diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-03-28 12:13:23 +0200 |
---|---|---|
committer | Grégoire Aubert <gregaubert@users.noreply.github.com> | 2017-03-31 10:29:27 +0200 |
commit | 76ad0222a481f307474b2990f264780f42cf3627 (patch) | |
tree | e23bfc78a9f43c2afd9d35baf46f54e0118fde0e /server/sonar-web/src/main/js/store | |
parent | 4b2cf358d38ad0e1931246530d3ff6ada7467079 (diff) | |
download | sonarqube-76ad0222a481f307474b2990f264780f42cf3627.tar.gz sonarqube-76ad0222a481f307474b2990f264780f42cf3627.zip |
SONAR-8993 Remove member from organization
Diffstat (limited to 'server/sonar-web/src/main/js/store')
-rw-r--r-- | server/sonar-web/src/main/js/store/organizationsMembers/actions.js | 7 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/store/organizationsMembers/reducer.js | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/store/organizationsMembers/actions.js b/server/sonar-web/src/main/js/store/organizationsMembers/actions.js index 08425dafc76..dcd2312f9c9 100644 --- a/server/sonar-web/src/main/js/store/organizationsMembers/actions.js +++ b/server/sonar-web/src/main/js/store/organizationsMembers/actions.js @@ -38,6 +38,7 @@ export const actions = { RECEIVE_MEMBERS: 'organizations/RECEIVE_MEMBERS', RECEIVE_MORE_MEMBERS: 'organizations/RECEIVE_MORE_MEMBERS', ADD_MEMBER: 'organizations/ADD_MEMBER', + REMOVE_MEMBER: 'organizations/REMOVE_MEMBER' }; export const receiveMembers = (organizationKey: string, members: Array<Member>, stateChanges: MembersState) => ({ @@ -60,6 +61,12 @@ export const addMember = (organizationKey: string, member: Member) => ({ member }); +export const removeMember = (organizationKey: string, member: Member) => ({ + type: actions.REMOVE_MEMBER, + organization: organizationKey, + member +}); + export const updateState = ( organizationKey: string, stateChanges: MembersState diff --git a/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js b/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js index 3e635f21dbc..346b4a26a48 100644 --- a/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js +++ b/server/sonar-web/src/main/js/store/organizationsMembers/reducer.js @@ -51,6 +51,17 @@ const organizationMembers = (state = {}, action = {}) => { members: withNew }; } + case actions.REMOVE_MEMBER: { + const withoutDeleted = state.members.filter(login => login !== action.member.login); + if (withoutDeleted.length === state.members.length) { + return state; + } + return { + ...state, + total: withoutDeleted.length, + members: withoutDeleted + }; + } default: return state; } @@ -63,6 +74,7 @@ const organizationsMembers = (state = {}, action = {}) => { case actions.RECEIVE_MEMBERS: case actions.RECEIVE_MORE_MEMBERS: case actions.ADD_MEMBER: + case actions.REMOVE_MEMBER: return { ...state, [action.organization]: organizationMembers(organization, action) |