Explorar o código

When role is viewer and edit URL is loaded view mode will be loaded instead, Closes #2089

Torkel Ödegaard %!s(int64=10) %!d(string=hai) anos
pai
achega
86f5152092

+ 4 - 3
public/app/features/dashboard/viewStateSrv.js

@@ -130,10 +130,11 @@ function (angular, _, $) {
       var docHeight = $(window).height();
       var editHeight = Math.floor(docHeight * 0.3);
       var fullscreenHeight = Math.floor(docHeight * 0.7);
-      this.oldTimeRange = panelScope.range;
 
-      panelScope.height = this.state.edit ? editHeight : fullscreenHeight;
-      panelScope.editMode = this.state.edit;
+      panelScope.editMode = this.state.edit && this.$scope.dashboardMeta.canEdit;
+      panelScope.height = panelScope.editMode ? editHeight : fullscreenHeight;
+
+      this.oldTimeRange = panelScope.range;
       this.fullscreenPanel = panelScope;
 
       $(window).scrollTop(0);

+ 3 - 3
public/app/features/panel/panelMenu.js

@@ -8,7 +8,7 @@ function (angular, $, _) {
 
   angular
     .module('grafana.directives')
-    .directive('panelMenu', function($compile, linkSrv, contextSrv) {
+    .directive('panelMenu', function($compile, linkSrv) {
       var linkTemplate =
           '<span class="panel-title drag-handle pointer">' +
             '<span class="panel-title-text drag-handle">{{panel.title | interpolateTemplateVars:this}}</span>' +
@@ -19,7 +19,7 @@ function (angular, $, _) {
       function createMenuTemplate($scope) {
         var template = '<div class="panel-menu small">';
 
-        if ($scope.dashboardMeta.canEdit && contextSrv.isEditor) {
+        if ($scope.dashboardMeta.canEdit) {
           template += '<div class="panel-menu-inner">';
           template += '<div class="panel-menu-row">';
           template += '<a class="panel-menu-icon pull-left" ng-click="updateColumnSpan(-1)"><i class="fa fa-minus"></i></a>';
@@ -34,7 +34,7 @@ function (angular, $, _) {
 
         _.each($scope.panelMeta.menu, function(item) {
           // skip edit actions if not editor
-          if (item.role === 'Editor' && (!contextSrv.isEditor || !$scope.dashboardMeta.canEdit)) {
+          if (item.role === 'Editor' && !$scope.dashboardMeta.canEdit) {
             return;
           }
 

+ 0 - 8
public/app/features/panel/panelSrv.js

@@ -71,14 +71,6 @@ function (angular, _, config) {
       };
 
       $scope.toggleFullscreen = function(edit) {
-        if (edit && $scope.dashboardMeta.canEdit === false) {
-          $scope.appEvent('alert-warning', [
-            'Dashboard not editable',
-            'Use Save As.. feature to create an editable copy of this dashboard.'
-          ]);
-          return;
-        }
-
         $scope.dashboardViewState.update({ fullscreen: true, edit: edit, panelId: $scope.panel.id });
       };