Browse Source

wip: panel-header: Start implementing the Toggle legend, but its not taken all the way

Johannes Schill 7 years ago
parent
commit
6151310216

+ 14 - 2
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx

@@ -3,7 +3,14 @@ import { DashboardModel } from 'app/features/dashboard/dashboard_model';
 import { PanelHeaderMenuItem, PanelHeaderMenuItemTypes } from './PanelHeaderMenuItem';
 import { store } from 'app/store/configureStore';
 import { updateLocation } from 'app/core/actions';
-import { removePanel, duplicatePanel, copyPanel, editPanelJson, sharePanel } from 'app/features/dashboard/utils/panel';
+import {
+  removePanel,
+  duplicatePanel,
+  copyPanel,
+  editPanelJson,
+  sharePanel,
+  toggleLegend,
+} from 'app/features/dashboard/utils/panel';
 
 export interface PanelHeaderMenuProps {
   panelId: number;
@@ -73,6 +80,11 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
     editPanelJson(dashboard, panel);
   };
 
+  onToggleLegend = () => {
+    const panel = this.getPanel();
+    toggleLegend(panel);
+  };
+
   render() {
     return (
       <div className="panel-menu-container dropdown">
@@ -122,7 +134,7 @@ export class PanelHeaderMenu extends PureComponent<PanelHeaderMenuProps, any> {
               <PanelHeaderMenuItem
                 type={PanelHeaderMenuItemTypes.Link}
                 text="Toggle legend"
-                handleClick={() => {}}
+                handleClick={this.onToggleLegend}
                 shortcut="p l"
               />
             </ul>

+ 11 - 0
public/app/features/dashboard/utils/panel.ts

@@ -73,3 +73,14 @@ export const sharePanel = (dashboard: DashboardModel, panel: PanelModel) => {
     },
   });
 };
+
+export const refreshPanel = (panel: PanelModel) => {
+  panel.refresh();
+};
+
+export const toggleLegend = (panel: PanelModel) => {
+  console.log('Toggle legend is not implemented yet');
+  // We need to set panel.legend defaults first
+  // panel.legend.show = !panel.legend.show;
+  refreshPanel(panel);
+};