Merge pull request #11786 from marefr/11625_save_as

dashboard: show save as button if user has edit permission

This will show the "Save As..." button in dashboard settings page if the user 
has edit permissions (org role admin/editor or viewers_can_edit enabled) 
and has at least edit permission in any folder.
This commit is contained in:
Marcus Efraimsson
2018-05-02 11:15:22 +02:00
committed by GitHub
7 changed files with 127 additions and 32 deletions

View File

@@ -11,6 +11,7 @@ export class User {
timezone: string;
helpFlags1: number;
lightTheme: boolean;
hasEditPermissionInFolders: boolean;
constructor() {
if (config.bootData.user) {
@@ -28,6 +29,7 @@ export class ContextSrv {
isEditor: any;
sidemenu: any;
sidemenuSmallBreakpoint = false;
hasEditPermissionInFolders: boolean;
constructor() {
this.sidemenu = store.getBool('grafana.sidemenu', true);
@@ -44,6 +46,7 @@ export class ContextSrv {
this.isSignedIn = this.user.isSignedIn;
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
this.isEditor = this.hasRole('Editor') || this.hasRole('Admin');
this.hasEditPermissionInFolders = this.user.hasEditPermissionInFolders;
}
hasRole(role) {

View File

@@ -30,7 +30,7 @@ export class SettingsCtrl {
});
});
this.canSaveAs = contextSrv.isEditor;
this.canSaveAs = this.dashboard.meta.canEdit && contextSrv.hasEditPermissionInFolders;
this.canSave = this.dashboard.meta.canSave;
this.canDelete = this.dashboard.meta.canSave;