mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
* Remove deprecated setDefault usages * Add simple support for conditinal field config properties * Use new API in NewsPanel * Update tests * Fix check
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { PanelModel, PanelPlugin } from '@grafana/data';
|
|
|
|
import { TextPanel } from './TextPanel';
|
|
import { TextOptions } from './types';
|
|
|
|
export const plugin = new PanelPlugin<TextOptions>(TextPanel)
|
|
.setPanelOptions(builder => {
|
|
builder
|
|
.addRadio({
|
|
path: 'mode',
|
|
name: 'Mode',
|
|
description: 'text mode of the panel',
|
|
settings: {
|
|
options: [
|
|
{ value: 'markdown', label: 'Markdown' },
|
|
{ value: 'text', label: 'Text' },
|
|
{ value: 'html', label: 'HTML' },
|
|
],
|
|
},
|
|
defaultValue: 'markdown',
|
|
})
|
|
.addTextInput({
|
|
path: 'content',
|
|
name: 'Content',
|
|
description: 'Content of the panel',
|
|
settings: {
|
|
useTextarea: true,
|
|
rows: 5,
|
|
},
|
|
defaultValue: `# Title
|
|
|
|
For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)
|
|
`,
|
|
});
|
|
})
|
|
.setPanelChangeHandler((panel: PanelModel<TextOptions>, prevPluginId: string, prevOptions: any) => {
|
|
if (prevPluginId === 'text') {
|
|
return prevOptions as TextOptions;
|
|
}
|
|
return panel.options;
|
|
});
|