From 61513102169f05d7955d34254830c85cd302cf01 Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Wed, 31 Oct 2018 13:43:21 +0100 Subject: [PATCH] wip: panel-header: Start implementing the Toggle legend, but its not taken all the way --- .../dashgrid/PanelHeader/PanelHeaderMenu.tsx | 16 ++++++++++++++-- public/app/features/dashboard/utils/panel.ts | 11 +++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx b/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx index 13b0fca86e9..826406fddff 100644 --- a/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderMenu.tsx +++ b/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 { editPanelJson(dashboard, panel); }; + onToggleLegend = () => { + const panel = this.getPanel(); + toggleLegend(panel); + }; + render() { return (
@@ -122,7 +134,7 @@ export class PanelHeaderMenu extends PureComponent { {}} + handleClick={this.onToggleLegend} shortcut="p l" /> diff --git a/public/app/features/dashboard/utils/panel.ts b/public/app/features/dashboard/utils/panel.ts index fff837d9685..151c1ea8d61 100644 --- a/public/app/features/dashboard/utils/panel.ts +++ b/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); +};