Commit 8ce509f3 by Ryan McKinley Committed by GitHub

Plugins: show a clear error on the plugin page when it failed to load (#18733)

parent e83f55f3
......@@ -124,6 +124,9 @@ export class GrafanaPlugin<T extends PluginMeta = PluginMeta> {
// Meta is filled in by the plugin loading system
meta?: T;
// This is set if the plugin system had errors loading the plugin
loadError?: boolean;
// Config control (app/datasource)
angularConfigCtrl?: any;
......
......@@ -36,7 +36,7 @@ class PanelPluginError extends PureComponent<Props> {
}
export function getPanelPluginLoadError(meta: PanelPluginMeta, err: any): PanelPlugin {
const NotFound = class NotFound extends PureComponent<PanelProps> {
const LoadError = class LoadError extends PureComponent<PanelProps> {
render() {
const text = (
<>
......@@ -47,8 +47,9 @@ export function getPanelPluginLoadError(meta: PanelPluginMeta, err: any): PanelP
return <PanelPluginError title={`Error loading: ${meta.id}`} text={text} />;
}
};
const plugin = new PanelPlugin(NotFound);
const plugin = new PanelPlugin(LoadError);
plugin.meta = meta;
plugin.loadError = true;
return plugin;
}
......
......@@ -6,7 +6,7 @@ import find from 'lodash/find';
// Types
import { UrlQueryMap } from '@grafana/runtime';
import { StoreState } from 'app/types';
import { StoreState, AppNotificationSeverity } from 'app/types';
import {
PluginType,
GrafanaPlugin,
......@@ -30,6 +30,7 @@ import { PluginDashboards } from './PluginDashboards';
import { appEvents } from 'app/core/core';
import { config } from 'app/core/config';
import { ContextSrv } from '../../core/services/context_srv';
import { AlertBox } from 'app/core/components/AlertBox/AlertBox';
export function getLoadingNav(): NavModel {
const node = {
......@@ -140,7 +141,7 @@ class PluginPage extends PureComponent<Props, State> {
const { plugin, nav } = this.state;
if (!plugin) {
return <div>Plugin not found.</div>;
return <AlertBox severity={AppNotificationSeverity.Error} title="Plugin Not Found" />;
}
const active = nav.main.children.find(tab => tab.active);
......@@ -297,7 +298,21 @@ class PluginPage extends PureComponent<Props, State> {
<Page.Contents isLoading={loading}>
{!loading && (
<div className="sidebar-container">
<div className="sidebar-content">{this.renderBody()}</div>
<div className="sidebar-content">
{plugin.loadError && (
<AlertBox
severity={AppNotificationSeverity.Error}
title="Error Loading Plugin"
body={
<>
Check the server startup logs for more information. <br />
If this plugin was loaded from git, make sure it was compiled.
</>
}
/>
)}
{this.renderBody()}
</div>
<aside className="page-sidebar">
{plugin && (
<section className="page-sidebar-section">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment