}
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);
}
},
showUsers() {
- new UsersView({ model: this.model }).render();
+ new UsersView({ model: this.model, organization: this.model.collection.organization }).render();
}
});
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%',
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) {
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);
};