PanelMenu: Remove hide legend action as it was showing on all panel types (#54876)

* PanelMenu: Remove hide legend action

* Fix test

* Updated
This commit is contained in:
Torkel Ödegaard
2022-09-13 10:19:59 +02:00
committed by GitHub
parent dc1f7cc226
commit ab045184e4
3 changed files with 16 additions and 28 deletions

View File

@@ -45,12 +45,6 @@ describe('getPanelMenu', () => {
"shortcut": "x",
"text": "Explore",
},
Object {
"iconClassName": "exchange-alt",
"onClick": [Function],
"shortcut": "p l",
"text": "Show legend",
},
Object {
"iconClassName": "info-circle",
"onClick": [Function],
@@ -135,12 +129,6 @@ describe('getPanelMenu', () => {
"shortcut": "x",
"text": "Explore",
},
Object {
"iconClassName": "exchange-alt",
"onClick": [Function],
"shortcut": "p l",
"text": "Show legend",
},
Object {
"iconClassName": "info-circle",
"onClick": [Function],

View File

@@ -48,11 +48,6 @@ export function getPanelMenu(
sharePanel(dashboard, panel);
};
const onToggleLegend = (event: React.MouseEvent<any>) => {
event.preventDefault();
toggleLegend(panel);
};
const onAddLibraryPanel = (event: React.MouseEvent<any>) => {
event.preventDefault();
addLibraryPanel(dashboard, panel);
@@ -96,6 +91,10 @@ export function getPanelMenu(
store.dispatch(navigateToExplore(panel, { getDataSourceSrv, getTimeSrv, getExploreUrl, openInNewWindow }) as any);
};
const onToggleLegend = (event: React.MouseEvent) => {
event.preventDefault();
toggleLegend(panel);
};
const menu: PanelMenuItem[] = [];
if (!panel.isEditing) {
@@ -141,13 +140,6 @@ export function getPanelMenu(
});
}
menu.push({
text: panel.options.legend?.showLegend ? 'Hide legend' : 'Show legend',
iconClassName: 'exchange-alt',
onClick: onToggleLegend,
shortcut: 'p l',
});
const inspectMenu: PanelMenuItem[] = [];
// Only show these inspect actions for data plugins
@@ -192,6 +184,7 @@ export function getPanelMenu(
id: 'panel.header-menu.inspect',
message: `Inspect`,
});
menu.push({
type: 'submenu',
text: inspectTextTranslation,
@@ -251,6 +244,14 @@ export function getPanelMenu(
}
}
if (panel.options.legend) {
subMenu.push({
text: panel.options.legend.showLegend ? 'Hide legend' : 'Show legend',
onClick: onToggleLegend,
shortcut: 'p l',
});
}
if (!panel.isEditing && subMenu.length) {
const moreTextTranslation = t({
id: 'panel.header-menu.more',