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

This commit is contained in:
Johannes Schill 2018-10-31 13:43:21 +01:00
parent 79da3dc9f6
commit 6151310216
2 changed files with 25 additions and 2 deletions

View File

@ -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>

View File

@ -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);
};