From: Stas Vilchik Date: Mon, 3 Mar 2014 14:51:01 +0000 (+0100) Subject: SONAR-4366 Quality Gates: ready for the permissions stuff X-Git-Tag: 4.3~599 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a9222115d520f8da131664c7e7ec867c8246ae0d;p=sonarqube.git SONAR-4366 Quality Gates: ready for the permissions stuff --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index e98690d04b1..99325c57268 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/index.html.erb index b7533d0d9ee..3d4f395e217 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/quality_gates/index.html.erb @@ -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') -%>' } } }; diff --git a/sonar-server/src/main/webapp/javascripts/common/select-list.js b/sonar-server/src/main/webapp/javascripts/common/select-list.js index b323e6f81c8..1a352f8c3f1 100644 --- a/sonar-server/src/main/webapp/javascripts/common/select-list.js +++ b/sonar-server/src/main/webapp/javascripts/common/select-list.js @@ -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: { diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee index a59bafc1991..18971082a92 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/app.coffee @@ -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() diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/app.js b/sonar-server/src/main/webapp/javascripts/quality-gate/app.js index 6235f36420b..972313802b8 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/app.js +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/app.js @@ -11,9 +11,6 @@ 'select-list': 'common/select-list' }, shim: { - 'jquery': { - exports: '$' - }, 'backbone.marionette': { deps: ['backbone'], exports: 'Marionette' @@ -107,7 +104,7 @@ }); 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(); }); diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee index 411be461dda..2bc4af08faa 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.coffee @@ -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 diff --git a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js index cc2aec4861e..d1cd26edf93 100644 --- a/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js +++ b/sonar-server/src/main/webapp/javascripts/quality-gate/views/quality-gate-detail-projects-view.js @@ -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, diff --git a/sonar-server/src/main/webapp/stylesheets/select-list.css b/sonar-server/src/main/webapp/stylesheets/select-list.css index 19b2b8c8263..7a39861bc77 100644 --- a/sonar-server/src/main/webapp/stylesheets/select-list.css +++ b/sonar-server/src/main/webapp/stylesheets/select-list.css @@ -20,6 +20,14 @@ 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; }