diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/project-admin')
10 files changed, 66 insertions, 94 deletions
diff --git a/server/sonar-web/src/main/js/apps/project-admin/app.js b/server/sonar-web/src/main/js/apps/project-admin/app.js deleted file mode 100644 index 903ed046cb9..00000000000 --- a/server/sonar-web/src/main/js/apps/project-admin/app.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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 React from 'react'; -import { render } from 'react-dom'; -import { Provider } from 'react-redux'; -import { Router, Route, useRouterHistory } from 'react-router'; -import { createHistory } from 'history'; -import Deletion from './deletion/Deletion'; -import QualityProfiles from './quality-profiles/QualityProfiles'; -import QualityGate from './quality-gate/QualityGate'; -import Links from './links/Links'; -import Key from './key/Key'; -import rootReducer from './store/rootReducer'; -import configureStore from '../../components/store/configureStore'; - -window.sonarqube.appStarted.then(options => { - const el = document.querySelector(options.el); - - const history = useRouterHistory(createHistory)({ - basename: window.baseUrl + '/project' - }); - - const store = configureStore(rootReducer); - - const withComponent = ComposedComponent => props => - <ComposedComponent {...props} component={options.component}/>; - - render(( - <Provider store={store}> - <Router history={history}> - <Route - path="/deletion" - component={withComponent(Deletion)}/> - <Route - path="/quality_profiles" - component={withComponent(QualityProfiles)}/> - <Route - path="/quality_gate" - component={withComponent(QualityGate)}/> - <Route - path="/links" - component={withComponent(Links)}/> - <Route - path="/key" - component={withComponent(Key)}/> - </Router> - </Provider> - ), el); -}); diff --git a/server/sonar-web/src/main/js/apps/project-admin/components/GlobalMessagesContainer.js b/server/sonar-web/src/main/js/apps/project-admin/components/GlobalMessagesContainer.js index f64ef91664b..130192047b7 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/components/GlobalMessagesContainer.js +++ b/server/sonar-web/src/main/js/apps/project-admin/components/GlobalMessagesContainer.js @@ -19,10 +19,10 @@ */ import { connect } from 'react-redux'; import GlobalMessages from '../../../components/controls/GlobalMessages'; -import { getGlobalMessages } from '../store/rootReducer'; +import { getProjectAdminGlobalMessages } from '../../../app/store/rootReducer'; const mapStateToProps = state => ({ - messages: getGlobalMessages(state) + messages: getProjectAdminGlobalMessages(state) }); export default connect(mapStateToProps)(GlobalMessages); diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js b/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js index 67563891ade..52e4fbc1774 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js +++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js @@ -23,10 +23,14 @@ import Form from './Form'; export default class Deletion extends React.Component { static propTypes = { - component: React.PropTypes.object.isRequired + component: React.PropTypes.object }; render () { + if (!this.props.component) { + return null; + } + return ( <div className="page page-limited"> <Header/> diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js b/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js index 315dc4b17f2..4bc8050a464 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/BulkUpdate.js @@ -30,7 +30,7 @@ import { closeAllGlobalMessages } from '../../../components/store/globalMessages'; import { reloadUpdateKeyPage } from './utils'; -import RecentHistory from '../../../main/nav/component/RecentHistory'; +import RecentHistory from '../../../app/components/nav/component/RecentHistory'; class BulkUpdate extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/apps/project-admin/key/Key.js b/server/sonar-web/src/main/js/apps/project-admin/key/Key.js index 019cde640df..f4bff8b4a59 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/key/Key.js +++ b/server/sonar-web/src/main/js/apps/project-admin/key/Key.js @@ -25,7 +25,6 @@ import UpdateForm from './UpdateForm'; import BulkUpdate from './BulkUpdate'; import FineGrainedUpdate from './FineGrainedUpdate'; import GlobalMessagesContainer from '../components/GlobalMessagesContainer'; -import { getProjectModules } from '../store/rootReducer'; import { fetchProjectModules, changeKey } from '../store/actions'; import { translate } from '../../../helpers/l10n'; import { @@ -35,7 +34,8 @@ import { } from '../../../components/store/globalMessages'; import { parseError } from '../../code/utils'; import { reloadUpdateKeyPage } from './utils'; -import RecentHistory from '../../../main/nav/component/RecentHistory'; +import RecentHistory from '../../../app/components/nav/component/RecentHistory'; +import { getProjectAdminProjectModules } from '../../../app/store/rootReducer'; class Key extends React.Component { static propTypes = { @@ -152,7 +152,7 @@ class Key extends React.Component { } const mapStateToProps = (state, ownProps) => ({ - modules: getProjectModules(state, ownProps.component.key) + modules: getProjectAdminProjectModules(state, ownProps.component.key) }); export default connect( diff --git a/server/sonar-web/src/main/js/apps/project-admin/links/Links.js b/server/sonar-web/src/main/js/apps/project-admin/links/Links.js index 88602532ea9..4494c52b5c9 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/links/Links.js +++ b/server/sonar-web/src/main/js/apps/project-admin/links/Links.js @@ -23,12 +23,12 @@ import { connect } from 'react-redux'; import Header from './Header'; import Table from './Table'; import DeletionModal from './views/DeletionModal'; -import { getProjectLinks } from '../store/rootReducer'; import { fetchProjectLinks, deleteProjectLink, createProjectLink } from '../store/actions'; +import { getProjectAdminProjectLinks } from '../../../app/store/rootReducer'; class Links extends React.Component { static propTypes = { @@ -73,7 +73,7 @@ class Links extends React.Component { } const mapStateToProps = (state, ownProps) => ({ - links: getProjectLinks(state, ownProps.component.key) + links: getProjectAdminProjectLinks(state, ownProps.component.key) }); export default connect( diff --git a/server/sonar-web/src/main/js/apps/project-admin/quality-gate/QualityGate.js b/server/sonar-web/src/main/js/apps/project-admin/quality-gate/QualityGate.js index e80c5b72284..0921f1f2060 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/quality-gate/QualityGate.js +++ b/server/sonar-web/src/main/js/apps/project-admin/quality-gate/QualityGate.js @@ -23,8 +23,8 @@ import shallowCompare from 'react-addons-shallow-compare'; import Header from './Header'; import Form from './Form'; import GlobalMessagesContainer from '../components/GlobalMessagesContainer'; -import { getAllGates, getProjectGate } from '../store/rootReducer'; import { fetchProjectGate, setProjectGate } from '../store/actions'; +import { getProjectAdminAllGates, getProjectAdminProjectGate } from '../../../app/store/rootReducer'; class QualityGate extends React.Component { static propTypes = { @@ -60,8 +60,8 @@ class QualityGate extends React.Component { } const mapStateToProps = (state, ownProps) => ({ - allGates: getAllGates(state), - gate: getProjectGate(state, ownProps.component.key) + allGates: getProjectAdminAllGates(state), + gate: getProjectAdminProjectGate(state, ownProps.component.key) }); export default connect( diff --git a/server/sonar-web/src/main/js/apps/project-admin/quality-profiles/QualityProfiles.js b/server/sonar-web/src/main/js/apps/project-admin/quality-profiles/QualityProfiles.js index de20aa1ad8d..9bfdab5c533 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/quality-profiles/QualityProfiles.js +++ b/server/sonar-web/src/main/js/apps/project-admin/quality-profiles/QualityProfiles.js @@ -24,7 +24,7 @@ import Header from './Header'; import Table from './Table'; import GlobalMessagesContainer from '../components/GlobalMessagesContainer'; import { fetchProjectProfiles, setProjectProfile } from '../store/actions'; -import { getProjectProfiles, getAllProfiles } from '../store/rootReducer'; +import { getProjectAdminAllProfiles, getProjectAdminProjectProfiles } from '../../../app/store/rootReducer'; class QualityProfiles extends React.Component { static propTypes = { @@ -68,8 +68,8 @@ class QualityProfiles extends React.Component { } const mapStateToProps = (state, ownProps) => ({ - allProfiles: getAllProfiles(state), - profiles: getProjectProfiles(state, ownProps.component.key) + allProfiles: getProjectAdminAllProfiles(state), + profiles: getProjectAdminProjectProfiles(state, ownProps.component.key) }); export default connect( diff --git a/server/sonar-web/src/main/js/apps/project-admin/routes.js b/server/sonar-web/src/main/js/apps/project-admin/routes.js new file mode 100644 index 00000000000..fda733c0002 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/project-admin/routes.js @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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 React from 'react'; +import { Route } from 'react-router'; +import Deletion from './deletion/Deletion'; +import QualityProfiles from './quality-profiles/QualityProfiles'; +import QualityGate from './quality-gate/QualityGate'; +import Links from './links/Links'; +import Key from './key/Key'; + +export default [ + <Route key="deletion" path="deletion" component={Deletion}/>, + <Route key="quality_profiles" path="quality_profiles" component={QualityProfiles}/>, + <Route key="quality_gate" path="quality_gate" component={QualityGate}/>, + <Route key="links" path="links" component={Links}/>, + <Route key="key" path="key" component={Key}/> +]; 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 18eb9917862..b5c3c1a5f21 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 @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getQualityProfiles, associateProject, dissociateProject } from '../../../api/quality-profiles'; -import { getProfileByKey } from './rootReducer'; import { fetchQualityGates, getGateForProject, @@ -29,14 +28,15 @@ import { getProjectLinks, createLink } from '../../../api/projectLinks'; import { getTree, changeKey as changeKeyApi } from '../../../api/components'; import { addGlobalSuccessMessage } from '../../../components/store/globalMessages'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { getProjectAdminProfileByKey } from '../../../app/store/rootReducer'; -export const RECEIVE_PROFILES = 'RECEIVE_PROFILES'; +export const RECEIVE_PROFILES = 'projectAdmin/RECEIVE_PROFILES'; export const receiveProfiles = profiles => ({ type: RECEIVE_PROFILES, profiles }); -export const RECEIVE_PROJECT_PROFILES = 'RECEIVE_PROJECT_PROFILES'; +export const RECEIVE_PROJECT_PROFILES = 'projectAdmin/RECEIVE_PROJECT_PROFILES'; export const receiveProjectProfiles = (projectKey, profiles) => ({ type: RECEIVE_PROJECT_PROFILES, projectKey, @@ -54,7 +54,7 @@ export const fetchProjectProfiles = projectKey => dispatch => { }); }; -export const SET_PROJECT_PROFILE = 'SET_PROJECT_PROFILE'; +export const SET_PROJECT_PROFILE = 'projectAdmin/SET_PROJECT_PROFILE'; const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ type: SET_PROJECT_PROFILE, projectKey, @@ -65,7 +65,7 @@ const setProjectProfileAction = (projectKey, oldProfileKey, newProfileKey) => ({ export const setProjectProfile = (projectKey, oldKey, newKey) => (dispatch, getState) => { const state = getState(); - const newProfile = getProfileByKey(state, newKey); + const newProfile = getProjectAdminProfileByKey(state, newKey); const request = newProfile.isDefault ? dissociateProject(oldKey, projectKey) : associateProject(newKey, projectKey); @@ -79,13 +79,13 @@ export const setProjectProfile = (projectKey, oldKey, newKey) => }); }; -export const RECEIVE_GATES = 'RECEIVE_GATES'; +export const RECEIVE_GATES = 'projectAdmin/RECEIVE_GATES'; export const receiveGates = gates => ({ type: RECEIVE_GATES, gates }); -export const RECEIVE_PROJECT_GATE = 'RECEIVE_PROJECT_GATE'; +export const RECEIVE_PROJECT_GATE = 'projectAdmin/RECEIVE_PROJECT_GATE'; export const receiveProjectGate = (projectKey, gate) => ({ type: RECEIVE_PROJECT_GATE, projectKey, @@ -103,7 +103,7 @@ export const fetchProjectGate = projectKey => dispatch => { }); }; -export const SET_PROJECT_GATE = 'SET_PROJECT_GATE'; +export const SET_PROJECT_GATE = 'projectAdmin/SET_PROJECT_GATE'; const setProjectGateAction = (projectKey, gateId) => ({ type: SET_PROJECT_GATE, projectKey, @@ -122,7 +122,7 @@ export const setProjectGate = (projectKey, oldId, newId) => dispatch => { }); }; -export const RECEIVE_PROJECT_LINKS = 'RECEIVE_PROJECT_LINKS'; +export const RECEIVE_PROJECT_LINKS = 'projectAdmin/RECEIVE_PROJECT_LINKS'; export const receiveProjectLinks = (projectKey, links) => ({ type: RECEIVE_PROJECT_LINKS, projectKey, @@ -135,7 +135,7 @@ export const fetchProjectLinks = projectKey => dispatch => { }); }; -export const ADD_PROJECT_LINK = 'ADD_PROJECT_LINK'; +export const ADD_PROJECT_LINK = 'projectAdmin/ADD_PROJECT_LINK'; const addProjectLink = (projectKey, link) => ({ type: ADD_PROJECT_LINK, projectKey, @@ -148,14 +148,14 @@ export const createProjectLink = (projectKey, name, url) => dispatch => { }); }; -export const DELETE_PROJECT_LINK = 'DELETE_PROJECT_LINK'; +export const DELETE_PROJECT_LINK = 'projectAdmin/DELETE_PROJECT_LINK'; export const deleteProjectLink = (projectKey, linkId) => ({ type: DELETE_PROJECT_LINK, projectKey, linkId }); -export const RECEIVE_PROJECT_MODULES = 'RECEIVE_PROJECT_MODULES'; +export const RECEIVE_PROJECT_MODULES = 'projectAdmin/RECEIVE_PROJECT_MODULES'; const receiveProjectModules = (projectKey, modules) => ({ type: RECEIVE_PROJECT_MODULES, projectKey, @@ -169,7 +169,7 @@ export const fetchProjectModules = projectKey => dispatch => { }); }; -export const CHANGE_KEY = 'CHANGE_KEY'; +export const CHANGE_KEY = 'projectAdmin/CHANGE_KEY'; const changeKeyAction = (key, newKey) => ({ type: CHANGE_KEY, key, |