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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 28 deletions

View File

@ -4200,13 +4200,12 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
[0, 0, 0, "Unexpected any. Specify a different type.", "15"]
],
"public/app/features/dashboard/utils/panelMerge.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],

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',