]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4366 Quality Gates: ready for the permissions stuff
authorStas Vilchik <vilchiks@gmail.com>
Mon, 3 Mar 2014 14:51:01 +0000 (15:51 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 3 Mar 2014 14:51:08 +0000 (15:51 +0100)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/index.html.erb
sonar-server/src/main/webapp/javascripts/common/select-list.js
sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee
sonar-server/src/main/webapp/javascripts/quality-gate/app.js
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee
sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js
sonar-server/src/main/webapp/stylesheets/select-list.css

index e98690d04b19be4178a250828f93e3cdaa84b481..99325c57268b1b0a1f9a124c3d1cbbe5942f8ff2 100644 (file)
@@ -1651,6 +1651,7 @@ quality_gates.projects_for_default=You must not select specific projects for the
 quality_gates.projects.with=With
 quality_gates.projects.without=Without
 quality_gates.projects.all=All
+quality_gates.projects.noResults=There are no associated projects.
 quality_gates.projects.select_hint=Click to associate this project with the quality gate
 quality_gates.projects.deselect_hint=Click to remove association between this project and the quality gate
 
index b7533d0d9eeb3b3e99fef730cfb836f7e81dbec2..3d4f395e21795f016f82f4450f5479e05e5f6d7b 100644 (file)
@@ -42,7 +42,8 @@
         without: '<%= message('quality_gates.projects.without') -%>',
         all: '<%= message('quality_gates.projects.all') -%>',
         select_hint: '<%= message('quality_gates.projects.select_hint') -%>',
-        deselect_hint: '<%= message('quality_gates.projects.deselect_hint') -%>'
+        deselect_hint: '<%= message('quality_gates.projects.deselect_hint') -%>',
+        noResults: '<%= message('quality_gates.projects.noResults') -%>'
       }
     }
   };
index b323e6f81c88214fb17aaabc826851de860f884f..1a352f8c3f17f40016fdbf5c89ebe23c5fc589bd 100644 (file)
@@ -104,7 +104,12 @@ requirejs(['backbone'], function (Backbone) {
         }
       },
 
-      toggle: function () {
+      toggle: function (e) {
+        if (this.settings.readOnly) {
+          $(e.target).prop('checked', !$(e.target).prop('checked'));
+          return;
+        }
+
         var selected = this.model.get('selected'),
             that = this,
             url = selected ? this.settings.deselectUrl : this.settings.selectUrl,
@@ -178,12 +183,17 @@ requirejs(['backbone'], function (Backbone) {
         this.$el.html(this.template(this.settings.labels))
             .width(this.settings.width);
 
-        this.$listContainer = this.$('.select-list-list-container')
-            .height(this.settings.height)
-            .css('overflow', 'auto')
-            .on('scroll', function () {
-              that.scroll();
-            });
+        this.$listContainer = this.$('.select-list-list-container');
+        if (!this.settings.readOnly) {
+          this.$listContainer
+              .height(this.settings.height)
+              .css('overflow', 'auto')
+              .on('scroll', function () {
+                that.scroll();
+              });
+        } else {
+          this.$listContainer.addClass('select-list-list-container-readonly');
+        }
 
         this.$list = this.$('.select-list-list');
 
@@ -201,6 +211,10 @@ requirejs(['backbone'], function (Backbone) {
               .addClass('error').text(that.settings.errorMessage)
               .insertBefore(that.$el);
         };
+
+        if (this.settings.readOnly) {
+          this.$('.select-list-control').remove();
+        }
       },
 
       renderList: function () {
@@ -208,7 +222,11 @@ requirejs(['backbone'], function (Backbone) {
           view.remove();
         });
         this.listItemViews = [];
-        this.collection.each(this.renderListItem, this);
+        if (this.collection.length > 0) {
+          this.collection.each(this.renderListItem, this);
+        } else {
+          this.renderEmpty();
+        }
         this.$listContainer.scrollTop(0);
       },
 
@@ -222,6 +240,10 @@ requirejs(['backbone'], function (Backbone) {
         itemView.render();
       },
 
+      renderEmpty: function () {
+        this.$listContainer.html(this.settings.labels.noResults);
+      },
+
       confirmFilter: function (model) {
         if (this.currentFilter !== 'all') {
           this.collection.remove(model);
@@ -379,6 +401,8 @@ requirejs(['backbone'], function (Backbone) {
       width: '50%',
       height: 400,
 
+      readOnly: false,
+
       format: function (item) {
         return item.value;
       },
@@ -386,7 +410,8 @@ requirejs(['backbone'], function (Backbone) {
       labels: {
         selected: 'Selected',
         deselected: 'Deselected',
-        all: 'All'
+        all: 'All',
+        noResults: ''
       },
 
       tooltips: {
index a59bafc199102625f36daf133c1ec2a747c7d20f..18971082a92afbfe881d37e2f6f9f81dd96eba67 100644 (file)
@@ -10,8 +10,6 @@ requirejs.config
     'select-list': 'common/select-list'
 
   shim:
-    'jquery':
-      exports: '$'
     'backbone.marionette':
       deps: ['backbone']
       exports: 'Marionette'
@@ -115,7 +113,7 @@ requirejs [
   jQuery.when(App.metrics.fetch(), qualityGatesXHR)
     .done ->
       # Set permissions
-      App.canEdit = true #qualityGatesXHR.responseJSON.edit
+      App.canEdit = false #qualityGatesXHR.responseJSON.edit
 
       # Remove the initial spinner
       jQuery('.quality-gate-page-loader').remove()
index 6235f36420bbd07a136d3dcec3f77eca35f8fa9c..972313802b8dabaefab96b8776225402a3f3840b 100644 (file)
@@ -11,9 +11,6 @@
       'select-list': 'common/select-list'
     },
     shim: {
-      'jquery': {
-        exports: '$'
-      },
       'backbone.marionette': {
         deps: ['backbone'],
         exports: 'Marionette'
     });
     qualityGatesXHR = App.qualityGates.fetch();
     return jQuery.when(App.metrics.fetch(), qualityGatesXHR).done(function() {
-      App.canEdit = true;
+      App.canEdit = false;
       jQuery('.quality-gate-page-loader').remove();
       return App.start();
     });
index 411be461dda2dad50ffceabe3a1ba25b801c1c44..2bc4af08faa0243b63eff552a90ae451110ae545 100644 (file)
@@ -16,6 +16,7 @@ define [
         new SelectList
           el: @$('#select-list-projects')
           width: '100%'
+          readOnly: true
           format: (item) -> item.name
           searchUrl: "#{baseUrl}/api/qualitygates/search?gateId=#{@options.gateId}"
           selectUrl: "#{baseUrl}/api/qualitygates/select"
@@ -28,10 +29,13 @@ define [
             selected: window.SS.phrases.projects.with
             deselected: window.SS.phrases.projects.without
             all: window.SS.phrases.projects.all
+            noResults: window.SS.phrases.projects.noResults
           tooltips:
             select: window.SS.phrases.projects.select_hint
             deselect: window.SS.phrases.projects.deselect_hint
 
 
+
+
     serializeData: ->
       _.extend super, canEdit: @options.app.canEdit
index cc2aec4861ec48a30e6960832ad885e118c11240..d1cd26edf9360bb448c7a201301a8aa602939cbb 100644 (file)
@@ -20,6 +20,7 @@
           return new SelectList({
             el: this.$('#select-list-projects'),
             width: '100%',
+            readOnly: true,
             format: function(item) {
               return item.name;
             },
@@ -34,7 +35,8 @@
             labels: {
               selected: window.SS.phrases.projects["with"],
               deselected: window.SS.phrases.projects.without,
-              all: window.SS.phrases.projects.all
+              all: window.SS.phrases.projects.all,
+              noResults: window.SS.phrases.projects.noResults
             },
             tooltips: {
               select: window.SS.phrases.projects.select_hint,
index 19b2b8c8263404cf4027a0a8c8db722e8f445a19..7a39861bc77be1b2dcd7ce85d9535bc68cd1c3d1 100644 (file)
   display: none;
 }
 
+.select-list-list-container-readonly {
+  border: none;
+}
+
+.select-list-list-container-readonly .select-list-list > li {
+  border: none;
+}
+
 .select-list-list {
   overflow-x: hidden;
 }