Plugins: better warning when plugins fail to load (#18671)

* better pluin feedback

* add server side check for module.js
This commit is contained in:
Ryan McKinley
2019-08-21 22:04:02 -07:00
committed by Torkel Ödegaard
parent c98c5c3c8e
commit f7c55d3968
6 changed files with 44 additions and 15 deletions

View File

@@ -1,19 +1,20 @@
// Libraries
import _ from 'lodash';
import React, { PureComponent } from 'react';
import React, { PureComponent, ReactNode } from 'react';
// Components
import { AlertBox } from 'app/core/components/AlertBox/AlertBox';
// Types
import { AppNotificationSeverity } from 'app/types';
import { PanelProps, PanelPlugin, PluginType } from '@grafana/ui';
import { PanelProps, PanelPlugin, PluginType, PanelPluginMeta } from '@grafana/ui';
interface Props {
pluginId: string;
title: string;
text?: ReactNode;
}
class PanelPluginNotFound extends PureComponent<Props> {
class PanelPluginError extends PureComponent<Props> {
constructor(props: Props) {
super(props);
}
@@ -28,16 +29,33 @@ class PanelPluginNotFound extends PureComponent<Props> {
return (
<div style={style}>
<AlertBox severity={AppNotificationSeverity.Error} title={`Panel plugin not found: ${this.props.pluginId}`} />
<AlertBox severity={AppNotificationSeverity.Error} {...this.props} />
</div>
);
}
}
export function getPanelPluginLoadError(meta: PanelPluginMeta, err: any): PanelPlugin {
const NotFound = class NotFound extends PureComponent<PanelProps> {
render() {
const text = (
<>
Check the server startup logs for more information. <br />
If this plugin was loaded from git, make sure it was compiled.
</>
);
return <PanelPluginError title={`Error loading: ${meta.id}`} text={text} />;
}
};
const plugin = new PanelPlugin(NotFound);
plugin.meta = meta;
return plugin;
}
export function getPanelPluginNotFound(id: string): PanelPlugin {
const NotFound = class NotFound extends PureComponent<PanelProps> {
render() {
return <PanelPluginNotFound pluginId={id} />;
return <PanelPluginError title={`Panel plugin not found: ${id}`} />;
}
};