mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: panel plugin not found
This commit is contained in:
parent
7a30220d01
commit
119e94f745
@ -5,13 +5,14 @@ import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoa
|
||||
import { importPluginModule } from 'app/features/plugins/plugin_loader';
|
||||
|
||||
import { AddPanelPanel } from './AddPanelPanel';
|
||||
import { PanelPluginNotFound } from './PanelPluginNotFound';
|
||||
import { DashboardRow } from './DashboardRow';
|
||||
import { PanelPlugin } from 'app/types/plugins';
|
||||
import { PanelChrome } from './PanelChrome';
|
||||
import { PanelEditor } from './PanelEditor';
|
||||
|
||||
import { PanelModel } from '../panel_model';
|
||||
import { DashboardModel } from '../dashboard_model';
|
||||
import { PanelPlugin, PanelProps } from 'app/types';
|
||||
|
||||
export interface Props {
|
||||
panel: PanelModel;
|
||||
@ -70,7 +71,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
|
||||
|
||||
// handle plugin loading & changing of plugin type
|
||||
if (!this.state.plugin || this.state.plugin.id !== panel.type) {
|
||||
const plugin = config.panels[panel.type];
|
||||
const plugin = config.panels[panel.type] || this.getPanelPluginNotFound(panel.type);
|
||||
|
||||
if (plugin.exports) {
|
||||
this.cleanUpAngularPanel();
|
||||
@ -87,6 +88,22 @@ export class DashboardPanel extends PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
getPanelPluginNotFound(id: string): PanelPlugin {
|
||||
const NotFound = class NotFound extends PureComponent<PanelProps> {
|
||||
render() {
|
||||
return <PanelPluginNotFound pluginId={id} />;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
id: id,
|
||||
name: id,
|
||||
exports: {
|
||||
PanelComponent: NotFound,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.loadPlugin();
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ export class EditorTabBody extends PureComponent<Props, State> {
|
||||
{toolbarItems.map(item => this.renderButton(item))}
|
||||
</div>
|
||||
<div className="panel-editor__scroll">
|
||||
<CustomScrollbar>
|
||||
<CustomScrollbar autoHide={false}>
|
||||
<div className="panel-editor__content">
|
||||
<FadeIn in={openView !== null} duration={200}>
|
||||
{openView && this.renderOpenView(openView)}
|
||||
|
@ -0,0 +1,16 @@
|
||||
import _ from 'lodash';
|
||||
import React, { PureComponent } from 'react';
|
||||
|
||||
interface Props {
|
||||
pluginId: string;
|
||||
}
|
||||
|
||||
export class PanelPluginNotFound extends PureComponent<Props> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <h2>Panel plugin with id {this.props.id} could not be found</h2>;
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ import {
|
||||
DataQueryOptions,
|
||||
} from './series';
|
||||
import { PanelProps, PanelOptionsProps } from './panel';
|
||||
import { PluginDashboard, PluginMeta, Plugin, PluginsState } from './plugins';
|
||||
import { PluginDashboard, PluginMeta, Plugin, PanelPlugin, PluginsState } from './plugins';
|
||||
import { Organization, OrganizationPreferences, OrganizationState } from './organization';
|
||||
import {
|
||||
AppNotification,
|
||||
@ -69,6 +69,7 @@ export {
|
||||
UsersState,
|
||||
TimeRange,
|
||||
LoadingState,
|
||||
PanelPlugin,
|
||||
PanelProps,
|
||||
PanelOptionsProps,
|
||||
TimeSeries,
|
||||
|
@ -12,13 +12,13 @@ export interface PluginExports {
|
||||
// Panel plugin
|
||||
PanelCtrl?;
|
||||
PanelComponent?: ComponentClass<PanelProps>;
|
||||
PanelOptionsComponent: ComponentClass<PanelOptionsProps>;
|
||||
PanelOptionsComponent?: ComponentClass<PanelOptionsProps>;
|
||||
}
|
||||
|
||||
export interface PanelPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
meta: any;
|
||||
meta: PluginMeta;
|
||||
hideFromList: boolean;
|
||||
module: string;
|
||||
baseUrl: string;
|
||||
|
Loading…
Reference in New Issue
Block a user