Commit 1df4f711 by Torkel Ödegaard Committed by GitHub

Dashboard: Restore panel edit permission check, fixes 26555' (#26556)

parent a94745af
......@@ -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();
......
......@@ -117,6 +117,12 @@ export class DashboardPage extends PureComponent<Props, State> {
// 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 });
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment