diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/project-admin/store/actions.js')
-rw-r--r-- | server/sonar-web/src/main/js/apps/project-admin/store/actions.js | 138 |
1 files changed, 65 insertions, 73 deletions
diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/actions.js b/server/sonar-web/src/main/js/apps/project-admin/store/actions.js index d3f66e9af6c..8fa84ac1d97 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/store/actions.js +++ b/server/sonar-web/src/main/js/apps/project-admin/store/actions.js @@ -47,19 +47,18 @@ export const receiveProjectProfiles = (projectKey, profiles) => ({ profiles }); -export const fetchProjectProfiles = (projectKey, organization) => - dispatch => { - Promise.all([ - organization ? getQualityProfiles({ organization }) : getQualityProfiles(), - organization - ? getQualityProfiles({ organization, projectKey }) - : getQualityProfiles({ projectKey }) - ]).then(responses => { - const [allProfiles, projectProfiles] = responses; - dispatch(receiveProfiles(allProfiles)); - dispatch(receiveProjectProfiles(projectKey, projectProfiles)); - }); - }; +export const fetchProjectProfiles = (projectKey, organization) => dispatch => { + Promise.all([ + organization ? getQualityProfiles({ organization }) : getQualityProfiles(), + organization + ? getQualityProfiles({ organization, projectKey }) + : getQualityProfiles({ projectKey }) + ]).then(responses => { + const [allProfiles, projectProfiles] = responses; + dispatch(receiveProfiles(allProfiles)); + dispatch(receiveProjectProfiles(projectKey, projectProfiles)); + }); +}; export const SET_PROJECT_PROFILE = 'projectAdmin/SET_PROJECT_PROFILE'; const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ @@ -69,26 +68,25 @@ const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ newProfileKey }); -export const setProjectProfile = (projectKey, oldKey, newKey) => - (dispatch, getState) => { - const state = getState(); - const newProfile = getProjectAdminProfileByKey(state, newKey); - const request = newProfile.isDefault - ? dissociateProject(oldKey, projectKey) - : associateProject(newKey, projectKey); - - request.then(() => { - dispatch(setProjectProfileAction(projectKey, oldKey, newKey)); - dispatch( - addGlobalSuccessMessage( - translateWithParameters( - 'project_quality_profile.successfully_updated', - newProfile.languageName - ) +export const setProjectProfile = (projectKey, oldKey, newKey) => (dispatch, getState) => { + const state = getState(); + const newProfile = getProjectAdminProfileByKey(state, newKey); + const request = newProfile.isDefault + ? dissociateProject(oldKey, projectKey) + : associateProject(newKey, projectKey); + + request.then(() => { + dispatch(setProjectProfileAction(projectKey, oldKey, newKey)); + dispatch( + addGlobalSuccessMessage( + translateWithParameters( + 'project_quality_profile.successfully_updated', + newProfile.languageName ) - ); - }); - }; + ) + ); + }); +}; export const RECEIVE_GATES = 'projectAdmin/RECEIVE_GATES'; export const receiveGates = gates => ({ @@ -103,14 +101,13 @@ export const receiveProjectGate = (projectKey, gate) => ({ gate }); -export const fetchProjectGate = projectKey => - dispatch => { - Promise.all([fetchQualityGates(), getGateForProject(projectKey)]).then(responses => { - const [allGates, projectGate] = responses; - dispatch(receiveGates(allGates)); - dispatch(receiveProjectGate(projectKey, projectGate)); - }); - }; +export const fetchProjectGate = projectKey => dispatch => { + Promise.all([fetchQualityGates(), getGateForProject(projectKey)]).then(responses => { + const [allGates, projectGate] = responses; + dispatch(receiveGates(allGates)); + dispatch(receiveProjectGate(projectKey, projectGate)); + }); +}; export const SET_PROJECT_GATE = 'projectAdmin/SET_PROJECT_GATE'; const setProjectGateAction = (projectKey, gateId) => ({ @@ -119,17 +116,16 @@ const setProjectGateAction = (projectKey, gateId) => ({ gateId }); -export const setProjectGate = (projectKey, oldId, newId) => - dispatch => { - const request = newId != null - ? associateGateWithProject(newId, projectKey) - : dissociateGateWithProject(oldId, projectKey); +export const setProjectGate = (projectKey, oldId, newId) => dispatch => { + const request = newId != null + ? associateGateWithProject(newId, projectKey) + : dissociateGateWithProject(oldId, projectKey); - request.then(() => { - dispatch(setProjectGateAction(projectKey, newId)); - dispatch(addGlobalSuccessMessage(translate('project_quality_gate.successfully_updated'))); - }); - }; + request.then(() => { + dispatch(setProjectGateAction(projectKey, newId)); + dispatch(addGlobalSuccessMessage(translate('project_quality_gate.successfully_updated'))); + }); +}; export const RECEIVE_PROJECT_LINKS = 'projectAdmin/RECEIVE_PROJECT_LINKS'; export const receiveProjectLinks = (projectKey, links) => ({ @@ -138,12 +134,11 @@ export const receiveProjectLinks = (projectKey, links) => ({ links }); -export const fetchProjectLinks = projectKey => - dispatch => { - getProjectLinks(projectKey).then(links => { - dispatch(receiveProjectLinks(projectKey, links)); - }); - }; +export const fetchProjectLinks = projectKey => dispatch => { + getProjectLinks(projectKey).then(links => { + dispatch(receiveProjectLinks(projectKey, links)); + }); +}; export const ADD_PROJECT_LINK = 'projectAdmin/ADD_PROJECT_LINK'; const addProjectLink = (projectKey, link) => ({ @@ -152,12 +147,11 @@ const addProjectLink = (projectKey, link) => ({ link }); -export const createProjectLink = (projectKey, name, url) => - dispatch => { - return createLink(projectKey, name, url).then(link => { - dispatch(addProjectLink(projectKey, link)); - }); - }; +export const createProjectLink = (projectKey, name, url) => dispatch => { + return createLink(projectKey, name, url).then(link => { + dispatch(addProjectLink(projectKey, link)); + }); +}; export const DELETE_PROJECT_LINK = 'projectAdmin/DELETE_PROJECT_LINK'; export const deleteProjectLink = (projectKey, linkId) => ({ @@ -173,13 +167,12 @@ const receiveProjectModules = (projectKey, modules) => ({ modules }); -export const fetchProjectModules = projectKey => - dispatch => { - const options = { qualifiers: 'BRC', s: 'name', ps: 500 }; - getTree(projectKey, options).then(r => { - dispatch(receiveProjectModules(projectKey, r.components)); - }); - }; +export const fetchProjectModules = projectKey => dispatch => { + const options = { qualifiers: 'BRC', s: 'name', ps: 500 }; + getTree(projectKey, options).then(r => { + dispatch(receiveProjectModules(projectKey, r.components)); + }); +}; export const CHANGE_KEY = 'projectAdmin/CHANGE_KEY'; const changeKeyAction = (key, newKey) => ({ @@ -188,7 +181,6 @@ const changeKeyAction = (key, newKey) => ({ newKey }); -export const changeKey = (key, newKey) => - dispatch => { - return changeKeyApi(key, newKey).then(() => dispatch(changeKeyAction(key, newKey))); - }; +export const changeKey = (key, newKey) => dispatch => { + return changeKeyApi(key, newKey).then(() => dispatch(changeKeyAction(key, newKey))); +}; |