|
@@ -1,19 +1,20 @@
|
|
|
// Libraries
|
|
// Libraries
|
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
-import React, { PureComponent } from 'react';
|
|
|
|
|
|
|
+import React, { PureComponent, ReactNode } from 'react';
|
|
|
|
|
|
|
|
// Components
|
|
// Components
|
|
|
import { AlertBox } from 'app/core/components/AlertBox/AlertBox';
|
|
import { AlertBox } from 'app/core/components/AlertBox/AlertBox';
|
|
|
|
|
|
|
|
// Types
|
|
// Types
|
|
|
import { AppNotificationSeverity } from 'app/types';
|
|
import { AppNotificationSeverity } from 'app/types';
|
|
|
-import { PanelProps, PanelPlugin, PluginType } from '@grafana/ui';
|
|
|
|
|
|
|
+import { PanelProps, PanelPlugin, PluginType, PanelPluginMeta } from '@grafana/ui';
|
|
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
|
- pluginId: string;
|
|
|
|
|
|
|
+ title: string;
|
|
|
|
|
+ text?: ReactNode;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-class PanelPluginNotFound extends PureComponent<Props> {
|
|
|
|
|
|
|
+class PanelPluginError extends PureComponent<Props> {
|
|
|
constructor(props: Props) {
|
|
constructor(props: Props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
}
|
|
}
|
|
@@ -28,16 +29,33 @@ class PanelPluginNotFound extends PureComponent<Props> {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div style={style}>
|
|
<div style={style}>
|
|
|
- <AlertBox severity={AppNotificationSeverity.Error} title={`Panel plugin not found: ${this.props.pluginId}`} />
|
|
|
|
|
|
|
+ <AlertBox severity={AppNotificationSeverity.Error} {...this.props} />
|
|
|
</div>
|
|
</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 {
|
|
export function getPanelPluginNotFound(id: string): PanelPlugin {
|
|
|
const NotFound = class NotFound extends PureComponent<PanelProps> {
|
|
const NotFound = class NotFound extends PureComponent<PanelProps> {
|
|
|
render() {
|
|
render() {
|
|
|
- return <PanelPluginNotFound pluginId={id} />;
|
|
|
|
|
|
|
+ return <PanelPluginError title={`Panel plugin not found: ${id}`} />;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|