Skip to content

Commit

Permalink
Add required default markdown visState (#38390)
Browse files Browse the repository at this point in the history
The markdownVis expression has the markdown string property configured as required.The current implementation of the markdown vis doesn't have a default value (actually it's undefined) and this cause the error to be thrown when creating a new markdown vis.

fix #38127
  • Loading branch information
markov00 committed Jun 17, 2019
1 parent b36aad3 commit 1c495ae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/legacy/core_plugins/markdown_vis/public/markdown_vis.js
Expand Up @@ -43,7 +43,8 @@ function MarkdownVisProvider() {
component: MarkdownVisWrapper,
defaults: {
fontSize: 12,
openLinksInNewTab: false
openLinksInNewTab: false,
markdown: '',
}
},
editorConfig: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -92,6 +92,12 @@ describe('visualize loader pipeline helpers: build pipeline', () => {
expect(actual).toMatchSnapshot();
});

it('handles undefined markdown function', () => {
const params = { fontSize: 12, openLinksInNewTab: true, foo: 'bar' };
const actual = buildPipelineVisFunction.markdown({ params });
expect(actual).toMatchSnapshot();
});

describe('handles table function', () => {
it('without splits or buckets', () => {
const params = { foo: 'bar' };
Expand Down
Expand Up @@ -226,7 +226,10 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = {
},
markdown: visState => {
const { markdown, fontSize, openLinksInNewTab } = visState.params;
const escapedMarkdown = escapeString(markdown);
let escapedMarkdown = '';
if (typeof markdown === 'string' || markdown instanceof String) {
escapedMarkdown = escapeString(markdown.toString());
}
let expr = `markdownvis '${escapedMarkdown}' `;
if (fontSize) {
expr += ` fontSize=${fontSize} `;
Expand Down

0 comments on commit 1c495ae

Please sign in to comment.