minor react panels refafactor

pull/14039/head
Torkel Ödegaard 7 years ago
parent e331d24a38
commit 7b805bdb81
  1. 4
      public/app/features/dashboard/dashgrid/DashboardPanel.tsx
  2. 6
      public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx
  3. 6
      public/app/features/dashboard/dashgrid/VisualizationTab.tsx
  4. 2
      public/app/plugins/panel/gauge/GaugeOptions.tsx
  5. 3
      public/app/plugins/panel/gauge/module.tsx
  6. 0
      public/app/plugins/panel/graph2/img/icn-graph-panel.svg
  7. 2
      public/app/plugins/panel/graph2/module.tsx
  8. 4
      public/app/plugins/panel/graph2/plugin.json
  9. 0
      public/app/plugins/panel/text2/img/icn-text-panel.svg
  10. 2
      public/app/plugins/panel/text2/module.tsx
  11. 4
      public/app/plugins/panel/text2/plugin.json
  12. 5
      public/app/types/panel.ts
  13. 4
      public/app/types/plugins.ts

@ -128,7 +128,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
return (
<div className={containerClass}>
<div className={panelWrapperClass}>
<PanelChrome component={plugin.exports.PanelComponent} panel={panel} dashboard={dashboard} />
<PanelChrome component={plugin.exports.Panel} panel={panel} dashboard={dashboard} />
</div>
{panel.isEditing && (
<PanelEditor panel={panel} plugin={plugin} dashboard={dashboard} onTypeChanged={this.onPluginTypeChanged} />
@ -151,7 +151,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
}
// if exporting PanelComponent it must be a react panel
if (plugin.exports.PanelComponent) {
if (plugin.exports.Panel) {
return this.renderReactPanel();
}

@ -14,8 +14,8 @@ class PanelPluginNotFound extends PureComponent<Props> {
render() {
const style = {
display: 'flex',
'align-items': 'center',
'text-align': 'center',
alignItems: 'center',
textAlign: 'center' as 'center',
height: '100%',
};
@ -58,7 +58,7 @@ export function getPanelPluginNotFound(id: string): PanelPlugin {
},
exports: {
PanelComponent: NotFound,
Panel: NotFound,
},
};
}

@ -21,10 +21,10 @@ export class VisualizationTab extends PureComponent<Props> {
renderPanelOptions() {
const { plugin, panel } = this.props;
const { PanelOptionsComponent } = plugin.exports;
const { PanelOptions } = plugin.exports;
if (PanelOptionsComponent) {
return <PanelOptionsComponent options={panel.getOptions()} onChange={this.onPanelOptionsChanged} />;
if (PanelOptions) {
return <PanelOptions options={panel.getOptions()} onChange={this.onPanelOptionsChanged} />;
} else {
return <p>Visualization has no options</p>;
}

@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { PanelOptionsProps } from '../types';
import { PanelOptionsProps } from 'app/types';
interface Props {}

@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import Gauge from 'app/viz/Gauge';
import { NullValueMode, PanelProps } from 'app/types';
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
import { GaugeOptions } from './GaugeOptions';
export interface Options {}
@ -20,4 +21,4 @@ export class GaugePanel extends PureComponent<Props> {
}
}
export { GaugePanel as PanelComponent };
export { GaugePanel as Panel, GaugeOptions as PanelOptions };

@ -87,4 +87,4 @@ export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
}
}
export { Graph2 as PanelComponent, GraphOptions as PanelOptionsComponent };
export { Graph2 as Panel, GraphOptions as PanelOptions };

@ -11,8 +11,8 @@
"url": "https://grafana.com"
},
"logos": {
"small": "img/icn-text-panel.svg",
"large": "img/icn-text-panel.svg"
"small": "img/icn-graph-panel.svg",
"large": "img/icn-graph-panel.svg"
}
}
}

@ -11,4 +11,4 @@ export class Text2 extends PureComponent<PanelProps> {
}
}
export { Text2 as PanelComponent };
export { Text2 as Panel };

@ -11,8 +11,8 @@
"url": "https://grafana.com"
},
"logos": {
"small": "img/icn-graph-panel.svg",
"large": "img/icn-graph-panel.svg"
"small": "img/icn-text-panel.svg",
"large": "img/icn-text-panel.svg"
}
}
}

@ -13,6 +13,11 @@ export interface PanelOptionsProps<T = any> {
onChange: (options: T) => void;
}
export interface PanelSize {
width: number;
height: number;
}
export interface PanelMenuItem {
type?: 'submenu' | 'divider';
text?: string;

@ -11,8 +11,8 @@ export interface PluginExports {
// Panel plugin
PanelCtrl?;
PanelComponent?: ComponentClass<PanelProps>;
PanelOptionsComponent?: ComponentClass<PanelOptionsProps>;
Panel?: ComponentClass<PanelProps>;
PanelOptions?: ComponentClass<PanelOptionsProps>;
}
export interface PanelPlugin {

Loading…
Cancel
Save