mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: better warning when plugins fail to load (#18671)
* better pluin feedback * add server side check for module.js
This commit is contained in:
committed by
Torkel Ödegaard
parent
c98c5c3c8e
commit
f7c55d3968
@@ -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}`} />;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user