mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
refactor to not crash when no links
This commit is contained in:
parent
bf7ba9a4d1
commit
659b5a3c15
@ -25,18 +25,24 @@ export default class PluginHelp extends PureComponent<Props, State> {
|
||||
this.loadHelp();
|
||||
}
|
||||
|
||||
constructPlaceholderInfo() {
|
||||
constructPlaceholderInfo = () => {
|
||||
const { plugin } = this.props;
|
||||
const markdown = new Remarkable();
|
||||
|
||||
return markdown.render(
|
||||
const fallBack = markdown.render(
|
||||
`## ${plugin.name} \n by _${plugin.info.author.name} (<${plugin.info.author.url}>)_\n\n${
|
||||
plugin.info.description
|
||||
}\n\n### Links \n ${plugin.info.links.map(link => {
|
||||
return `${link.name}: <${link.url}>\n`;
|
||||
})}`
|
||||
}\n\n${
|
||||
plugin.info.links
|
||||
? `### Links \n ${plugin.info.links.map(link => {
|
||||
return `${link.name}: <${link.url}>\n`;
|
||||
})}`
|
||||
: ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
return fallBack;
|
||||
};
|
||||
|
||||
loadHelp = () => {
|
||||
const { plugin, type } = this.props;
|
||||
@ -48,7 +54,7 @@ export default class PluginHelp extends PureComponent<Props, State> {
|
||||
const markdown = new Remarkable();
|
||||
const helpHtml = markdown.render(response);
|
||||
|
||||
if (response === '' && this.props.type === 'help') {
|
||||
if (response === '' && type === 'help') {
|
||||
this.setState({
|
||||
isError: false,
|
||||
isLoading: false,
|
||||
|
@ -205,7 +205,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
||||
}
|
||||
};
|
||||
|
||||
renderHelp = () => <PluginHelp plugin={this.state.currentDataSource.meta} type="panel_help" />;
|
||||
renderHelp = () => <PluginHelp plugin={this.state.currentDataSource.meta} type="help" />;
|
||||
|
||||
render() {
|
||||
const { plugin } = this.props;
|
||||
|
Loading…
Reference in New Issue
Block a user