]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6565 display groups on users page
authorStas Vilchik <vilchiks@gmail.com>
Thu, 28 May 2015 09:44:02 +0000 (11:44 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 28 May 2015 09:44:12 +0000 (11:44 +0200)
server/sonar-web/src/main/js/apps/users/groups-view.js
server/sonar-web/src/main/js/apps/users/list-item-view.js
server/sonar-web/src/main/js/apps/users/templates/users-list-item.hbs
server/sonar-web/src/main/js/apps/users/user.js
server/sonar-web/src/main/less/components/search-navigator.less
server/sonar-web/src/test/js/users-spec.js
server/sonar-web/src/test/json/users-spec/search.json

index 8b49948d1433ebb31fdd614290256ade729d993e..b242f435773b7a3a760659c32662f655c9e6c50b 100644 (file)
@@ -13,7 +13,7 @@ define([
       new window.SelectList({
         el: this.$('#users-groups'),
         width: '100%',
-        readOnly: false,
+        readOnly: true,
         focusSearch: false,
         format: function (item) {
           return item.name + '<br><span class="note">' + item.description + '</span>';
index d36925e2d0df8ee9f064cf50010b42b80ad7f510..c6a81a2e71f20f3c8612ab3eefe0138e10408f02 100644 (file)
@@ -13,6 +13,7 @@ define([
 
     events: {
       'click .js-user-more-scm': 'onMoreScmClick',
+      'click .js-user-more-groups': 'onMoreGroupsClick',
       'click .js-user-update': 'onUpdateClick',
       'click .js-user-change-password': 'onChangePasswordClick',
       'click .js-user-deactivate': 'onDeactivateClick',
@@ -21,6 +22,7 @@ define([
 
     initialize: function () {
       this.scmLimit = 3;
+      this.groupsLimit = 3;
     },
 
     onRender: function () {
@@ -37,6 +39,11 @@ define([
       this.showMoreScm();
     },
 
+    onMoreGroupsClick: function (e) {
+      e.preventDefault();
+      this.showMoreGroups();
+    },
+
     onUpdateClick: function (e) {
       e.preventDefault();
       this.updateUser();
@@ -62,6 +69,11 @@ define([
       this.render();
     },
 
+    showMoreGroups: function () {
+      this.groupsLimit = 10000;
+      this.render();
+    },
+
     updateUser: function () {
       new UpdateView({
         model: this.model,
@@ -86,10 +98,14 @@ define([
 
     serializeData: function () {
       var scmAccounts = this.model.get('scmAccounts'),
-          scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit;
+          scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit,
+          groups = this.model.get('groups'),
+          groupsLimit = groups.length > this.groupsLimit ? this.groupsLimit - 1 : this.groupsLimit;
       return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
         firstScmAccounts: _.first(scmAccounts, scmAccountsLimit),
-        moreScmAccountsCount: scmAccounts.length - scmAccountsLimit
+        moreScmAccountsCount: scmAccounts.length - scmAccountsLimit,
+        firstGroups: _.first(groups, groupsLimit),
+        moreGroupsCount: groups.length - groupsLimit
       });
     }
   });
index c3d34d75f535d013e64ed1faaf0a76fdec540683..9efab3f96672802f8ed6b239aaac274dda142e32 100644 (file)
     <strong>Groups</strong>
   </div>
   <ul class="overflow-hidden bordered-left">
-    <li class="spacer-left little-spacer-bottom">sonar-users ?</li>
-    <li class="spacer-left little-spacer-bottom">sonar-administrators ?</li>
+    {{#each firstGroups}}
+      <li class="spacer-left little-spacer-bottom">{{this}}</li>
+    {{/each}}
     <li class="spacer-left little-spacer-bottom">
-      <a class="js-user-more-groups" href="#">? more</a>
-      <a class="js-user-groups icon-bullet-list spacer-left" title="Update Groups" data-toggle="tooltip" href="#"></a>
+      {{#gt moreGroupsCount 0}}
+        <a class="js-user-more-groups spacer-right" href="#">{{moreGroupsCount}} more</a>
+      {{/gt}}
+      <a class="js-user-groups icon-bullet-list" title="Update Groups" data-toggle="tooltip" href="#"></a>
     </li>
   </ul>
 </div>
index 119a27fbfd576f506da2afa81e82297a58415629..746ffe8bdd728534c084099ef4446f024c012e87 100644 (file)
@@ -9,7 +9,7 @@ define(function () {
 
     defaults: function () {
       return {
-        groupsCount: 0,
+        groups: [],
         scmAccounts: []
       };
     },
index 517b27fff88002706f6797fe9d36cfdc672c1893..b427e283ffeaf8e2a7491561dbccc738c2aa0e1d 100644 (file)
 
 .search-navigator-workspace {
   padding-left: @sideWidth;
-  overflow-x: hidden;
 }
 
 .search-navigator-workspace-header {
index 1b963016acd5722488d612ee9537d9acfbec28b7..2dc44a647e87b0057daa6a58552b3479264cdb28 100644 (file)
@@ -6,7 +6,7 @@ lib.initMessages();
 lib.changeWorkingDirectory('users-spec');
 lib.configureCasper();
 
-casper.test.begin(testName('List'), 11, function (test) {
+casper.test.begin(testName('List'), 13, function (test) {
   casper
       .start(lib.buildUrl('users'), function () {
         lib.setDefaultViewport();
@@ -43,6 +43,12 @@ casper.test.begin(testName('List'), 11, function (test) {
         test.assertSelectorContains('[data-login="ryan"]', 'another@example.com');
       })
 
+      .then(function () {
+        test.assertSelectorDoesntContain('[data-login="ryan"]', 'four');
+        casper.click('[data-login="ryan"] .js-user-more-groups');
+        test.assertSelectorContains('[data-login="ryan"]', 'four');
+      })
+
       .then(function () {
         lib.sendCoverage();
       })
index abe8f1dfb3460459c04e5104127b3ab4d3d12b06..34df33c9b0d3f8415d5c98be59339ad9331cc9ca 100644 (file)
@@ -19,7 +19,8 @@
       "login": "ryan",
       "name": "John",
       "email": "john@example.com",
-      "scmAccounts": ["ryan@example.com", "ryan", "john", "another@example.com"]
+      "scmAccounts": ["ryan@example.com", "ryan", "john", "another@example.com"],
+      "groups": ["one", "two", "three", "four"]
     }
   ]
 }