diff options
Diffstat (limited to 'server/sonar-web')
5 files changed, 61 insertions, 49 deletions
diff --git a/server/sonar-web/src/main/js/api/permissions.js b/server/sonar-web/src/main/js/api/permissions.js index f498c3612d9..0496d8fa719 100644 --- a/server/sonar-web/src/main/js/api/permissions.js +++ b/server/sonar-web/src/main/js/api/permissions.js @@ -21,49 +21,51 @@ import { getJSON, post, postJSON } from '../helpers/request'; 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); } @@ -144,7 +146,7 @@ export function removeProjectCreatorFromTemplate (templateId, permission) { 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) { @@ -153,10 +155,13 @@ export function getPermissionsUsersForComponent (projectKey, query = '', permiss 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) { @@ -165,10 +170,13 @@ export function getPermissionsGroupsForComponent (projectKey, query = '', permis 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) { @@ -177,10 +185,13 @@ export function getGlobalPermissionsUsers (query = '', permission = null) { 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) { @@ -189,6 +200,9 @@ export function getGlobalPermissionsGroups (query = '', permission = null) { if (permission) { data.permission = permission; } + if (organization) { + data.organization = organization; + } return getJSON(url, data).then(r => r.groups); } diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js index dabcf13e564..6eff70419e1 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js @@ -135,20 +135,20 @@ const mapStateToProps = state => ({ 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( diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js index 700b2b48ea3..7a0a05686d9 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js @@ -80,8 +80,8 @@ const mapStateToProps = state => ({ 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( diff --git a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js index 1982d34ea05..26d69c45e4c 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js @@ -37,7 +37,7 @@ import { 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()); @@ -47,15 +47,13 @@ export const loadHolders = projectKey => (dispatch, 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([])); } @@ -72,46 +70,46 @@ export const loadHolders = projectKey => (dispatch, getState) => { }); }; -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, @@ -122,8 +120,8 @@ export const grantToGroup = (projectKey, groupName, permission) => dispatch => { }); }; -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, diff --git a/server/sonar-web/src/main/js/apps/permissions/project/views/ApplyTemplateView.js b/server/sonar-web/src/main/js/apps/permissions/project/views/ApplyTemplateView.js index 14817206db7..a22e93f8740 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/views/ApplyTemplateView.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/views/ApplyTemplateView.js @@ -33,7 +33,7 @@ export default ModalForm.extend({ }, loadPermissionTemplates () { - return getPermissionTemplates().then(r => { + return getPermissionTemplates(this.options.project.organization).then(r => { this.permissionTemplates = r.permissionTemplates; this.render(); }); |