From: Stas Vilchik Date: Thu, 28 May 2015 09:44:02 +0000 (+0200) Subject: SONAR-6565 display groups on users page X-Git-Tag: 5.2-RC1~1792 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2f5e5a2d0a7570318cf708273ce902d36d43de40;p=sonarqube.git SONAR-6565 display groups on users page --- diff --git a/server/sonar-web/src/main/js/apps/users/groups-view.js b/server/sonar-web/src/main/js/apps/users/groups-view.js index 8b49948d143..b242f435773 100644 --- a/server/sonar-web/src/main/js/apps/users/groups-view.js +++ b/server/sonar-web/src/main/js/apps/users/groups-view.js @@ -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 + '
' + item.description + ''; diff --git a/server/sonar-web/src/main/js/apps/users/list-item-view.js b/server/sonar-web/src/main/js/apps/users/list-item-view.js index d36925e2d0d..c6a81a2e71f 100644 --- a/server/sonar-web/src/main/js/apps/users/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-item-view.js @@ -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 }); } }); diff --git a/server/sonar-web/src/main/js/apps/users/templates/users-list-item.hbs b/server/sonar-web/src/main/js/apps/users/templates/users-list-item.hbs index c3d34d75f53..9efab3f9667 100644 --- a/server/sonar-web/src/main/js/apps/users/templates/users-list-item.hbs +++ b/server/sonar-web/src/main/js/apps/users/templates/users-list-item.hbs @@ -42,11 +42,14 @@ Groups diff --git a/server/sonar-web/src/main/js/apps/users/user.js b/server/sonar-web/src/main/js/apps/users/user.js index 119a27fbfd5..746ffe8bdd7 100644 --- a/server/sonar-web/src/main/js/apps/users/user.js +++ b/server/sonar-web/src/main/js/apps/users/user.js @@ -9,7 +9,7 @@ define(function () { defaults: function () { return { - groupsCount: 0, + groups: [], scmAccounts: [] }; }, diff --git a/server/sonar-web/src/main/less/components/search-navigator.less b/server/sonar-web/src/main/less/components/search-navigator.less index 517b27fff88..b427e283ffe 100644 --- a/server/sonar-web/src/main/less/components/search-navigator.less +++ b/server/sonar-web/src/main/less/components/search-navigator.less @@ -445,7 +445,6 @@ .search-navigator-workspace { padding-left: @sideWidth; - overflow-x: hidden; } .search-navigator-workspace-header { diff --git a/server/sonar-web/src/test/js/users-spec.js b/server/sonar-web/src/test/js/users-spec.js index 1b963016acd..2dc44a647e8 100644 --- a/server/sonar-web/src/test/js/users-spec.js +++ b/server/sonar-web/src/test/js/users-spec.js @@ -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(); }) diff --git a/server/sonar-web/src/test/json/users-spec/search.json b/server/sonar-web/src/test/json/users-spec/search.json index abe8f1dfb34..34df33c9b0d 100644 --- a/server/sonar-web/src/test/json/users-spec/search.json +++ b/server/sonar-web/src/test/json/users-spec/search.json @@ -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"] } ] }