diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go index 8afbe870c14..d07ddaa63fa 100644 --- a/pkg/plugins/plugins.go +++ b/pkg/plugins/plugins.go @@ -216,6 +216,17 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error { } loader = reflect.New(reflect.TypeOf(pluginGoType)).Interface().(PluginLoader) + // External plugins need a module.js file for SystemJS to load + if !strings.HasPrefix(pluginJsonFilePath, setting.StaticRootPath) { + module := filepath.Join(filepath.Dir(pluginJsonFilePath), "module.js") + if _, err := os.Stat(module); os.IsNotExist(err) { + plog.Warn("Plugin missing module.js", + "name", pluginCommon.Name, + "warning", "Missing module.js, If you loaded this plugin from git, make sure to compile it.", + "path", module) + } + } + reader.Seek(0, 0) return loader.Load(jsonParser, currentDir) } diff --git a/public/app/core/components/AlertBox/AlertBox.tsx b/public/app/core/components/AlertBox/AlertBox.tsx index a0c8328def0..3bedf71dd5b 100644 --- a/public/app/core/components/AlertBox/AlertBox.tsx +++ b/public/app/core/components/AlertBox/AlertBox.tsx @@ -1,10 +1,10 @@ -import React, { FunctionComponent } from 'react'; +import React, { FunctionComponent, ReactNode } from 'react'; import { AppNotificationSeverity } from 'app/types'; interface Props { title: string; icon?: string; - text?: string; + body?: ReactNode; severity: AppNotificationSeverity; onClose?: () => void; } @@ -22,7 +22,7 @@ function getIconFromSeverity(severity: AppNotificationSeverity): string { } } -export const AlertBox: FunctionComponent = ({ title, icon, text, severity, onClose }) => { +export const AlertBox: FunctionComponent = ({ title, icon, body, severity, onClose }) => { return (
@@ -30,7 +30,7 @@ export const AlertBox: FunctionComponent = ({ title, icon, text, severity
{title}
- {text &&
{text}
} + {body &&
{body}
}
{onClose && (
); diff --git a/public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx b/public/app/features/dashboard/dashgrid/PanelPluginError.tsx similarity index 52% rename from public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx rename to public/app/features/dashboard/dashgrid/PanelPluginError.tsx index 80440c9631c..5bec4191873 100644 --- a/public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx +++ b/public/app/features/dashboard/dashgrid/PanelPluginError.tsx @@ -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 { +class PanelPluginError extends PureComponent { constructor(props: Props) { super(props); } @@ -28,16 +29,33 @@ class PanelPluginNotFound extends PureComponent { return (
- +
); } } +export function getPanelPluginLoadError(meta: PanelPluginMeta, err: any): PanelPlugin { + const NotFound = class NotFound extends PureComponent { + render() { + const text = ( + <> + Check the server startup logs for more information.
+ If this plugin was loaded from git, make sure it was compiled. + + ); + return ; + } + }; + const plugin = new PanelPlugin(NotFound); + plugin.meta = meta; + return plugin; +} + export function getPanelPluginNotFound(id: string): PanelPlugin { const NotFound = class NotFound extends PureComponent { render() { - return ; + return ; } }; diff --git a/public/app/features/plugins/plugin_loader.ts b/public/app/features/plugins/plugin_loader.ts index ac952cb9514..7c90ce4b441 100644 --- a/public/app/features/plugins/plugin_loader.ts +++ b/public/app/features/plugins/plugin_loader.ts @@ -199,7 +199,7 @@ export function importAppPlugin(meta: PluginMeta): Promise { }); } -import { getPanelPluginNotFound } from '../dashboard/dashgrid/PanelPluginNotFound'; +import { getPanelPluginNotFound, getPanelPluginLoadError } from '../dashboard/dashgrid/PanelPluginError'; interface PanelCache { [key: string]: PanelPlugin; @@ -233,7 +233,7 @@ export function importPanelPlugin(id: string): Promise { }) .catch(err => { // TODO, maybe a different error plugin - console.log('Error loading panel plugin', err); - return getPanelPluginNotFound(id); + console.warn('Error loading panel plugin: ' + id, err); + return getPanelPluginLoadError(meta, err); }); }