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

This commit is contained in:
Ryan McKinley
2019-08-26 23:43:45 -07:00
committed by GitHub
parent e83f55f394
commit 8ce509f3b4
3 changed files with 24 additions and 5 deletions

View File

@@ -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">