]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5851 show number of associated projects
authorStas Vilchik <vilchiks@gmail.com>
Mon, 20 Apr 2015 10:48:42 +0000 (12:48 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 20 Apr 2015 10:50:08 +0000 (12:50 +0200)
server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-profile.hbs
server/sonar-web/src/main/js/quality-profiles/profile-details-view.js
server/sonar-web/src/main/js/quality-profiles/profile-view.js
server/sonar-web/src/main/js/quality-profiles/profile.js
server/sonar-web/src/main/js/quality-profiles/profiles.js
server/sonar-web/src/test/js/quality-profiles.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 3a9d461703e851b18bc8bc78976f003469c80ae2..030140c27b1ba86e7dbc976611c0852cc385249b 100644 (file)
@@ -7,11 +7,13 @@
       </td>
     {{/if}}
     <td class="text-top">{{name}}</td>
-    {{#if isDefault}}
-      <td class="text-top thin spacer-left">
-        <span class="note pull-right">{{t 'default'}}</span>
-      </td>
-    {{/if}}
+    <td class="text-top thin nowrap spacer-left">
+      {{#if isDefault}}
+        <span class="badge pull-right">{{t 'default'}}</span>
+      {{else}}
+        <span class="note pull-right">{{tp 'quality_profiles.x_projects' projectCountFormatted}}</span>
+      {{/if}}
+    </td>
   </tr>
 </table>
 
index 96146f2915911fa4eafc160c7bdac300d9320815..51aa787cb3fea6eaf3a3c2f9af23f4ffc1ffd6d7 100644 (file)
@@ -61,7 +61,7 @@ define([
 
     initProjectsSelect: function () {
       var key = this.model.get('key');
-      new window.SelectList({
+      this.projectsSelectList = new window.SelectList({
         el: this.$('#quality-profile-projects-list'),
         width: '100%',
         readOnly: !this.options.canWrite,
@@ -88,6 +88,7 @@ define([
           deselect: t('quality_gates.projects.deselect_hint')
         }
       });
+      this.listenTo(this.projectsSelectList.collection, 'change:selected', this.onProjectsChange);
     },
 
     onProfileClick: function (e) {
@@ -104,6 +105,10 @@ define([
       this.changeParent();
     },
 
+    onProjectsChange: function () {
+      this.model.collection.updateForLanguage(this.model.get('language'));
+    },
+
     changeParent: function () {
       new ChangeProfileParentView({
         model: this.model
index d2d42aee324976dc6fc9cf1ce825364b226164e7..b8c69aba0fbe925cf1250760c8c04377080d1b28 100644 (file)
@@ -48,6 +48,12 @@ define([
     onClick: function (e) {
       e.preventDefault();
       this.model.trigger('select', this.model);
+    },
+
+    serializeData: function () {
+      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+        projectCountFormatted: window.formatMeasure(this.model.get('projectCount'), 'INT')
+      });
     }
   });
 
index 3f061e4a9a9d22af0cc8c59ae411c8b9c8ba57be..4f4bd39133adcf8e75bd0bce81146847898bd0ef 100644 (file)
@@ -25,7 +25,8 @@ define(function () {
     idAttribute: 'key',
 
     defaults: {
-      activeRuleCount: 0
+      activeRuleCount: 0,
+      projectCount: 0
     },
 
     fetch: function () {
index c7d5c45f39770d50dd9ac1ec14ec0b6e9898ea94..38c0477ca29c62dbbd249c605b994de101b888e0 100644 (file)
@@ -28,6 +28,17 @@ define([
 
     parse: function (r) {
       return r.profiles;
+    },
+
+    updateForLanguage: function (language) {
+      this.fetch({
+        data: {
+          language: language
+        },
+        merge: true,
+        reset: false,
+        remove: false
+      });
     }
   });
 
index 63e7a65ea5535e1da0946dde2b8433a4d0645d2b..04ca1ff46f62cab5c773f00a9d7e84f5c0612495 100644 (file)
@@ -59,7 +59,7 @@ casper.test.begin(testName('Should Show List'), 9, function (test) {
         test.assertSelectorContains('.js-list-language', 'PHP');
         test.assertSelectorContains('.js-list-language', 'Python');
 
-        test.assertElementCount('.js-list .note', 4);
+        test.assertElementCount('.js-list .badge', 4);
       })
 
       .then(function () {
@@ -557,8 +557,8 @@ casper.test.begin(testName('Make Profile Default'), 4, function (test) {
       })
 
       .then(function () {
-        test.assertDoesntExist('.js-list .list-group-item[data-key="php-psr-2-46772"] .note');
-        test.assertExists('.js-list .list-group-item[data-key="php-sonar-way-10778"] .note');
+        test.assertDoesntExist('.js-list .list-group-item[data-key="php-psr-2-46772"] .badge');
+        test.assertExists('.js-list .list-group-item[data-key="php-sonar-way-10778"] .badge');
         casper.click('.js-list .list-group-item[data-key="php-psr-2-46772"]');
         casper.waitForSelector('#quality-profile-set-as-default');
       })
@@ -568,12 +568,12 @@ casper.test.begin(testName('Make Profile Default'), 4, function (test) {
         lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-another-default.json');
 
         casper.click('#quality-profile-set-as-default');
-        casper.waitWhileSelector('.js-list .list-group-item[data-key="php-sonar-way-10778"] .note');
+        casper.waitWhileSelector('.js-list .list-group-item[data-key="php-sonar-way-10778"] .badge');
       })
 
       .then(function () {
         test.assertDoesntExist('#quality-profile-set-as-default');
-        test.assertExists('.js-list .list-group-item[data-key="php-psr-2-46772"] .note');
+        test.assertExists('.js-list .list-group-item[data-key="php-psr-2-46772"] .badge');
       })
 
       .then(function () {
index 3b08fd16d2c4c03f6b48c8354c230e5d3d8a2dfd..2d0fa3b2f144efe6d7768eef78d0217e8fc9908e 100644 (file)
@@ -1794,6 +1794,7 @@ quality_profiles.x_overridden_rules={0} overridden rules
 quality_profiles.change_parent=Change Parent
 quality_profiles.all_profiles=All Profiles
 quality_profiles.x_profiles={0} Profiles
+quality_profiles.x_projects={0} projects