diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-04-20 11:10:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 11:10:13 +0200 |
commit | f6e90fdc19e222b3b238f0f5995a8039b7db158e (patch) | |
tree | 69c22415cb50a650b046ce4b9a9ac99e57695dfd /server/sonar-web/src/main/js/apps/permissions/global | |
parent | 36c9fa041018d7eed91f1d22e0c5eda075737ebc (diff) | |
download | sonarqube-f6e90fdc19e222b3b238f0f5995a8039b7db158e.tar.gz sonarqube-f6e90fdc19e222b3b238f0f5995a8039b7db158e.zip |
upgrade prettier (#1954)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/permissions/global')
-rw-r--r-- | server/sonar-web/src/main/js/apps/permissions/global/store/actions.js | 208 |
1 files changed, 106 insertions, 102 deletions
diff --git a/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js index 64c80c2b924..19a153e8b4c 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js @@ -38,121 +38,125 @@ import { getPermissionsAppSelectedPermission } from '../../../../store/rootReducer'; -type Dispatch = (Object) => void; +type Dispatch = Object => void; type GetState = () => Object; -export const loadHolders = (organization?: string) => - (dispatch: Dispatch, getState: GetState) => { - const query = getPermissionsAppQuery(getState()); - const filter = getPermissionsAppFilter(getState()); - const selectedPermission = getPermissionsAppSelectedPermission(getState()); +export const loadHolders = (organization?: string) => (dispatch: Dispatch, getState: GetState) => { + const query = getPermissionsAppQuery(getState()); + const filter = getPermissionsAppFilter(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); - dispatch({ type: REQUEST_HOLDERS, query }); + dispatch({ type: REQUEST_HOLDERS, query }); - const requests = []; + const requests = []; - if (filter !== 'groups') { - requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'groups') { + requests.push(api.getGlobalPermissionsUsers(query, selectedPermission, organization)); + } else { + requests.push(Promise.resolve([])); + } - if (filter !== 'users') { - requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); - } else { - requests.push(Promise.resolve([])); - } + if (filter !== 'users') { + requests.push(api.getGlobalPermissionsGroups(query, selectedPermission, organization)); + } else { + requests.push(Promise.resolve([])); + } - return Promise.all(requests) - .then(responses => - dispatch({ - type: RECEIVE_HOLDERS_SUCCESS, - users: responses[0], - groups: responses[1], - query - })) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; - -export const updateQuery = (query: string = '', organization?: string) => - (dispatch: Dispatch) => { - dispatch({ type: UPDATE_QUERY, query }); - if (query.length === 0 || query.length > 2) { - dispatch(loadHolders(organization)); - } - }; + return Promise.all(requests) + .then(responses => + dispatch({ + type: RECEIVE_HOLDERS_SUCCESS, + users: responses[0], + groups: responses[1], + query + }) + ) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const updateFilter = (filter: string, organization?: string) => - (dispatch: Dispatch) => { - dispatch({ type: UPDATE_FILTER, filter }); +export const updateQuery = (query: string = '', organization?: string) => (dispatch: Dispatch) => { + dispatch({ type: UPDATE_QUERY, query }); + if (query.length === 0 || query.length > 2) { dispatch(loadHolders(organization)); - }; + } +}; -export const selectPermission = (permission: string, organization?: string) => - (dispatch: Dispatch, getState: GetState) => { - const selectedPermission = getPermissionsAppSelectedPermission(getState()); - if (selectedPermission !== permission) { - dispatch({ type: SELECT_PERMISSION, permission }); - } else { - dispatch({ type: SELECT_PERMISSION, permission: null }); - } - dispatch(loadHolders(organization)); - }; +export const updateFilter = (filter: string, organization?: string) => (dispatch: Dispatch) => { + dispatch({ type: UPDATE_FILTER, filter }); + dispatch(loadHolders(organization)); +}; -export const grantToUser = (login: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .grantPermissionToUser(null, login, permission, organization) - .then(() => { - dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; +export const selectPermission = (permission: string, organization?: string) => ( + dispatch: Dispatch, + getState: GetState +) => { + const selectedPermission = getPermissionsAppSelectedPermission(getState()); + if (selectedPermission !== permission) { + dispatch({ type: SELECT_PERMISSION, permission }); + } else { + dispatch({ type: SELECT_PERMISSION, permission: null }); + } + dispatch(loadHolders(organization)); +}; -export const revokeFromUser = (login: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .revokePermissionFromUser(null, login, permission, organization) - .then(() => { - dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); - }); - }; +export const grantToUser = (login: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .grantPermissionToUser(null, login, permission, organization) + .then(() => { + dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const grantToGroup = (groupName: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .grantPermissionToGroup(null, groupName, permission, organization) - .then(() => { - dispatch({ - type: GRANT_PERMISSION_TO_GROUP, - groupName, - permission - }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); +export const revokeFromUser = (login: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .revokePermissionFromUser(null, 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 = (groupName: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .grantPermissionToGroup(null, groupName, permission, organization) + .then(() => { + dispatch({ + type: GRANT_PERMISSION_TO_GROUP, + groupName, + permission }); - }; + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; -export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => - (dispatch: Dispatch) => { - api - .revokePermissionFromGroup(null, groupName, permission, organization) - .then(() => { - dispatch({ - type: REVOKE_PERMISSION_FROM_GROUP, - groupName, - permission - }); - }) - .catch(e => { - return parseError(e).then(message => dispatch(raiseError(message))); +export const revokeFromGroup = (groupName: string, permission: string, organization?: string) => ( + dispatch: Dispatch +) => { + api + .revokePermissionFromGroup(null, groupName, permission, organization) + .then(() => { + dispatch({ + type: REVOKE_PERMISSION_FROM_GROUP, + groupName, + permission }); - }; + }) + .catch(e => { + return parseError(e).then(message => dispatch(raiseError(message))); + }); +}; |