diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-09-01 16:33:48 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 11:34:58 +0200 |
commit | c2954e35714c703c84b0e4c2af4e0249751516b6 (patch) | |
tree | 2b41a712c1f161815fc936eb520ee04da49b2a07 /server/sonar-web/src/main/js/apps/project-admin/store | |
parent | 081f3bce1dfa04d2445178045885bd8a50494f1f (diff) | |
download | sonarqube-c2954e35714c703c84b0e4c2af4e0249751516b6.tar.gz sonarqube-c2954e35714c703c84b0e4c2af4e0249751516b6.zip |
SONAR-9736 fix access to project admin pages
Diffstat (limited to 'server/sonar-web/src/main/js/apps/project-admin/store')
6 files changed, 0 insertions, 281 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 6701e8f07db..28f7473e260 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 @@ -17,116 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { - searchQualityProfiles, - associateProject, - dissociateProject -} from '../../../api/quality-profiles'; -import { - fetchQualityGates, - getGateForProject, - associateGateWithProject, - dissociateGateWithProject -} from '../../../api/quality-gates'; import { getProjectLinks, createLink } from '../../../api/projectLinks'; import { getTree, changeKey as changeKeyApi } from '../../../api/components'; -import { addGlobalSuccessMessage } from '../../../store/globalMessages/duck'; -import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { getProjectAdminProfileByKey } from '../../../store/rootReducer'; - -export const RECEIVE_PROFILES = 'projectAdmin/RECEIVE_PROFILES'; -export const receiveProfiles = profiles => ({ - type: RECEIVE_PROFILES, - profiles -}); - -export const RECEIVE_PROJECT_PROFILES = 'projectAdmin/RECEIVE_PROJECT_PROFILES'; -export const receiveProjectProfiles = (projectKey, profiles) => ({ - type: RECEIVE_PROJECT_PROFILES, - projectKey, - profiles -}); - -export const fetchProjectProfiles = (projectKey, organization) => dispatch => { - Promise.all([ - organization ? searchQualityProfiles({ organization }) : searchQualityProfiles(), - organization - ? searchQualityProfiles({ organization, projectKey }) - : searchQualityProfiles({ 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) => ({ - type: SET_PROJECT_PROFILE, - projectKey, - oldProfileKey, - 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 RECEIVE_GATES = 'projectAdmin/RECEIVE_GATES'; -export const receiveGates = gates => ({ - type: RECEIVE_GATES, - gates -}); - -export const RECEIVE_PROJECT_GATE = 'projectAdmin/RECEIVE_PROJECT_GATE'; -export const receiveProjectGate = (projectKey, gate) => ({ - type: RECEIVE_PROJECT_GATE, - projectKey, - 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 SET_PROJECT_GATE = 'projectAdmin/SET_PROJECT_GATE'; -const setProjectGateAction = (projectKey, gateId) => ({ - type: SET_PROJECT_GATE, - projectKey, - gateId -}); - -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'))); - }); -}; export const RECEIVE_PROJECT_LINKS = 'projectAdmin/RECEIVE_PROJECT_LINKS'; export const receiveProjectLinks = (projectKey, links) => ({ diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/gateByProject.js b/server/sonar-web/src/main/js/apps/project-admin/store/gateByProject.js deleted file mode 100644 index 451f531d1ca..00000000000 --- a/server/sonar-web/src/main/js/apps/project-admin/store/gateByProject.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { RECEIVE_PROJECT_GATE, SET_PROJECT_GATE } from './actions'; - -const gateByProject = (state = {}, action = {}) => { - if (action.type === RECEIVE_PROJECT_GATE) { - const gateId = action.gate ? action.gate.id : null; - return { ...state, [action.projectKey]: gateId }; - } - - if (action.type === SET_PROJECT_GATE) { - return { ...state, [action.projectKey]: action.gateId }; - } - - return state; -}; - -export default gateByProject; - -export const getProjectGate = (state, projectKey) => state[projectKey]; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/gates.js b/server/sonar-web/src/main/js/apps/project-admin/store/gates.js deleted file mode 100644 index d68aae11508..00000000000 --- a/server/sonar-web/src/main/js/apps/project-admin/store/gates.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { keyBy, values } from 'lodash'; -import { RECEIVE_GATES } from './actions'; - -const gates = (state = {}, action = {}) => { - if (action.type === RECEIVE_GATES) { - const newGatesById = keyBy(action.gates, 'id'); - return { ...state, ...newGatesById }; - } - - return state; -}; - -export default gates; - -export const getAllGates = state => values(state); - -export const getGate = (state, id) => state[id]; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/profiles.js b/server/sonar-web/src/main/js/apps/project-admin/store/profiles.js deleted file mode 100644 index ed6a8345d0e..00000000000 --- a/server/sonar-web/src/main/js/apps/project-admin/store/profiles.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { keyBy, values } from 'lodash'; -import { RECEIVE_PROFILES } from './actions'; - -const profiles = (state = {}, action = {}) => { - if (action.type === RECEIVE_PROFILES) { - const newProfilesByKey = keyBy(action.profiles, 'key'); - return { ...state, ...newProfilesByKey }; - } - - return state; -}; - -export default profiles; - -export const getAllProfiles = state => values(state); - -export const getProfile = (state, key) => state[key]; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/profilesByProject.js b/server/sonar-web/src/main/js/apps/project-admin/store/profilesByProject.js deleted file mode 100644 index afc7ea0143b..00000000000 --- a/server/sonar-web/src/main/js/apps/project-admin/store/profilesByProject.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { without } from 'lodash'; -import { RECEIVE_PROJECT_PROFILES, SET_PROJECT_PROFILE } from './actions'; - -const profilesByProject = (state = {}, action = {}) => { - if (action.type === RECEIVE_PROJECT_PROFILES) { - const profileKeys = action.profiles.map(profile => profile.key); - return { ...state, [action.projectKey]: profileKeys }; - } - - if (action.type === SET_PROJECT_PROFILE) { - const profileKeys = state[action.projectKey]; - const nextProfileKeys = [...without(profileKeys, action.oldProfileKey), action.newProfileKey]; - return { ...state, [action.projectKey]: nextProfileKeys }; - } - - return state; -}; - -export default profilesByProject; - -export const getProfiles = (state, projectKey) => state[projectKey] || []; diff --git a/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js b/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js index 4eb6dec8e0e..43ab5760cfd 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js +++ b/server/sonar-web/src/main/js/apps/project-admin/store/rootReducer.js @@ -18,10 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { combineReducers } from 'redux'; -import profiles, { getProfile, getAllProfiles as nextGetAllProfiles } from './profiles'; -import profilesByProject, { getProfiles } from './profilesByProject'; -import gates, { getAllGates as nextGetAllGates, getGate } from './gates'; -import gateByProject, { getProjectGate as nextGetProjectGate } from './gateByProject'; import links, { getLink } from './links'; import linksByProject, { getLinks } from './linksByProject'; import components, { getComponentByKey as nextGetComponentByKey } from './components'; @@ -31,10 +27,6 @@ import globalMessages, { } from '../../../store/globalMessages/duck'; const rootReducer = combineReducers({ - profiles, - profilesByProject, - gates, - gateByProject, links, linksByProject, components, @@ -44,22 +36,6 @@ const rootReducer = combineReducers({ export default rootReducer; -export const getProfileByKey = (state, profileKey) => getProfile(state.profiles, profileKey); - -export const getAllProfiles = state => nextGetAllProfiles(state.profiles); - -export const getProjectProfiles = (state, projectKey) => - getProfiles(state.profilesByProject, projectKey).map(profileKey => - getProfileByKey(state, profileKey) - ); - -export const getGateById = (state, gateId) => getGate(state.gates, gateId); - -export const getAllGates = state => nextGetAllGates(state.gates); - -export const getProjectGate = (state, projectKey) => - getGateById(state, nextGetProjectGate(state.gateByProject, projectKey)); - export const getLinkById = (state, linkId) => getLink(state.links, linkId); export const getProjectLinks = (state, projectKey) => |