mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
use replaceVariables
This commit is contained in:
@@ -3,7 +3,6 @@ import React, { Component } from 'react';
|
|||||||
import Remarkable from 'remarkable';
|
import Remarkable from 'remarkable';
|
||||||
import { sanitize } from 'app/core/utils/text';
|
import { sanitize } from 'app/core/utils/text';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import templateSrv from 'app/features/templating/template_srv';
|
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
@@ -21,15 +20,8 @@ export class TextPanel extends Component<Props, State> {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
// TODO thre must be some better way to start with defualt options!
|
|
||||||
let opts = props.options;
|
|
||||||
if (opts && opts['options']) {
|
|
||||||
opts = opts['options'];
|
|
||||||
console.log('WEIRD!', opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
html: this.processContent(opts),
|
html: this.processContent(props.options),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +39,11 @@ export class TextPanel extends Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepareHTML(html: string): string {
|
prepareHTML(html: string): string {
|
||||||
const scopedVars = {}; // TODO?? = this.props.;
|
const { replaceVariables } = this.props;
|
||||||
|
|
||||||
html = config.disableSanitizeHtml ? html : sanitize(html);
|
html = config.disableSanitizeHtml ? html : sanitize(html);
|
||||||
try {
|
try {
|
||||||
return templateSrv.replace(html, scopedVars);
|
return replaceVariables(html);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TODO -- put the error in the header window
|
// TODO -- put the error in the header window
|
||||||
console.log('Text panel error: ', e);
|
console.log('Text panel error: ', e);
|
||||||
|
@@ -10,9 +10,9 @@ export class TextPanelEditor extends PureComponent<PanelEditorProps<TextOptions>
|
|||||||
{ value: 'html', label: 'HTML' },
|
{ value: 'html', label: 'HTML' },
|
||||||
];
|
];
|
||||||
|
|
||||||
onModeChange = (item: SelectOptionItem) => this.props.onChange({ ...this.props.options, mode: item.value });
|
onModeChange = (item: SelectOptionItem) => this.props.onOptionsChange({ ...this.props.options, mode: item.value });
|
||||||
|
|
||||||
onContentChange = evt => this.props.onChange({ ...this.props.options, content: (event.target as any).value });
|
onContentChange = evt => this.props.onOptionsChange({ ...this.props.options, content: (event.target as any).value });
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { mode, content } = this.props.options;
|
const { mode, content } = this.props.options;
|
||||||
|
Reference in New Issue
Block a user