TextPanel: Removes text mode (#25589)

This commit is contained in:
Hugo Häggmark 2020-06-15 10:17:46 +02:00 committed by GitHub
parent 7a27dfdffa
commit 258092ec7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 2 deletions

View File

@ -14,7 +14,6 @@ export const plugin = new PanelPlugin<TextOptions>(TextPanel)
settings: {
options: [
{ value: 'markdown', label: 'Markdown' },
{ value: 'text', label: 'Text' },
{ value: 'html', label: 'HTML' },
],
},

View File

@ -6,6 +6,7 @@
"skipDataQuery": true,
"info": {
"version": "7.1.0",
"author": {
"name": "Grafana Labs",
"url": "https://grafana.com"

View File

@ -40,4 +40,28 @@ describe('textPanelMigrationHandler', () => {
expect(result.mode).toEqual('markdown');
});
});
describe('when invoked and previous version was using text mode', () => {
it('then should switch to markdown', () => {
const panel: PanelModel<TextOptions> = {
id: 1,
fieldConfig: ({} as unknown) as FieldConfigSource,
options: {
content: `# Title
For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)
`,
mode: 'text',
},
};
const result = textPanelMigrationHandler(panel);
expect(result.content).toEqual(`# Title
For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)
`);
expect(result.mode).toEqual('markdown');
});
});
});

View File

@ -11,5 +11,9 @@ export const textPanelMigrationHandler = (panel: PanelModel<TextOptions>): Parti
return { content, mode };
}
return panel.options as TextOptions;
if (panel.options.mode === 'text') {
return { content: panel.options.content, mode: 'markdown' };
}
return panel.options;
};