diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-08-26 16:55:32 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-08-26 16:55:32 +0200 |
commit | 5da21a945d8b11b647ee8c0eca996a005386317f (patch) | |
tree | 66032324c96a91fe275b167dfac097c079377862 /server/sonar-web/src/main/js/apps/global-permissions | |
parent | db17082eea791372e587b9762b0871766591fa18 (diff) | |
download | sonarqube-5da21a945d8b11b647ee8c0eca996a005386317f.tar.gz sonarqube-5da21a945d8b11b647ee8c0eca996a005386317f.zip |
SONAR-6805 Rewrite project permissions page on a project level
Diffstat (limited to 'server/sonar-web/src/main/js/apps/global-permissions')
6 files changed, 49 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js b/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js index fbc0691ed6d..950c9888a61 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js +++ b/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js @@ -4,6 +4,22 @@ define([ './templates' ], function (Modal) { + function getSearchUrl(permission, project) { + var url = baseUrl + '/api/permissions/groups?ps=100&permission=' + permission; + if (project) { + url = url + '&projectId=' + project; + } + return url; + } + + function getExtra (permission, project) { + var extra = { permission: permission }; + if (project) { + extra.projectId = project; + } + return extra; + } + return Modal.extend({ template: Templates['global-permissions-groups'], @@ -18,12 +34,10 @@ define([ return item.name; }, queryParam: 'q', - searchUrl: baseUrl + '/api/permissions/groups?ps=100&permission=' + this.options.permission, + searchUrl: getSearchUrl(this.options.permission, this.options.project), selectUrl: baseUrl + '/api/permissions/add_group', deselectUrl: baseUrl + '/api/permissions/remove_group', - extra: { - permission: this.options.permission - }, + extra: getExtra(this.options.permission, this.options.project), selectParameter: 'groupName', selectParameterValue: 'name', parse: function (r) { diff --git a/server/sonar-web/src/main/js/apps/global-permissions/permission-groups.jsx b/server/sonar-web/src/main/js/apps/global-permissions/permission-groups.jsx index e710f3713b0..7a38d84c0a6 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/permission-groups.jsx +++ b/server/sonar-web/src/main/js/apps/global-permissions/permission-groups.jsx @@ -27,6 +27,7 @@ export default React.createClass({ e.preventDefault(); new GroupsView({ permission: this.props.permission.key, + project: this.props.project, refresh: this.props.refresh }).render(); } diff --git a/server/sonar-web/src/main/js/apps/global-permissions/permission-users.jsx b/server/sonar-web/src/main/js/apps/global-permissions/permission-users.jsx index 3d8fe5df33f..56f52feed0d 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/permission-users.jsx +++ b/server/sonar-web/src/main/js/apps/global-permissions/permission-users.jsx @@ -28,6 +28,7 @@ export default React.createClass({ e.preventDefault(); new UsersView({ permission: this.props.permission.key, + project: this.props.project, refresh: this.props.refresh }).render(); } diff --git a/server/sonar-web/src/main/js/apps/global-permissions/permission.jsx b/server/sonar-web/src/main/js/apps/global-permissions/permission.jsx index 1e87875a64b..ac259f521de 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/permission.jsx +++ b/server/sonar-web/src/main/js/apps/global-permissions/permission.jsx @@ -23,13 +23,19 @@ export default React.createClass({ requestUsers() { const url = `${window.baseUrl}/api/permissions/users`; - const data = { permission: this.props.permission.key, ps: MAX_ITEMS }; + let data = { permission: this.props.permission.key, ps: MAX_ITEMS }; + if (this.props.project) { + data.projectId = this.props.project; + } $.get(url, data).done(r => this.setState({ users: r.users, totalUsers: r.paging && r.paging.total })); }, requestGroups() { const url = `${window.baseUrl}/api/permissions/groups`; - const data = { permission: this.props.permission.key, ps: MAX_ITEMS }; + let data = { permission: this.props.permission.key, ps: MAX_ITEMS }; + if (this.props.project) { + data.projectId = this.props.project; + } $.get(url, data).done(r => this.setState({ groups: r.groups, totalGroups: r.paging && r.paging.total })); }, @@ -40,11 +46,13 @@ export default React.createClass({ <p className="spacer-top" dangerouslySetInnerHTML={{ __html: this.props.permission.description }}/> <ul className="list-inline spacer-top"> <PermissionUsers permission={this.props.permission} + project={this.props.project} max={MAX_ITEMS} items={this.state.users} total={this.state.totalUsers || this.props.permission.usersCount} refresh={this.requestUsers}/> <PermissionGroups permission={this.props.permission} + project={this.props.project} max={MAX_ITEMS} items={this.state.groups} total={this.state.totalGroups || this.props.permission.groupsCount} diff --git a/server/sonar-web/src/main/js/apps/global-permissions/permissions-list.jsx b/server/sonar-web/src/main/js/apps/global-permissions/permissions-list.jsx index 432f020e1e1..e019fbcbfec 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/permissions-list.jsx +++ b/server/sonar-web/src/main/js/apps/global-permissions/permissions-list.jsx @@ -8,7 +8,7 @@ export default React.createClass({ renderPermissions() { return this.props.permissions.map(permission => { - return <Permission key={permission.key} permission={permission}/> + return <Permission key={permission.key} permission={permission} project={this.props.project}/>; }); }, diff --git a/server/sonar-web/src/main/js/apps/global-permissions/users-view.js b/server/sonar-web/src/main/js/apps/global-permissions/users-view.js index 1c0a0937038..8146bfef5e9 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/users-view.js +++ b/server/sonar-web/src/main/js/apps/global-permissions/users-view.js @@ -4,6 +4,22 @@ define([ './templates' ], function (Modal) { + function getSearchUrl (permission, project) { + var url = baseUrl + '/api/permissions/users?ps=100&permission=' + permission; + if (project) { + url = url + '&projectId=' + project; + } + return url; + } + + function getExtra (permission, project) { + var extra = { permission: permission }; + if (project) { + extra.projectId = project; + } + return extra; + } + return Modal.extend({ template: Templates['global-permissions-users'], @@ -18,12 +34,10 @@ define([ return item.name + '<br><span class="note">' + item.login + '</span>'; }, queryParam: 'q', - searchUrl: baseUrl + '/api/permissions/users?ps=100&permission=' + this.options.permission, + searchUrl: getSearchUrl(this.options.permission, this.options.project), selectUrl: baseUrl + '/api/permissions/add_user', deselectUrl: baseUrl + '/api/permissions/remove_user', - extra: { - permission: this.options.permission - }, + extra: getExtra(this.options.permission, this.options.project), selectParameter: 'login', selectParameterValue: 'login', parse: function (r) { |