|
@@ -18,12 +18,12 @@ import { PanelModel } from '../state';
|
|
|
import { DashboardModel } from '../state';
|
|
import { DashboardModel } from '../state';
|
|
|
import { VizPickerSearch } from './VizPickerSearch';
|
|
import { VizPickerSearch } from './VizPickerSearch';
|
|
|
import PluginStateinfo from 'app/features/plugins/PluginStateInfo';
|
|
import PluginStateinfo from 'app/features/plugins/PluginStateInfo';
|
|
|
-import { PanelPluginMeta } from '@grafana/ui';
|
|
|
|
|
|
|
+import { PanelPlugin, PanelPluginMeta } from '@grafana/ui';
|
|
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
|
panel: PanelModel;
|
|
panel: PanelModel;
|
|
|
dashboard: DashboardModel;
|
|
dashboard: DashboardModel;
|
|
|
- plugin: PanelPluginMeta;
|
|
|
|
|
|
|
+ plugin: PanelPlugin;
|
|
|
angularPanel?: AngularComponent;
|
|
angularPanel?: AngularComponent;
|
|
|
onTypeChanged: (newType: PanelPluginMeta) => void;
|
|
onTypeChanged: (newType: PanelPluginMeta) => void;
|
|
|
updateLocation: typeof updateLocation;
|
|
updateLocation: typeof updateLocation;
|
|
@@ -41,7 +41,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
element: HTMLElement;
|
|
element: HTMLElement;
|
|
|
angularOptions: AngularComponent;
|
|
angularOptions: AngularComponent;
|
|
|
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
|
|
+ constructor(props: Props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
this.state = {
|
|
@@ -54,7 +54,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
|
|
|
|
|
getReactPanelOptions = () => {
|
|
getReactPanelOptions = () => {
|
|
|
const { panel, plugin } = this.props;
|
|
const { panel, plugin } = this.props;
|
|
|
- return panel.getOptions(plugin.panelPlugin.defaults);
|
|
|
|
|
|
|
+ return panel.getOptions(plugin.defaults);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
renderPanelOptions() {
|
|
renderPanelOptions() {
|
|
@@ -64,12 +64,8 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
return <div ref={element => (this.element = element)} />;
|
|
return <div ref={element => (this.element = element)} />;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (plugin.panelPlugin) {
|
|
|
|
|
- const PanelEditor = plugin.panelPlugin.editor;
|
|
|
|
|
-
|
|
|
|
|
- if (PanelEditor) {
|
|
|
|
|
- return <PanelEditor options={this.getReactPanelOptions()} onOptionsChange={this.onPanelOptionsChanged} />;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (plugin.editor) {
|
|
|
|
|
+ return <plugin.editor options={this.getReactPanelOptions()} onOptionsChange={this.onPanelOptionsChanged} />;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <p>Visualization has no options</p>;
|
|
return <p>Visualization has no options</p>;
|
|
@@ -176,11 +172,12 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
renderToolbar = (): JSX.Element => {
|
|
renderToolbar = (): JSX.Element => {
|
|
|
const { plugin } = this.props;
|
|
const { plugin } = this.props;
|
|
|
const { isVizPickerOpen, searchQuery } = this.state;
|
|
const { isVizPickerOpen, searchQuery } = this.state;
|
|
|
|
|
+ const { meta } = plugin;
|
|
|
|
|
|
|
|
if (isVizPickerOpen) {
|
|
if (isVizPickerOpen) {
|
|
|
return (
|
|
return (
|
|
|
<VizPickerSearch
|
|
<VizPickerSearch
|
|
|
- plugin={plugin}
|
|
|
|
|
|
|
+ plugin={meta}
|
|
|
searchQuery={searchQuery}
|
|
searchQuery={searchQuery}
|
|
|
onChange={this.onSearchQueryChange}
|
|
onChange={this.onSearchQueryChange}
|
|
|
onClose={this.onCloseVizPicker}
|
|
onClose={this.onCloseVizPicker}
|
|
@@ -189,8 +186,8 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
} else {
|
|
} else {
|
|
|
return (
|
|
return (
|
|
|
<div className="toolbar__main" onClick={this.onOpenVizPicker}>
|
|
<div className="toolbar__main" onClick={this.onOpenVizPicker}>
|
|
|
- <img className="toolbar__main-image" src={plugin.info.logos.small} />
|
|
|
|
|
- <div className="toolbar__main-name">{plugin.name}</div>
|
|
|
|
|
|
|
+ <img className="toolbar__main-image" src={meta.info.logos.small} />
|
|
|
|
|
+ <div className="toolbar__main-name">{meta.name}</div>
|
|
|
<i className="fa fa-caret-down" />
|
|
<i className="fa fa-caret-down" />
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
@@ -198,14 +195,14 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
onTypeChanged = (plugin: PanelPluginMeta) => {
|
|
onTypeChanged = (plugin: PanelPluginMeta) => {
|
|
|
- if (plugin.id === this.props.plugin.id) {
|
|
|
|
|
|
|
+ if (plugin.id === this.props.plugin.meta.id) {
|
|
|
this.setState({ isVizPickerOpen: false });
|
|
this.setState({ isVizPickerOpen: false });
|
|
|
} else {
|
|
} else {
|
|
|
this.props.onTypeChanged(plugin);
|
|
this.props.onTypeChanged(plugin);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />;
|
|
|
|
|
|
|
+ renderHelp = () => <PluginHelp plugin={this.props.plugin.meta} type="help" />;
|
|
|
|
|
|
|
|
setScrollTop = (event: React.MouseEvent<HTMLElement>) => {
|
|
setScrollTop = (event: React.MouseEvent<HTMLElement>) => {
|
|
|
const target = event.target as HTMLElement;
|
|
const target = event.target as HTMLElement;
|
|
@@ -215,6 +212,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
render() {
|
|
render() {
|
|
|
const { plugin } = this.props;
|
|
const { plugin } = this.props;
|
|
|
const { isVizPickerOpen, searchQuery, scrollTop } = this.state;
|
|
const { isVizPickerOpen, searchQuery, scrollTop } = this.state;
|
|
|
|
|
+ const { meta } = plugin;
|
|
|
|
|
|
|
|
const pluginHelp: EditorToolbarView = {
|
|
const pluginHelp: EditorToolbarView = {
|
|
|
heading: 'Help',
|
|
heading: 'Help',
|
|
@@ -233,13 +231,13 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
|
|
<>
|
|
<>
|
|
|
<FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}>
|
|
<FadeIn in={isVizPickerOpen} duration={200} unmountOnExit={true} onExited={this.clearQuery}>
|
|
|
<VizTypePicker
|
|
<VizTypePicker
|
|
|
- current={plugin}
|
|
|
|
|
|
|
+ current={meta}
|
|
|
onTypeChanged={this.onTypeChanged}
|
|
onTypeChanged={this.onTypeChanged}
|
|
|
searchQuery={searchQuery}
|
|
searchQuery={searchQuery}
|
|
|
onClose={this.onCloseVizPicker}
|
|
onClose={this.onCloseVizPicker}
|
|
|
/>
|
|
/>
|
|
|
</FadeIn>
|
|
</FadeIn>
|
|
|
- <PluginStateinfo state={plugin.state} />
|
|
|
|
|
|
|
+ <PluginStateinfo state={meta.state} />
|
|
|
{this.renderPanelOptions()}
|
|
{this.renderPanelOptions()}
|
|
|
</>
|
|
</>
|
|
|
</EditorTabBody>
|
|
</EditorTabBody>
|