aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-05-04 17:09:29 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-05-09 11:14:36 +0200
commitd2a01aa04acb6a43bd6451e1d947d1ce9705f1cd (patch)
tree100eb271b665913d4aa7a9378a6e28b3d760a11b /server/sonar-web/src/main
parent7be7dcb2cbd44fa3594035dfb5423cf13fd7a17d (diff)
downloadsonarqube-d2a01aa04acb6a43bd6451e1d947d1ce9705f1cd.tar.gz
sonarqube-d2a01aa04acb6a43bd6451e1d947d1ce9705f1cd.zip
Fix bad api call with organization members
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/api/permissions.js20
-rw-r--r--server/sonar-web/src/main/js/apps/groups/list-item-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/groups/users-view.js16
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/components/Template.js14
4 files changed, 37 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/js/api/permissions.js b/server/sonar-web/src/main/js/api/permissions.js
index 50839634a6a..f002618224a 100644
--- a/server/sonar-web/src/main/js/api/permissions.js
+++ b/server/sonar-web/src/main/js/api/permissions.js
@@ -131,22 +131,26 @@ export function bulkApplyTemplate(data: Object) {
}
export function grantTemplatePermissionToUser(
- templateId: string,
- login: string,
- permission: string
+ data: {
+ templateId: string,
+ login: string,
+ permission: string,
+ organization?: string
+ }
) {
const url = '/api/permissions/add_user_to_template';
- const data = { templateId, login, permission };
return post(url, data);
}
export function revokeTemplatePermissionFromUser(
- templateId: string,
- login: string,
- permission: string
+ data: {
+ templateId: string,
+ login: string,
+ permission: string,
+ organization?: string
+ }
) {
const url = '/api/permissions/remove_user_from_template';
- const data = { templateId, login, permission };
return post(url, data);
}
diff --git a/server/sonar-web/src/main/js/apps/groups/list-item-view.js b/server/sonar-web/src/main/js/apps/groups/list-item-view.js
index ea6a0824950..4b4743b3c5d 100644
--- a/server/sonar-web/src/main/js/apps/groups/list-item-view.js
+++ b/server/sonar-web/src/main/js/apps/groups/list-item-view.js
@@ -78,6 +78,6 @@ export default Marionette.ItemView.extend({
},
showUsers() {
- new UsersView({ model: this.model }).render();
+ new UsersView({ model: this.model, organization: this.model.collection.organization }).render();
}
});
diff --git a/server/sonar-web/src/main/js/apps/groups/users-view.js b/server/sonar-web/src/main/js/apps/groups/users-view.js
index 1342c0685ab..d6538289abf 100644
--- a/server/sonar-web/src/main/js/apps/groups/users-view.js
+++ b/server/sonar-web/src/main/js/apps/groups/users-view.js
@@ -25,8 +25,20 @@ import Template from './templates/groups-users.hbs';
export default Modal.extend({
template: Template,
+ initialize(options) {
+ this.organization = options.organization;
+ },
+
onRender() {
Modal.prototype.onRender.apply(this, arguments);
+
+ const extra = {
+ name: this.model.get('name')
+ };
+ if (this.organization) {
+ extra.organization = this.organization.key;
+ }
+
new window.SelectList({
el: this.$('#groups-users'),
width: '100%',
@@ -39,9 +51,7 @@ export default Modal.extend({
searchUrl: window.baseUrl + '/api/user_groups/users?ps=100&id=' + this.model.id,
selectUrl: window.baseUrl + '/api/user_groups/add_user',
deselectUrl: window.baseUrl + '/api/user_groups/remove_user',
- extra: {
- id: this.model.id
- },
+ extra,
selectParameter: 'login',
selectParameterValue: 'login',
parse(r) {
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js
index 5152cb22960..8ee95b10525 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js
@@ -95,11 +95,19 @@ export default class Template extends React.PureComponent {
this.handleToggleProjectCreator(user, permission);
return;
}
- const { template } = this.props;
+ const { template, organization } = this.props;
const hasPermission = user.permissions.includes(permission);
+ const data = {
+ templateId: template.id,
+ login: user.login,
+ permission
+ };
+ if (organization) {
+ data.organization = organization.key;
+ }
const request = hasPermission
- ? api.revokeTemplatePermissionFromUser(template.id, user.login, permission)
- : api.grantTemplatePermissionToUser(template.id, user.login, permission);
+ ? api.revokeTemplatePermissionFromUser(data)
+ : api.grantTemplatePermissionToUser(data);
request.then(() => this.requestHolders()).then(this.props.refresh);
};