]> source.dussan.org Git - sonarqube.git/commitdiff
Fix bad api call with organization members
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 4 May 2017 15:09:29 +0000 (17:09 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 9 May 2017 09:14:36 +0000 (11:14 +0200)
server/sonar-web/src/main/js/api/permissions.js
server/sonar-web/src/main/js/apps/groups/list-item-view.js
server/sonar-web/src/main/js/apps/groups/users-view.js
server/sonar-web/src/main/js/apps/permission-templates/components/Template.js

index 50839634a6a1b83424d24d4d0566204f1a2060d1..f002618224a474198a5710525aa23abd9f0bf73d 100644 (file)
@@ -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);
 }
 
index ea6a082495066cc20629d83bdb91876a52cf7502..4b4743b3c5dc4b1e566c2f3f45223eac92407ed4 100644 (file)
@@ -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();
   }
 });
index 1342c0685ab931bea6ace88bf78dbe303020db78..d6538289abfe5f8e4ee520f76539f6eb1a64074f 100644 (file)
@@ -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) {
index 5152cb22960651c7f3e16fd27c5eb92245cd05fe..8ee95b10525836679ab8c52d1f9b49903cf8568a 100644 (file)
@@ -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);
   };