diff --git a/public/app/features/dashboard/containers/DashboardPage.test.tsx b/public/app/features/dashboard/containers/DashboardPage.test.tsx index ab43cd1249d..c5465bebc7a 100644 --- a/public/app/features/dashboard/containers/DashboardPage.test.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.test.tsx @@ -139,6 +139,20 @@ describe('DashboardPage', () => { }); }); + dashboardPageScenario('When user goes into panel edit but has no edit permissions', ctx => { + ctx.setup(() => { + ctx.mount(); + ctx.setDashboardProp({}, { canEdit: false }); + ctx.wrapper?.setProps({ + urlEditPanelId: '1', + }); + }); + + it('Should update component state to fullscreen and edit', () => { + const state = ctx.wrapper?.state(); + expect(state?.editPanel).toBe(null); + }); + }); dashboardPageScenario('When user goes back to dashboard from view panel', ctx => { ctx.setup(() => { ctx.mount(); diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index dcd7043e417..7c9e4249639 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -117,6 +117,12 @@ export class DashboardPage extends PureComponent { // entering edit mode if (!editPanel && urlEditPanelId) { this.getPanelByIdFromUrlParam(urlEditPanelId, panel => { + // if no edit permission show error + if (!dashboard.canEditPanel(panel)) { + this.props.notifyApp(createErrorNotification('Permission to edit panel denied')); + return; + } + this.setState({ editPanel: panel }); }); }