mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Restore panel edit permission check, fixes 26555' (#26556)
This commit is contained in:
parent
a94745af00
commit
1df4f71197
@ -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 });
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user