Просмотр исходного кода

wip: another baby step, another million to go

Torkel Ödegaard 7 лет назад
Родитель
Сommit
211e0f2199

+ 1 - 1
public/app/features/dashboard/dashgrid/DashboardPanel.tsx

@@ -107,7 +107,6 @@ export class DashboardPanel extends React.Component<Props, State> {
 
 
     // this might look strange with these classes that change when edit, but
     // this might look strange with these classes that change when edit, but
     // I want to try to keep markup (parents) for panel the same in edit mode to avoide unmount / new mount of panel
     // I want to try to keep markup (parents) for panel the same in edit mode to avoide unmount / new mount of panel
-    // plugin component
     return (
     return (
       <div className={containerClass}>
       <div className={containerClass}>
         <div className={panelWrapperClass}>
         <div className={panelWrapperClass}>
@@ -124,6 +123,7 @@ export class DashboardPanel extends React.Component<Props, State> {
               panelType={this.props.panel.type}
               panelType={this.props.panel.type}
               dashboard={this.props.dashboard}
               dashboard={this.props.dashboard}
               onTypeChanged={this.onPluginTypeChanged}
               onTypeChanged={this.onPluginTypeChanged}
+              pluginExports={pluginExports}
             />
             />
           </div>
           </div>
         )}
         )}

+ 14 - 1
public/app/features/dashboard/dashgrid/PanelEditor.tsx

@@ -5,13 +5,14 @@ import { DashboardModel } from '../dashboard_model';
 import { store } from 'app/stores/store';
 import { store } from 'app/stores/store';
 import { observer } from 'mobx-react';
 import { observer } from 'mobx-react';
 import { QueriesTab } from './QueriesTab';
 import { QueriesTab } from './QueriesTab';
-import { PanelPlugin } from 'app/types/plugins';
+import { PanelPlugin, PluginExports } from 'app/types/plugins';
 import { VizTypePicker } from './VizTypePicker';
 import { VizTypePicker } from './VizTypePicker';
 
 
 interface PanelEditorProps {
 interface PanelEditorProps {
   panel: PanelModel;
   panel: PanelModel;
   dashboard: DashboardModel;
   dashboard: DashboardModel;
   panelType: string;
   panelType: string;
+  pluginExports: PluginExports;
   onTypeChanged: (newType: PanelPlugin) => void;
   onTypeChanged: (newType: PanelPlugin) => void;
 }
 }
 
 
@@ -38,6 +39,17 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
     return <QueriesTab panel={this.props.panel} dashboard={this.props.dashboard} />;
     return <QueriesTab panel={this.props.panel} dashboard={this.props.dashboard} />;
   }
   }
 
 
+  renderPanelOptions() {
+    const { pluginExports } = this.props;
+
+    if (pluginExports.PanelOptions) {
+      const PanelOptions = pluginExports.PanelOptions;
+      return <PanelOptions />;
+    } else {
+      return <p>Visualization has no options</p>;
+    }
+  }
+
   renderVizTab() {
   renderVizTab() {
     return (
     return (
       <div className="viz-editor">
       <div className="viz-editor">
@@ -46,6 +58,7 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
         </div>
         </div>
         <div className="viz-editor-col2">
         <div className="viz-editor-col2">
           <h5 className="page-heading">Options</h5>
           <h5 className="page-heading">Options</h5>
+          {this.renderPanelOptions()}
         </div>
         </div>
       </div>
       </div>
     );
     );

+ 7 - 1
public/app/plugins/panel/text2/module.tsx

@@ -18,4 +18,10 @@ export class ReactTestPanel extends PureComponent<PanelProps> {
   }
   }
 }
 }
 
 
-export { ReactTestPanel as PanelComponent };
+export class TextOptions extends PureComponent<any> {
+  render() {
+    return <p>Text2 Options component</p>;
+  }
+}
+
+export { ReactTestPanel as PanelComponent, TextOptions as PanelOptions };

+ 1 - 0
public/app/types/plugins.ts

@@ -5,6 +5,7 @@ export interface PluginExports {
   QueryCtrl?: any;
   QueryCtrl?: any;
   ConfigCtrl?: any;
   ConfigCtrl?: any;
   AnnotationsQueryCtrl?: any;
   AnnotationsQueryCtrl?: any;
+  PanelOptions?: any;
 }
 }
 
 
 export interface PanelPlugin {
 export interface PanelPlugin {

+ 1 - 1
public/sass/components/_viz_editor.scss

@@ -23,7 +23,7 @@
   padding-top: $spacer;
   padding-top: $spacer;
   display: flex;
   display: flex;
   flex-direction: column;
   flex-direction: column;
-  overflow: hidden;
+  overflow: auto;
   flex-grow: 1;
   flex-grow: 1;
 }
 }