From a0d440fb03199e43192dc176c6943cca138a185a Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 21 Mar 2023 07:15:45 -0700 Subject: [PATCH] Dashboards: Show copy menu item to editors (regardless of dashboard edit state) (#64826) --- .../features/dashboard/utils/getPanelMenu.ts | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/public/app/features/dashboard/utils/getPanelMenu.ts b/public/app/features/dashboard/utils/getPanelMenu.ts index 4de4e890095..d2bbaee17d2 100644 --- a/public/app/features/dashboard/utils/getPanelMenu.ts +++ b/public/app/features/dashboard/utils/getPanelMenu.ts @@ -187,28 +187,35 @@ export function getPanelMenu( const subMenu: PanelMenuItem[] = []; const canEdit = dashboard.canEditPanel(panel); + if (!(panel.isViewing || panel.isEditing)) { + if (canEdit) { + subMenu.push({ + text: t('panel.header-menu.duplicate', `Duplicate`), + onClick: onDuplicatePanel, + shortcut: 'p d', + }); - if (canEdit && !(panel.isViewing || panel.isEditing)) { - subMenu.push({ - text: t('panel.header-menu.duplicate', `Duplicate`), - onClick: onDuplicatePanel, - shortcut: 'p d', - }); - - subMenu.push({ - text: t('panel.header-menu.copy', `Copy`), - onClick: onCopyPanel, - }); - - if (isPanelModelLibraryPanel(panel)) { subMenu.push({ - text: t('panel.header-menu.unlink-library-panel', `Unlink library panel`), - onClick: onUnlinkLibraryPanel, + text: t('panel.header-menu.copy', `Copy`), + onClick: onCopyPanel, }); - } else { + + if (isPanelModelLibraryPanel(panel)) { + subMenu.push({ + text: t('panel.header-menu.unlink-library-panel', `Unlink library panel`), + onClick: onUnlinkLibraryPanel, + }); + } else { + subMenu.push({ + text: t('panel.header-menu.create-library-panel', `Create library panel`), + onClick: onAddLibraryPanel, + }); + } + } else if (contextSrv.isEditor) { + // An editor but the dashboard is not editable subMenu.push({ - text: t('panel.header-menu.create-library-panel', `Create library panel`), - onClick: onAddLibraryPanel, + text: t('panel.header-menu.copy', `Copy`), + onClick: onCopyPanel, }); } }