Explorar el Código

Unsaved changes: Do not show for users with role , Fixes #1703

Torkel Ödegaard hace 10 años
padre
commit
3b737999d6
Se han modificado 3 ficheros con 9 adiciones y 8 borrados
  1. 1 0
      CHANGELOG.md
  2. 8 4
      public/app/features/dashboard/unsavedChangesSrv.js
  3. 0 4
      public/views/index.html

+ 1 - 0
CHANGELOG.md

@@ -1,6 +1,7 @@
 # 2.0.0-RC1  (unreleased)
 
 **FIxes**
+- [Issue #1703](https://github.com/grafana/grafana/issues/1703). Unsaved changes: Do not show for users with role `Viewer`
 - [Issue #1675](https://github.com/grafana/grafana/issues/1675). Data source proxy: Fixed issue with Gzip enabled and data source proxy
 - [Issue #1681](https://github.com/grafana/grafana/issues/1681). MySQL session: fixed problem using mysql as session store
 - [Issue #1671](https://github.com/grafana/grafana/issues/1671). Data sources: Fixed issue with changing default data source (should not require full page load to take effect, now fixed)

+ 8 - 4
public/app/features/dashboard/unsavedChangesSrv.js

@@ -12,7 +12,7 @@ function(angular, _, config) {
 
   var module = angular.module('grafana.services');
 
-  module.service('unsavedChangesSrv', function($rootScope, $modal, $q, $location, $timeout) {
+  module.service('unsavedChangesSrv', function($rootScope, $modal, $q, $location, $timeout, contextSrv) {
 
     var self = this;
     var modalScope = $rootScope.$new();
@@ -36,7 +36,11 @@ function(angular, _, config) {
       self.originalPath = $location.path();
     });
 
+    this.ignoreChangeCheck = function() {
+   };
+
     window.onbeforeunload = function() {
+      if (contextSrv.hasRole('Viewer')) { return true; }
       if (self.has_unsaved_changes()) {
         return "There are unsaved changes to this dashboard";
       }
@@ -44,9 +48,9 @@ function(angular, _, config) {
 
     this.init = function() {
       $rootScope.$on("$locationChangeStart", function(event, next) {
-        if (self.originalPath === $location.path()) {
-          return;
-        }
+        // check if we should look for changes
+        if (self.originalPath === $location.path()) { return true; }
+        if (contextSrv.hasRole('Viewer')) { return true; }
 
         if (self.has_unsaved_changes()) {
           event.preventDefault();

+ 0 - 4
public/views/index.html

@@ -16,10 +16,6 @@
     <link rel="icon" type="image/png" href="[[.AppSubUrl]]/img/fav32.png">
 		<base href="[[.AppSubUrl]]/" />
 
-		<script type="text/javascript">
-			window.grafanaBackend = true;
-		</script>
-
 		<!-- build:js [[.AppSubUrl]]/app/app.js -->
     <script src="[[.AppSubUrl]]/public/vendor/require/require.js"></script>
     <script src="[[.AppSubUrl]]/public/app/components/require.config.js"></script>