const PAGE_SIZE = 100;
-export function getPermissionUsers (data) {
- const url = '/api/permissions/users';
- return getJSON(url, data);
-}
-
-export function grantPermissionToUser (projectKey, login, permission) {
+export function grantPermissionToUser (projectKey, login, permission, organization) {
const url = '/api/permissions/add_user';
const data = { login, permission };
if (projectKey) {
data.projectKey = projectKey;
}
+ if (organization) {
+ data.organization = organization;
+ }
return post(url, data);
}
-export function revokePermissionFromUser (projectKey, login, permission) {
+export function revokePermissionFromUser (projectKey, login, permission, organization) {
const url = '/api/permissions/remove_user';
const data = { login, permission };
if (projectKey) {
data.projectKey = projectKey;
}
+ if (organization) {
+ data.organization = organization;
+ }
return post(url, data);
}
-export function getPermissionGroups (data) {
- const url = '/api/permissions/groups';
- return getJSON(url, data);
-}
-
-export function grantPermissionToGroup (projectKey, groupName, permission) {
+export function grantPermissionToGroup (projectKey, groupName, permission, organization) {
const url = '/api/permissions/add_group';
const data = { groupName, permission };
if (projectKey) {
data.projectKey = projectKey;
}
+ if (organization) {
+ data.organization = organization;
+ }
return post(url, data);
}
-export function revokePermissionFromGroup (projectKey, groupName, permission) {
+export function revokePermissionFromGroup (projectKey, groupName, permission, organization) {
const url = '/api/permissions/remove_group';
const data = { groupName, permission };
if (projectKey) {
data.projectKey = projectKey;
}
+ if (organization) {
+ data.organization = organization;
+ }
return post(url, data);
}
return post(url, data);
}
-export function getPermissionsUsersForComponent (projectKey, query = '', permission = null) {
+export function getPermissionsUsersForComponent (projectKey, query = '', permission = null, organization = null) {
const url = '/api/permissions/users';
const data = { projectKey, ps: PAGE_SIZE };
if (query) {
if (permission) {
data.permission = permission;
}
+ if (organization) {
+ data.organization = organization;
+ }
return getJSON(url, data).then(r => r.users);
}
-export function getPermissionsGroupsForComponent (projectKey, query = '', permission = null) {
+export function getPermissionsGroupsForComponent (projectKey, query = '', permission = null, organization = null) {
const url = '/api/permissions/groups';
const data = { projectKey, ps: PAGE_SIZE };
if (query) {
if (permission) {
data.permission = permission;
}
+ if (organization) {
+ data.organization = organization;
+ }
return getJSON(url, data).then(r => r.groups);
}
-export function getGlobalPermissionsUsers (query = '', permission = null) {
+export function getGlobalPermissionsUsers (query = '', permission = null, organization = null) {
const url = '/api/permissions/users';
const data = { ps: PAGE_SIZE };
if (query) {
if (permission) {
data.permission = permission;
}
+ if (organization) {
+ data.organization = organization;
+ }
return getJSON(url, data).then(r => r.users);
}
-export function getGlobalPermissionsGroups (query = '', permission = null) {
+export function getGlobalPermissionsGroups (query = '', permission = null, organization = null) {
const url = '/api/permissions/groups';
const data = { ps: PAGE_SIZE };
if (query) {
if (permission) {
data.permission = permission;
}
+ if (organization) {
+ data.organization = organization;
+ }
return getJSON(url, data).then(r => r.groups);
}
selectedPermission: getPermissionsAppSelectedPermission(state)
});
-const mapDispatchToProps = dispatch => ({
- loadHolders: projectKey => dispatch(loadHolders(projectKey)),
- onSearch: (projectKey, query) => dispatch(updateQuery(projectKey, query)),
- onFilter: (projectKey, filter) => dispatch(updateFilter(projectKey, filter)),
+const mapDispatchToProps = (dispatch, ownProps) => ({
+ loadHolders: projectKey => dispatch(loadHolders(projectKey, ownProps.project.organization)),
+ onSearch: (projectKey, query) => dispatch(updateQuery(projectKey, query, ownProps.project.organization)),
+ onFilter: (projectKey, filter) => dispatch(updateFilter(projectKey, filter, ownProps.project.organization)),
onSelectPermission: (projectKey, permission) =>
- dispatch(selectPermission(projectKey, permission)),
+ dispatch(selectPermission(projectKey, permission, ownProps.project.organization)),
grantPermissionToUser: (projectKey, login, permission) =>
- dispatch(grantToUser(projectKey, login, permission)),
+ dispatch(grantToUser(projectKey, login, permission, ownProps.project.organization)),
revokePermissionFromUser: (projectKey, login, permission) =>
- dispatch(revokeFromUser(projectKey, login, permission)),
+ dispatch(revokeFromUser(projectKey, login, permission, ownProps.project.organization)),
grantPermissionToGroup: (projectKey, groupName, permission) =>
- dispatch(grantToGroup(projectKey, groupName, permission)),
+ dispatch(grantToGroup(projectKey, groupName, permission, ownProps.project.organization)),
revokePermissionFromGroup: (projectKey, groupName, permission) =>
- dispatch(revokeFromGroup(projectKey, groupName, permission))
+ dispatch(revokeFromGroup(projectKey, groupName, permission, ownProps.project.organization))
});
export default connect(
loading: isPermissionsAppLoading(state)
});
-const mapDispatchToProps = dispatch => ({
- loadHolders: projectKey => dispatch(loadHolders(projectKey))
+const mapDispatchToProps = (dispatch, ownProps) => ({
+ loadHolders: projectKey => dispatch(loadHolders(projectKey, ownProps.project.organization))
});
export default connect(
getPermissionsAppSelectedPermission
} from '../../../../store/rootReducer';
-export const loadHolders = projectKey => (dispatch, getState) => {
+export const loadHolders = (projectKey, organization) => (dispatch, getState) => {
const query = getPermissionsAppQuery(getState());
const filter = getPermissionsAppFilter(getState());
const selectedPermission = getPermissionsAppSelectedPermission(getState());
const requests = [];
if (filter !== 'groups') {
- requests.push(api.getPermissionsUsersForComponent(projectKey, query,
- selectedPermission));
+ requests.push(api.getPermissionsUsersForComponent(projectKey, query, selectedPermission, organization));
} else {
requests.push(Promise.resolve([]));
}
if (filter !== 'users') {
- requests.push(api.getPermissionsGroupsForComponent(projectKey, query,
- selectedPermission));
+ requests.push(api.getPermissionsGroupsForComponent(projectKey, query, selectedPermission, organization));
} else {
requests.push(Promise.resolve([]));
}
});
};
-export const updateQuery = (projectKey, query = '') => dispatch => {
+export const updateQuery = (projectKey, query = '', organization = null) => dispatch => {
dispatch({ type: UPDATE_QUERY, query });
if (query.length === 0 || query.length > 2) {
- dispatch(loadHolders(projectKey));
+ dispatch(loadHolders(projectKey, organization));
}
};
-export const updateFilter = (projectKey, filter) => dispatch => {
+export const updateFilter = (projectKey, filter, organization) => dispatch => {
dispatch({ type: UPDATE_FILTER, filter });
- dispatch(loadHolders(projectKey));
+ dispatch(loadHolders(projectKey, organization));
};
-export const selectPermission = (projectKey, permission) => (dispatch, getState) => {
+export const selectPermission = (projectKey, permission, organization) => (dispatch, getState) => {
const selectedPermission = getPermissionsAppSelectedPermission(getState());
if (selectedPermission !== permission) {
dispatch({ type: SELECT_PERMISSION, permission });
} else {
dispatch({ type: SELECT_PERMISSION, permission: null });
}
- dispatch(loadHolders(projectKey));
+ dispatch(loadHolders(projectKey, organization));
};
-export const grantToUser = (projectKey, login, permission) => dispatch => {
- api.grantPermissionToUser(projectKey, login, permission).then(() => {
+export const grantToUser = (projectKey, login, permission, organization) => dispatch => {
+ api.grantPermissionToUser(projectKey, login, permission, organization).then(() => {
dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission });
}).catch(e => {
return parseError(e).then(message => dispatch(raiseError(message)));
});
};
-export const revokeFromUser = (projectKey, login, permission) => dispatch => {
- api.revokePermissionFromUser(projectKey, login, permission).then(() => {
+export const revokeFromUser = (projectKey, login, permission, organization) => dispatch => {
+ api.revokePermissionFromUser(projectKey, login, permission, organization).then(() => {
dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission });
}).catch(e => {
return parseError(e).then(message => dispatch(raiseError(message)));
});
};
-export const grantToGroup = (projectKey, groupName, permission) => dispatch => {
- api.grantPermissionToGroup(projectKey, groupName, permission).then(() => {
+export const grantToGroup = (projectKey, groupName, permission, organization) => dispatch => {
+ api.grantPermissionToGroup(projectKey, groupName, permission, organization).then(() => {
dispatch({
type: GRANT_PERMISSION_TO_GROUP,
groupName,
});
};
-export const revokeFromGroup = (projectKey, groupName, permission) => dispatch => {
- api.revokePermissionFromGroup(projectKey, groupName, permission).then(() => {
+export const revokeFromGroup = (projectKey, groupName, permission, organization) => dispatch => {
+ api.revokePermissionFromGroup(projectKey, groupName, permission, organization).then(() => {
dispatch({
type: REVOKE_PERMISSION_FROM_GROUP,
groupName,
},
loadPermissionTemplates () {
- return getPermissionTemplates().then(r => {
+ return getPermissionTemplates(this.options.project.organization).then(r => {
this.permissionTemplates = r.permissionTemplates;
this.render();
});