From 4e096de629fda4bbdba94d8823da3f92881d7a4c Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 9 Dec 2016 15:44:24 +0100 Subject: reorganize store directories move store/ outside of app/ move components/store/* to store/ --- .../src/main/js/app/components/AdminContainer.js | 2 +- server/sonar-web/src/main/js/app/components/App.js | 4 +- .../src/main/js/app/components/GlobalFooter.js | 2 +- .../js/app/components/GlobalMessagesContainer.js | 4 +- .../src/main/js/app/components/Landing.js | 2 +- .../src/main/js/app/components/ProjectContainer.js | 4 +- .../nav/component/ComponentNavFavorite.js | 2 +- .../main/js/app/components/nav/global/GlobalNav.js | 2 +- .../app/components/nav/global/GlobalNavBranding.js | 2 +- .../app/components/nav/global/GlobalNavSearch.js | 2 +- .../src/main/js/app/store/appState/duck.js | 75 ----- .../src/main/js/app/store/components/actions.js | 25 -- .../src/main/js/app/store/components/reducer.js | 47 ---- .../src/main/js/app/store/favorites/duck.js | 63 ----- .../src/main/js/app/store/languages/actions.js | 25 -- .../src/main/js/app/store/languages/reducer.js | 35 --- .../src/main/js/app/store/measures/actions.js | 42 --- .../src/main/js/app/store/measures/reducer.js | 65 ----- .../sonar-web/src/main/js/app/store/rootActions.js | 77 ------ .../sonar-web/src/main/js/app/store/rootReducer.js | 304 --------------------- .../src/main/js/app/store/users/actions.js | 31 --- .../src/main/js/app/store/users/reducer.js | 52 ---- .../main/js/app/utils/getCurrentUserFromStore.js | 2 +- server/sonar-web/src/main/js/app/utils/getStore.js | 4 +- .../js/app/utils/handleRequiredAuthentication.js | 2 +- .../js/app/utils/handleRequiredAuthorization.js | 2 +- .../src/main/js/apps/about/components/AboutApp.js | 2 +- .../src/main/js/apps/account/components/Account.js | 2 +- .../main/js/apps/account/components/Security.js | 2 +- .../src/main/js/apps/account/profile/Profile.js | 2 +- .../components/BackgroundTasksApp.js | 2 +- .../src/main/js/apps/code/components/App.js | 2 +- .../components/ComponentIssuesAppContainer.js | 2 +- .../js/apps/component-measures/app/AppContainer.js | 2 +- .../bubbleChart/MeasureBubbleChartContainer.js | 2 +- .../details/MeasureDetailsContainer.js | 2 +- .../js/apps/component-measures/details/actions.js | 2 +- .../details/drilldown/ListViewContainer.js | 2 +- .../details/drilldown/TreeViewContainer.js | 2 +- .../details/history/MeasureHistoryContainer.js | 2 +- .../details/treemap/MeasureTreemapContainer.js | 2 +- .../home/AllMeasuresContainer.js | 2 +- .../home/DomainMeasuresContainer.js | 2 +- .../apps/component-measures/home/HomeContainer.js | 2 +- .../js/apps/component-measures/home/actions.js | 2 +- .../component-measures/store/listViewActions.js | 2 +- .../component-measures/store/treeViewActions.js | 2 +- .../components/CustomMeasuresAppContainer.js | 2 +- .../apps/issues/components/IssuesAppContainer.js | 2 +- .../js/apps/overview/components/AppContainer.js | 2 +- .../js/apps/overview/meta/MetaQualityProfiles.js | 2 +- .../components/AppContainer.js | 4 +- .../permission-templates/components/Template.js | 2 +- .../global/components/AllHoldersList.js | 2 +- .../permissions/global/components/PageHeader.js | 2 +- .../js/apps/permissions/global/store/actions.js | 2 +- .../project/components/AllHoldersList.js | 2 +- .../js/apps/permissions/project/components/App.js | 2 +- .../permissions/project/components/PageHeader.js | 2 +- .../js/apps/permissions/project/store/actions.js | 2 +- .../permissions/shared/components/PageError.js | 2 +- .../js/apps/project-admin/deletion/Deletion.js | 2 +- .../main/js/apps/project-admin/key/BulkUpdate.js | 2 +- .../src/main/js/apps/project-admin/key/Key.js | 4 +- .../src/main/js/apps/project-admin/links/Links.js | 2 +- .../apps/project-admin/quality-gate/QualityGate.js | 2 +- .../quality-profiles/QualityProfiles.js | 2 +- .../main/js/apps/project-admin/store/actions.js | 4 +- .../js/apps/project-admin/store/rootReducer.js | 2 +- .../main/js/apps/projects-admin/AppContainer.js | 4 +- .../projects/components/AllProjectsContainer.js | 2 +- .../projects/components/FavoriteFilterContainer.js | 2 +- .../components/FavoriteProjectsContainer.js | 2 +- .../projects/components/PageHeaderContainer.js | 2 +- .../projects/components/ProjectCardContainer.js | 2 +- .../projects/components/ProjectCardLanguages.js | 2 +- .../projects/components/ProjectsListContainer.js | 2 +- .../components/ProjectsListFooterContainer.js | 2 +- .../js/apps/projects/filters/FilterContainer.js | 2 +- .../src/main/js/apps/projects/store/actions.js | 10 +- .../src/main/js/apps/projects/store/facetsDuck.js | 2 +- .../src/main/js/apps/projects/store/stateDuck.js | 2 +- .../quality-gates/containers/DetailsContainer.js | 2 +- .../containers/QualityGatesAppContainer.js | 2 +- .../quality-profiles/components/AppContainer.js | 2 +- .../apps/sessions/components/LoginFormContainer.js | 4 +- .../src/main/js/apps/sessions/components/Logout.js | 2 +- .../apps/settings/components/AllCategoriesList.js | 2 +- .../src/main/js/apps/settings/components/App.js | 2 +- .../js/apps/settings/components/AppContainer.js | 2 +- .../settings/components/CategoryDefinitionsList.js | 2 +- .../main/js/apps/settings/components/Definition.js | 2 +- .../main/js/apps/settings/components/EmailForm.js | 2 +- .../settings/encryption/EncryptionAppContainer.js | 2 +- .../apps/settings/licenses/LicenseRowContainer.js | 2 +- .../settings/licenses/LicensesListContainer.js | 2 +- .../apps/settings/serverId/ServerIdAppContainer.js | 2 +- .../src/main/js/apps/settings/store/actions.js | 4 +- .../apps/settings/store/encryptionPage/actions.js | 2 +- .../js/apps/settings/store/licenses/actions.js | 2 +- .../src/main/js/apps/settings/store/rootReducer.js | 4 +- .../main/js/apps/settings/store/values/reducer.js | 2 +- .../components/UpdateCenterAppContainer.js | 2 +- .../js/apps/users/components/UsersAppContainer.js | 2 +- .../js/components/controls/FavoriteContainer.js | 6 +- .../main/js/components/controls/GlobalMessages.js | 2 +- .../src/main/js/components/store/configureStore.js | 40 --- .../main/js/components/store/generalReducers.js | 95 ------- .../src/main/js/components/store/globalMessages.js | 113 -------- .../src/main/js/components/store/withStore.js | 54 ---- .../sonar-web/src/main/js/components/ui/Avatar.js | 2 +- .../src/main/js/helpers/handlebars/avatarHelper.js | 2 +- .../main/js/helpers/handlebars/ifShowAvatars.js | 2 +- server/sonar-web/src/main/js/helpers/measures.js | 4 +- .../sonar-web/src/main/js/store/appState/duck.js | 75 +++++ .../src/main/js/store/components/actions.js | 25 ++ .../src/main/js/store/components/reducer.js | 47 ++++ .../sonar-web/src/main/js/store/favorites/duck.js | 63 +++++ .../src/main/js/store/globalMessages/duck.js | 113 ++++++++ .../src/main/js/store/languages/actions.js | 25 ++ .../src/main/js/store/languages/reducer.js | 35 +++ .../src/main/js/store/measures/actions.js | 42 +++ .../src/main/js/store/measures/reducer.js | 65 +++++ server/sonar-web/src/main/js/store/rootActions.js | 77 ++++++ server/sonar-web/src/main/js/store/rootReducer.js | 304 +++++++++++++++++++++ .../sonar-web/src/main/js/store/users/actions.js | 31 +++ .../sonar-web/src/main/js/store/users/reducer.js | 52 ++++ .../src/main/js/store/utils/configureStore.js | 40 +++ .../src/main/js/store/utils/generalReducers.js | 95 +++++++ .../sonar-web/src/main/js/store/utils/withStore.js | 54 ++++ 130 files changed, 1259 insertions(+), 1259 deletions(-) delete mode 100644 server/sonar-web/src/main/js/app/store/appState/duck.js delete mode 100644 server/sonar-web/src/main/js/app/store/components/actions.js delete mode 100644 server/sonar-web/src/main/js/app/store/components/reducer.js delete mode 100644 server/sonar-web/src/main/js/app/store/favorites/duck.js delete mode 100644 server/sonar-web/src/main/js/app/store/languages/actions.js delete mode 100644 server/sonar-web/src/main/js/app/store/languages/reducer.js delete mode 100644 server/sonar-web/src/main/js/app/store/measures/actions.js delete mode 100644 server/sonar-web/src/main/js/app/store/measures/reducer.js delete mode 100644 server/sonar-web/src/main/js/app/store/rootActions.js delete mode 100644 server/sonar-web/src/main/js/app/store/rootReducer.js delete mode 100644 server/sonar-web/src/main/js/app/store/users/actions.js delete mode 100644 server/sonar-web/src/main/js/app/store/users/reducer.js delete mode 100644 server/sonar-web/src/main/js/components/store/configureStore.js delete mode 100644 server/sonar-web/src/main/js/components/store/generalReducers.js delete mode 100644 server/sonar-web/src/main/js/components/store/globalMessages.js delete mode 100644 server/sonar-web/src/main/js/components/store/withStore.js create mode 100644 server/sonar-web/src/main/js/store/appState/duck.js create mode 100644 server/sonar-web/src/main/js/store/components/actions.js create mode 100644 server/sonar-web/src/main/js/store/components/reducer.js create mode 100644 server/sonar-web/src/main/js/store/favorites/duck.js create mode 100644 server/sonar-web/src/main/js/store/globalMessages/duck.js create mode 100644 server/sonar-web/src/main/js/store/languages/actions.js create mode 100644 server/sonar-web/src/main/js/store/languages/reducer.js create mode 100644 server/sonar-web/src/main/js/store/measures/actions.js create mode 100644 server/sonar-web/src/main/js/store/measures/reducer.js create mode 100644 server/sonar-web/src/main/js/store/rootActions.js create mode 100644 server/sonar-web/src/main/js/store/rootReducer.js create mode 100644 server/sonar-web/src/main/js/store/users/actions.js create mode 100644 server/sonar-web/src/main/js/store/users/reducer.js create mode 100644 server/sonar-web/src/main/js/store/utils/configureStore.js create mode 100644 server/sonar-web/src/main/js/store/utils/generalReducers.js create mode 100644 server/sonar-web/src/main/js/store/utils/withStore.js (limited to 'server/sonar-web/src/main/js') diff --git a/server/sonar-web/src/main/js/app/components/AdminContainer.js b/server/sonar-web/src/main/js/app/components/AdminContainer.js index 7ecbb77b2cd..728118fac90 100644 --- a/server/sonar-web/src/main/js/app/components/AdminContainer.js +++ b/server/sonar-web/src/main/js/app/components/AdminContainer.js @@ -20,7 +20,7 @@ import React from 'react'; import { connect } from 'react-redux'; import SettingsNav from './nav/settings/SettingsNav'; -import { getCurrentUser } from '../store/rootReducer'; +import { getCurrentUser } from '../../store/rootReducer'; import { isUserAdmin } from '../../helpers/users'; class AdminContainer extends React.Component { diff --git a/server/sonar-web/src/main/js/app/components/App.js b/server/sonar-web/src/main/js/app/components/App.js index 4c13709deaf..6ddad08119e 100644 --- a/server/sonar-web/src/main/js/app/components/App.js +++ b/server/sonar-web/src/main/js/app/components/App.js @@ -21,8 +21,8 @@ import React from 'react'; import { connect } from 'react-redux'; import GlobalLoading from './GlobalLoading'; -import { fetchCurrentUser } from '../store/users/actions'; -import { fetchLanguages, fetchAppState } from '../store/rootActions'; +import { fetchCurrentUser } from '../../store/users/actions'; +import { fetchLanguages, fetchAppState } from '../../store/rootActions'; class App extends React.Component { mounted: bool; diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooter.js b/server/sonar-web/src/main/js/app/components/GlobalFooter.js index 8d0e5472014..8ca593eb458 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooter.js +++ b/server/sonar-web/src/main/js/app/components/GlobalFooter.js @@ -21,7 +21,7 @@ import React from 'react'; import { Link } from 'react-router'; import { connect } from 'react-redux'; -import { getAppState } from '../store/rootReducer'; +import { getAppState } from '../../store/rootReducer'; class GlobalFooter extends React.Component { render () { diff --git a/server/sonar-web/src/main/js/app/components/GlobalMessagesContainer.js b/server/sonar-web/src/main/js/app/components/GlobalMessagesContainer.js index 6faf954d495..64d2ef040e3 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalMessagesContainer.js +++ b/server/sonar-web/src/main/js/app/components/GlobalMessagesContainer.js @@ -19,8 +19,8 @@ */ import { connect } from 'react-redux'; import GlobalMessages from '../../components/controls/GlobalMessages'; -import { getGlobalMessages } from '../store/rootReducer'; -import { closeGlobalMessage } from '../../components/store/globalMessages'; +import { getGlobalMessages } from '../../store/rootReducer'; +import { closeGlobalMessage } from '../../store/globalMessages/duck'; const mapStateToProps = state => ({ messages: getGlobalMessages(state) diff --git a/server/sonar-web/src/main/js/app/components/Landing.js b/server/sonar-web/src/main/js/app/components/Landing.js index 17074c24945..40ea3a3c8e6 100644 --- a/server/sonar-web/src/main/js/app/components/Landing.js +++ b/server/sonar-web/src/main/js/app/components/Landing.js @@ -21,7 +21,7 @@ import React from 'react'; import { withRouter } from 'react-router'; import { connect } from 'react-redux'; -import { getCurrentUser } from '../store/rootReducer'; +import { getCurrentUser } from '../../store/rootReducer'; class Landing extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/app/components/ProjectContainer.js b/server/sonar-web/src/main/js/app/components/ProjectContainer.js index 41eaec1e7db..8a6cc890eb8 100644 --- a/server/sonar-web/src/main/js/app/components/ProjectContainer.js +++ b/server/sonar-web/src/main/js/app/components/ProjectContainer.js @@ -20,8 +20,8 @@ import React from 'react'; import { connect } from 'react-redux'; import ComponentNav from './nav/component/ComponentNav'; -import { fetchProject } from '../store/rootActions'; -import { getComponent } from '../store/rootReducer'; +import { fetchProject } from '../../store/rootActions'; +import { getComponent } from '../../store/rootReducer'; class ProjectContainer extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js index e5ac6b7cbe6..46855693968 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js @@ -20,7 +20,7 @@ import React from 'react'; import { connect } from 'react-redux'; import Favorite from '../../../../components/controls/Favorite'; -import { getCurrentUser } from '../../../store/rootReducer'; +import { getCurrentUser } from '../../../../store/rootReducer'; class ComponentNavFavorite extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js index 01735c65a5a..7543197a7ae 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.js @@ -24,7 +24,7 @@ import GlobalNavMenu from './GlobalNavMenu'; import GlobalNavUser from './GlobalNavUser'; import GlobalNavSearch from './GlobalNavSearch'; import ShortcutsHelpView from './ShortcutsHelpView'; -import { getCurrentUser } from '../../../store/rootReducer'; +import { getCurrentUser } from '../../../../store/rootReducer'; class GlobalNav extends React.Component { componentDidMount () { diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js index b845eedfe58..9730f861f89 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavBranding.js @@ -20,7 +20,7 @@ import React from 'react'; import { Link } from 'react-router'; import { connect } from 'react-redux'; -import { getSettingValue, getCurrentUser } from '../../../store/rootReducer'; +import { getSettingValue, getCurrentUser } from '../../../../store/rootReducer'; import { translate } from '../../../../helpers/l10n'; class GlobalNavBranding extends React.Component { diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js index c4d6f7c385c..a0af8c4acd3 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavSearch.js @@ -21,7 +21,7 @@ import Backbone from 'backbone'; import React from 'react'; import { connect } from 'react-redux'; import SearchView from './SearchView'; -import { getCurrentUser } from '../../../store/rootReducer'; +import { getCurrentUser } from '../../../../store/rootReducer'; function contains (root, node) { while (node) { diff --git a/server/sonar-web/src/main/js/app/store/appState/duck.js b/server/sonar-web/src/main/js/app/store/appState/duck.js deleted file mode 100644 index cd313870e19..00000000000 --- a/server/sonar-web/src/main/js/app/store/appState/duck.js +++ /dev/null @@ -1,75 +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. - */ -// @flow -type AppState = { - authenticationError: boolean, - authorizationError: boolean, - qualifiers: ?Array -}; - -export type Action = { - type: string, - appState: AppState -} - -export const actions = { - SET_APP_STATE: 'SET_APP_STATE', - REQUIRE_AUTHENTICATION: 'REQUIRE_AUTHENTICATION', - REQUIRE_AUTHORIZATION: 'REQUIRE_AUTHORIZATION' -}; - -export const setAppState = (appState: AppState): Action => ({ - type: actions.SET_APP_STATE, - appState -}); - -export const requireAuthentication = () => ({ - type: actions.REQUIRE_AUTHENTICATION -}); - -export const requireAuthorization = () => ({ - type: actions.REQUIRE_AUTHORIZATION -}); - -const defaultValue = { - authenticationError: false, - authorizationError: false, - qualifiers: null -}; - -export default (state: AppState = defaultValue, action: Action) => { - if (action.type === actions.SET_APP_STATE) { - return { ...state, ...action.appState }; - } - - if (action.type === actions.REQUIRE_AUTHENTICATION) { - return { ...state, authenticationError: true }; - } - - if (action.type === actions.REQUIRE_AUTHORIZATION) { - return { ...state, authorizationError: true }; - } - - return state; -}; - -export const getRootQualifiers = (state: AppState) => ( - state.qualifiers -); diff --git a/server/sonar-web/src/main/js/app/store/components/actions.js b/server/sonar-web/src/main/js/app/store/components/actions.js deleted file mode 100644 index 3ba34eb2eb8..00000000000 --- a/server/sonar-web/src/main/js/app/store/components/actions.js +++ /dev/null @@ -1,25 +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. - */ -export const RECEIVE_COMPONENTS = 'RECEIVE_COMPONENTS'; - -export const receiveComponents = components => ({ - type: RECEIVE_COMPONENTS, - components -}); diff --git a/server/sonar-web/src/main/js/app/store/components/reducer.js b/server/sonar-web/src/main/js/app/store/components/reducer.js deleted file mode 100644 index c2d609a1066..00000000000 --- a/server/sonar-web/src/main/js/app/store/components/reducer.js +++ /dev/null @@ -1,47 +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 { combineReducers } from 'redux'; -import keyBy from 'lodash/keyBy'; -import uniq from 'lodash/uniq'; -import { RECEIVE_COMPONENTS } from './actions'; - -const byKey = (state = {}, action = {}) => { - if (action.type === RECEIVE_COMPONENTS) { - const changes = keyBy(action.components, 'key'); - return { ...state, ...changes }; - } - - return state; -}; - -const keys = (state = [], action = {}) => { - if (action.type === RECEIVE_COMPONENTS) { - const changes = action.components.map(f => f.key); - return uniq([...state, ...changes]); - } - - return state; -}; - -export default combineReducers({ byKey, keys }); - -export const getComponent = (state, key) => ( - state.byKey[key] -); diff --git a/server/sonar-web/src/main/js/app/store/favorites/duck.js b/server/sonar-web/src/main/js/app/store/favorites/duck.js deleted file mode 100644 index 7c6d4b52012..00000000000 --- a/server/sonar-web/src/main/js/app/store/favorites/duck.js +++ /dev/null @@ -1,63 +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 uniq from 'lodash/uniq'; -import without from 'lodash/without'; - -export const actions = { - RECEIVE_FAVORITES: 'RECEIVE_FAVORITES', - ADD_FAVORITE: 'ADD_FAVORITE', - REMOVE_FAVORITE: 'REMOVE_FAVORITE' -}; - -export const receiveFavorites = favorites => ({ - type: actions.RECEIVE_FAVORITES, - favorites -}); - -export const addFavorite = componentKey => ({ - type: actions.ADD_FAVORITE, - componentKey -}); - -export const removeFavorite = componentKey => ({ - type: actions.REMOVE_FAVORITE, - componentKey -}); - -export default (state = [], action = {}) => { - if (action.type === actions.RECEIVE_FAVORITES) { - return uniq([...state, ...action.favorites.map(f => f.key)]); - } - - if (action.type === actions.ADD_FAVORITE) { - return uniq([...state, action.componentKey]); - } - - if (action.type === actions.REMOVE_FAVORITE) { - return without(state, action.componentKey); - } - - return state; -}; - -export const isFavorite = (state, componentKey) => ( - state.includes(componentKey) -); - diff --git a/server/sonar-web/src/main/js/app/store/languages/actions.js b/server/sonar-web/src/main/js/app/store/languages/actions.js deleted file mode 100644 index 9d2d517acc2..00000000000 --- a/server/sonar-web/src/main/js/app/store/languages/actions.js +++ /dev/null @@ -1,25 +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. - */ -export const RECEIVE_LANGUAGES = 'RECEIVE_LANGUAGES'; - -export const receiveLanguages = languages => ({ - type: RECEIVE_LANGUAGES, - languages -}); diff --git a/server/sonar-web/src/main/js/app/store/languages/reducer.js b/server/sonar-web/src/main/js/app/store/languages/reducer.js deleted file mode 100644 index 73eb9d5f037..00000000000 --- a/server/sonar-web/src/main/js/app/store/languages/reducer.js +++ /dev/null @@ -1,35 +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 keyBy from 'lodash/keyBy'; -import { RECEIVE_LANGUAGES } from './actions'; - -const reducer = (state = {}, action = {}) => { - if (action.type === RECEIVE_LANGUAGES) { - return keyBy(action.languages, 'key'); - } - - return state; -}; - -export default reducer; - -export const getLanguages = state => ( - state -); diff --git a/server/sonar-web/src/main/js/app/store/measures/actions.js b/server/sonar-web/src/main/js/app/store/measures/actions.js deleted file mode 100644 index 2321163afd0..00000000000 --- a/server/sonar-web/src/main/js/app/store/measures/actions.js +++ /dev/null @@ -1,42 +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. - */ -export const RECEIVE_COMPONENT_MEASURE = 'RECEIVE_COMPONENT_MEASURE'; - -export const receiveComponentMeasure = (componentKey, metricKey, value) => ({ - type: RECEIVE_COMPONENT_MEASURE, - componentKey, - metricKey, - value -}); - -export const RECEIVE_COMPONENT_MEASURES = 'RECEIVE_COMPONENT_MEASURES'; - -export const receiveComponentMeasures = (componentKey, measures) => ({ - type: RECEIVE_COMPONENT_MEASURES, - componentKey, - measures -}); - -export const RECEIVE_COMPONENTS_MEASURES = 'RECEIVE_COMPONENTS_MEASURES'; - -export const receiveComponentsMeasures = componentsWithMeasures => ({ - type: RECEIVE_COMPONENTS_MEASURES, - componentsWithMeasures -}); diff --git a/server/sonar-web/src/main/js/app/store/measures/reducer.js b/server/sonar-web/src/main/js/app/store/measures/reducer.js deleted file mode 100644 index 3d166663836..00000000000 --- a/server/sonar-web/src/main/js/app/store/measures/reducer.js +++ /dev/null @@ -1,65 +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 { RECEIVE_COMPONENT_MEASURE, RECEIVE_COMPONENT_MEASURES, RECEIVE_COMPONENTS_MEASURES } from './actions'; - -const byMetricKey = (state = {}, action = {}) => { - if (action.type === RECEIVE_COMPONENT_MEASURE) { - return { ...state, [action.metricKey]: action.value }; - } - - if (action.type === RECEIVE_COMPONENT_MEASURES) { - return { ...state, ...action.measures }; - } - - return state; -}; - -const reducer = (state = {}, action = {}) => { - if ([RECEIVE_COMPONENT_MEASURE, RECEIVE_COMPONENT_MEASURES].includes(action.type)) { - const component = state[action.componentKey]; - return { ...state, [action.componentKey]: byMetricKey(component, action) }; - } - - if (action.type === RECEIVE_COMPONENTS_MEASURES) { - const newState = { ...state }; - Object.keys(action.componentsWithMeasures).forEach(componentKey => { - Object.assign(newState, { - [componentKey]: byMetricKey(state[componentKey], { - type: RECEIVE_COMPONENT_MEASURES, - measures: action.componentsWithMeasures[componentKey] - }) - }); - }); - return newState; - } - - return state; -}; - -export default reducer; - -export const getComponentMeasure = (state, componentKey, metricKey) => { - const component = state[componentKey]; - return component && component[metricKey]; -}; - -export const getComponentMeasures = (state, componentKey) => ( - state[componentKey] -); diff --git a/server/sonar-web/src/main/js/app/store/rootActions.js b/server/sonar-web/src/main/js/app/store/rootActions.js deleted file mode 100644 index b2e9500aefd..00000000000 --- a/server/sonar-web/src/main/js/app/store/rootActions.js +++ /dev/null @@ -1,77 +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 { getLanguages } from '../../api/languages'; -import { getGlobalNavigation, getComponentNavigation } from '../../api/nav'; -import * as auth from '../../api/auth'; -import { receiveLanguages } from './languages/actions'; -import { receiveComponents } from './components/actions'; -import { addGlobalErrorMessage } from '../../components/store/globalMessages'; -import { parseError } from '../../apps/code/utils'; -import { setAppState } from './appState/duck'; - -const onFail = dispatch => error => ( - parseError(error).then(message => dispatch(addGlobalErrorMessage(message))) -); - -export const fetchAppState = () => dispatch => ( - getGlobalNavigation().then( - appState => dispatch(setAppState(appState)), - onFail(dispatch) - ) -); - -export const fetchLanguages = () => dispatch => { - return getLanguages().then( - languages => dispatch(receiveLanguages(languages)), - onFail(dispatch) - ); -}; - -const addQualifier = project => ({ - ...project, - qualifier: project.breadcrumbs[project.breadcrumbs.length - 1].qualifier -}); - -export const fetchProject = key => dispatch => ( - getComponentNavigation(key).then( - component => dispatch(receiveComponents([addQualifier(component)])), - onFail(dispatch) - ) -); - -export const doLogin = (login, password) => dispatch => ( - auth.login(login, password).then( - () => { /* everything is fine */ }, - () => { - dispatch(addGlobalErrorMessage('Authentication failed')); - return Promise.reject(); - } - ) -); - -export const doLogout = () => dispatch => ( - auth.logout().then( - () => { /* everything is fine */ }, - () => { - dispatch(addGlobalErrorMessage('Logout failed')); - return Promise.reject(); - } - ) -); diff --git a/server/sonar-web/src/main/js/app/store/rootReducer.js b/server/sonar-web/src/main/js/app/store/rootReducer.js deleted file mode 100644 index b5cba2ff9bf..00000000000 --- a/server/sonar-web/src/main/js/app/store/rootReducer.js +++ /dev/null @@ -1,304 +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 { combineReducers } from 'redux'; -import appState from './appState/duck'; -import components, * as fromComponents from './components/reducer'; -import users, * as fromUsers from './users/reducer'; -import favorites, * as fromFavorites from './favorites/duck'; -import languages, * as fromLanguages from './languages/reducer'; -import measures, * as fromMeasures from './measures/reducer'; -import globalMessages, * as fromGlobalMessages from '../../components/store/globalMessages'; - -import measuresApp, * as fromMeasuresApp from '../../apps/component-measures/store/rootReducer'; -import permissionsApp, * as fromPermissionsApp from '../../apps/permissions/shared/store/rootReducer'; -import projectAdminApp, * as fromProjectAdminApp from '../../apps/project-admin/store/rootReducer'; -import projectsApp, * as fromProjectsApp from '../../apps/projects/store/reducer'; -import qualityGatesApp from '../../apps/quality-gates/store/rootReducer'; -import settingsApp, * as fromSettingsApp from '../../apps/settings/store/rootReducer'; - -export default combineReducers({ - appState, - components, - globalMessages, - favorites, - languages, - measures, - users, - - // apps - measuresApp, - permissionsApp, - projectAdminApp, - projectsApp, - qualityGatesApp, - settingsApp -}); - -export const getAppState = state => ( - state.appState -); - -export const getComponent = (state, key) => ( - fromComponents.getComponent(state.components, key) -); - -export const getGlobalMessages = state => ( - fromGlobalMessages.getGlobalMessages(state.globalMessages) -); - -export const getLanguages = (state, key) => ( - fromLanguages.getLanguages(state.languages, key) -); - -export const getCurrentUser = state => ( - fromUsers.getCurrentUser(state.users) -); - -export const isFavorite = (state, componentKey) => ( - fromFavorites.isFavorite(state.favorites, componentKey) -); - -export const getComponentMeasure = (state, componentKey, metricKey) => ( - fromMeasures.getComponentMeasure(state.measures, componentKey, metricKey) -); - -export const getComponentMeasures = (state, componentKey) => ( - fromMeasures.getComponentMeasures(state.measures, componentKey) -); - -export const getProjects = state => ( - fromProjectsApp.getProjects(state.projectsApp) -); - -export const getProjectsAppState = state => ( - fromProjectsApp.getState(state.projectsApp) -); - -export const getProjectsAppFacetByProperty = (state, property) => ( - fromProjectsApp.getFacetByProperty(state.projectsApp, property) -); - -export const getProjectsAppMaxFacetValue = state => ( - fromProjectsApp.getMaxFacetValue(state.projectsApp) -); - -export const getQualityGatesAppState = state => ( - state.qualityGatesApp -); - -export const getPermissionsAppUsers = state => ( - fromPermissionsApp.getUsers(state.permissionsApp) -); - -export const getPermissionsAppGroups = state => ( - fromPermissionsApp.getGroups(state.permissionsApp) -); - -export const isPermissionsAppLoading = state => ( - fromPermissionsApp.isLoading(state.permissionsApp) -); - -export const getPermissionsAppQuery = state => ( - fromPermissionsApp.getQuery(state.permissionsApp) -); - -export const getPermissionsAppFilter = state => ( - fromPermissionsApp.getFilter(state.permissionsApp) -); - -export const getPermissionsAppSelectedPermission = state => ( - fromPermissionsApp.getSelectedPermission(state.permissionsApp) -); - -export const getPermissionsAppError = state => ( - fromPermissionsApp.getError(state.permissionsApp) -); - -export const getSettingValue = (state, key) => ( - fromSettingsApp.getValue(state.settingsApp, key) -); - -export const getSettingsAppDefinition = (state, key) => ( - fromSettingsApp.getDefinition(state.settingsApp, key) -); - -export const getSettingsAppAllCategories = state => ( - fromSettingsApp.getAllCategories(state.settingsApp) -); - -export const getSettingsAppDefaultCategory = state => ( - fromSettingsApp.getDefaultCategory(state.settingsApp) -); - -export const getSettingsAppSettingsForCategory = (state, category) => ( - fromSettingsApp.getSettingsForCategory(state.settingsApp, category) -); - -export const getSettingsAppChangedValue = (state, key) => ( - fromSettingsApp.getChangedValue(state.settingsApp, key) -); - -export const isSettingsAppLoading = (state, key) => ( - fromSettingsApp.isLoading(state.settingsApp, key) -); - -export const getSettingsAppLicenseByKey = (state, key) => ( - fromSettingsApp.getLicenseByKey(state.settingsApp, key) -); - -export const getSettingsAppAllLicenseKeys = state => ( - fromSettingsApp.getAllLicenseKeys(state.settingsApp) -); - -export const getSettingsAppValidationMessage = (state, key) => ( - fromSettingsApp.getValidationMessage(state.settingsApp, key) -); - -export const getSettingsAppEncryptionState = state => ( - fromSettingsApp.getEncryptionState(state.settingsApp) -); - -export const getSettingsAppGlobalMessages = state => ( - fromSettingsApp.getGlobalMessages(state.settingsApp) -); - -export const getProjectAdminProfileByKey = (state, profileKey) => ( - fromProjectAdminApp.getProfileByKey(state.projectAdminApp, profileKey) -); - -export const getProjectAdminAllProfiles = state => ( - fromProjectAdminApp.getAllProfiles(state.projectAdminApp) -); - -export const getProjectAdminProjectProfiles = (state, projectKey) => ( - fromProjectAdminApp.getProjectProfiles(state.projectAdminApp, projectKey) -); - -export const getProjectAdminGateById = (state, gateId) => ( - fromProjectAdminApp.getGateById(state.projectAdminApp, gateId) -); - -export const getProjectAdminAllGates = state => ( - fromProjectAdminApp.getAllGates(state.projectAdminApp) -); - -export const getProjectAdminProjectGate = (state, projectKey) => ( - fromProjectAdminApp.getProjectGate(state.projectAdminApp, projectKey) -); - -export const getProjectAdminLinkById = (state, linkId) => ( - fromProjectAdminApp.getLinkById(state.projectAdminApp, linkId) -); - -export const getProjectAdminProjectLinks = (state, projectKey) => ( - fromProjectAdminApp.getProjectLinks(state.projectAdminApp, projectKey) -); - -export const getProjectAdminComponentByKey = (state, componentKey) => ( - fromProjectAdminApp.getComponentByKey(state.projectAdminApp, componentKey) -); - -export const getProjectAdminProjectModules = (state, projectKey) => ( - fromProjectAdminApp.getProjectModules(state.projectAdminApp, projectKey) -); - -export const getProjectAdminGlobalMessages = state => ( - fromProjectAdminApp.getGlobalMessages(state.projectAdminApp) -); - -export const getMeasuresAppComponent = state => ( - fromMeasuresApp.getComponent(state.measuresApp) -); - -export const getMeasuresAppAllMetrics = state => ( - fromMeasuresApp.getAllMetrics(state.measuresApp) -); - -export const getMeasuresAppDetailsMetric = state => ( - fromMeasuresApp.getDetailsMetric(state.measuresApp) -); - -export const getMeasuresAppDetailsMeasure = state => ( - fromMeasuresApp.getDetailsMeasure(state.measuresApp) -); - -export const getMeasuresAppDetailsSecondaryMeasure = state => ( - fromMeasuresApp.getDetailsSecondaryMeasure(state.measuresApp) -); - -export const getMeasuresAppDetailsPeriods = state => ( - fromMeasuresApp.getDetailsPeriods(state.measuresApp) -); - -export const isMeasuresAppFetching = state => ( - fromMeasuresApp.isFetching(state.measuresApp) -); - -export const getMeasuresAppList = state => ( - fromMeasuresApp.getList(state.measuresApp) -); - -export const getMeasuresAppListComponents = state => ( - fromMeasuresApp.getListComponents(state.measuresApp) -); - -export const getMeasuresAppListSelected = state => ( - fromMeasuresApp.getListSelected(state.measuresApp) -); - -export const getMeasuresAppListTotal = state => ( - fromMeasuresApp.getListTotal(state.measuresApp) -); - -export const getMeasuresAppListPageIndex = state => ( - fromMeasuresApp.getListPageIndex(state.measuresApp) -); - -export const getMeasuresAppTree = state => ( - fromMeasuresApp.getTree(state.measuresApp) -); - -export const getMeasuresAppTreeComponents = state => ( - fromMeasuresApp.getTreeComponents(state.measuresApp) -); - -export const getMeasuresAppTreeBreadcrumbs = state => ( - fromMeasuresApp.getTreeBreadcrumbs(state.measuresApp) -); - -export const getMeasuresAppTreeSelected = state => ( - fromMeasuresApp.getTreeSelected(state.measuresApp) -); - -export const getMeasuresAppTreeTotal = state => ( - fromMeasuresApp.getTreeTotal(state.measuresApp) -); - -export const getMeasuresAppTreePageIndex = state => ( - fromMeasuresApp.getTreePageIndex(state.measuresApp) -); - -export const getMeasuresAppHomeDomains = state => ( - fromMeasuresApp.getHomeDomains(state.measuresApp) -); - -export const getMeasuresAppHomePeriods = state => ( - fromMeasuresApp.getHomePeriods(state.measuresApp) -); diff --git a/server/sonar-web/src/main/js/app/store/users/actions.js b/server/sonar-web/src/main/js/app/store/users/actions.js deleted file mode 100644 index 71e055d6526..00000000000 --- a/server/sonar-web/src/main/js/app/store/users/actions.js +++ /dev/null @@ -1,31 +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 { getCurrentUser } from '../../../api/users'; - -export const RECEIVE_CURRENT_USER = 'RECEIVE_CURRENT_USER'; - -export const receiveCurrentUser = user => ({ - type: RECEIVE_CURRENT_USER, - user -}); - -export const fetchCurrentUser = () => dispatch => ( - getCurrentUser().then(user => dispatch(receiveCurrentUser(user))) -); diff --git a/server/sonar-web/src/main/js/app/store/users/reducer.js b/server/sonar-web/src/main/js/app/store/users/reducer.js deleted file mode 100644 index 03dd5f9df28..00000000000 --- a/server/sonar-web/src/main/js/app/store/users/reducer.js +++ /dev/null @@ -1,52 +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 { combineReducers } from 'redux'; -import uniq from 'lodash/uniq'; -import { RECEIVE_CURRENT_USER } from './actions'; - -const usersByLogin = (state = {}, action = {}) => { - if (action.type === RECEIVE_CURRENT_USER) { - return { ...state, [action.user.login]: action.user }; - } - - return state; -}; - -const userLogins = (state = [], action = {}) => { - if (action.type === RECEIVE_CURRENT_USER) { - return uniq([...state, action.user.login]); - } - - return state; -}; - -const currentUser = (state = null, action = {}) => { - if (action.type === RECEIVE_CURRENT_USER) { - return action.user; - } - - return state; -}; - -export default combineReducers({ usersByLogin, userLogins, currentUser }); - -export const getCurrentUser = state => ( - state.currentUser -); diff --git a/server/sonar-web/src/main/js/app/utils/getCurrentUserFromStore.js b/server/sonar-web/src/main/js/app/utils/getCurrentUserFromStore.js index b16ba492a00..82791c3306c 100644 --- a/server/sonar-web/src/main/js/app/utils/getCurrentUserFromStore.js +++ b/server/sonar-web/src/main/js/app/utils/getCurrentUserFromStore.js @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // @flow -import { getCurrentUser } from '../store/rootReducer'; +import { getCurrentUser } from '../../store/rootReducer'; // TODO remove my usages const getCurrentUserFromStore = () => { diff --git a/server/sonar-web/src/main/js/app/utils/getStore.js b/server/sonar-web/src/main/js/app/utils/getStore.js index 1fb1cad4e4f..010b0c581e9 100644 --- a/server/sonar-web/src/main/js/app/utils/getStore.js +++ b/server/sonar-web/src/main/js/app/utils/getStore.js @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // @flow -import configureStore from '../../components/store/configureStore'; -import rootReducer from '../store/rootReducer'; +import configureStore from '../../store/utils/configureStore'; +import rootReducer from '../../store/rootReducer'; let store; diff --git a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js index 566434f196c..453c970a69d 100644 --- a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js +++ b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthentication.js @@ -20,7 +20,7 @@ // @flow import getStore from './getStore'; import getHistory from './getHistory'; -import { requireAuthentication } from '../store/appState/duck'; +import { requireAuthentication } from '../../store/appState/duck'; export default () => { const store = getStore(); diff --git a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js index b8664b312df..095d2f53f5a 100644 --- a/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js +++ b/server/sonar-web/src/main/js/app/utils/handleRequiredAuthorization.js @@ -20,7 +20,7 @@ // @flow import getStore from './getStore'; import getHistory from './getHistory'; -import { requireAuthorization } from '../store/appState/duck'; +import { requireAuthorization } from '../../store/appState/duck'; export default () => { const store = getStore(); diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutApp.js b/server/sonar-web/src/main/js/apps/about/components/AboutApp.js index dae2e6c8158..e95674f2c6b 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutApp.js +++ b/server/sonar-web/src/main/js/apps/about/components/AboutApp.js @@ -31,7 +31,7 @@ import AboutScanners from './AboutScanners'; import { translate } from '../../../helpers/l10n'; import { searchProjects } from '../../../api/components'; import { getFacet } from '../../../api/issues'; -import { getSettingValue } from '../../../app/store/rootReducer'; +import { getSettingValue } from '../../../store/rootReducer'; import * as settingsAPI from '../../../api/settings'; import '../styles.css'; diff --git a/server/sonar-web/src/main/js/apps/account/components/Account.js b/server/sonar-web/src/main/js/apps/account/components/Account.js index 0606d1aef61..633a6da2275 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Account.js +++ b/server/sonar-web/src/main/js/apps/account/components/Account.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import Nav from './Nav'; import UserCard from './UserCard'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; import '../account.css'; class Account extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/account/components/Security.js b/server/sonar-web/src/main/js/apps/account/components/Security.js index 9accad023f5..f229aae9936 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Security.js +++ b/server/sonar-web/src/main/js/apps/account/components/Security.js @@ -23,7 +23,7 @@ import Helmet from 'react-helmet'; import Password from './Password'; import Tokens from './Tokens'; import { translate } from '../../../helpers/l10n'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; class Security extends React.Component { render () { diff --git a/server/sonar-web/src/main/js/apps/account/profile/Profile.js b/server/sonar-web/src/main/js/apps/account/profile/Profile.js index 776b328676e..3d3213b7ea2 100644 --- a/server/sonar-web/src/main/js/apps/account/profile/Profile.js +++ b/server/sonar-web/src/main/js/apps/account/profile/Profile.js @@ -22,7 +22,7 @@ import { connect } from 'react-redux'; import UserExternalIdentity from './UserExternalIdentity'; import UserGroups from './UserGroups'; import UserScmAccounts from './UserScmAccounts'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; class Profile extends React.Component { render () { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js index 94c5459e0fd..d94951e32c7 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js @@ -31,7 +31,7 @@ import Tasks from '../components/Tasks'; import { getTypes, getActivity, getStatus, cancelAllTasks, cancelTask as cancelTaskAPI } from '../../../api/ce'; import { updateTask, mapFiltersToParameters } from '../utils'; import { Task } from '../types'; -import { getComponent } from '../../../app/store/rootReducer'; +import { getComponent } from '../../../store/rootReducer'; import '../background-tasks.css'; class BackgroundTasksApp extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/code/components/App.js b/server/sonar-web/src/main/js/apps/code/components/App.js index 4e27e90e015..7e265b23692 100644 --- a/server/sonar-web/src/main/js/apps/code/components/App.js +++ b/server/sonar-web/src/main/js/apps/code/components/App.js @@ -27,7 +27,7 @@ import Search from './Search'; import ListFooter from '../../../components/controls/ListFooter'; import { retrieveComponentChildren, retrieveComponent, loadMoreChildren, parseError } from '../utils'; import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket'; -import { getComponent } from '../../../app/store/rootReducer'; +import { getComponent } from '../../../store/rootReducer'; import '../code.css'; class App extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js b/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js index 4ca3376c3b0..3c08036cb91 100644 --- a/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/component-issues/components/ComponentIssuesAppContainer.js @@ -20,7 +20,7 @@ import React from 'react'; import init from '../init'; import { connect } from 'react-redux'; -import { getComponent, getCurrentUser } from '../../../app/store/rootReducer'; +import { getComponent, getCurrentUser } from '../../../store/rootReducer'; class ComponentIssuesAppContainer extends React.Component { componentDidMount () { diff --git a/server/sonar-web/src/main/js/apps/component-measures/app/AppContainer.js b/server/sonar-web/src/main/js/apps/component-measures/app/AppContainer.js index 5c1f09eaf63..cd26bb8f63e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/app/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/app/AppContainer.js @@ -20,7 +20,7 @@ import { connect } from 'react-redux'; import App from './App'; import { fetchMetrics, setComponent } from './actions'; -import { getComponent, getMeasuresAppAllMetrics } from '../../../app/store/rootReducer'; +import { getComponent, getMeasuresAppAllMetrics } from '../../../store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ component: getComponent(state, ownProps.location.query.id), diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/MeasureBubbleChartContainer.js b/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/MeasureBubbleChartContainer.js index 029cee95b55..00534a6331c 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/MeasureBubbleChartContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/bubbleChart/MeasureBubbleChartContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import MeasureBubbleChart from './BubbleChart'; -import { getMeasuresAppAllMetrics, getMeasuresAppComponent } from '../../../../app/store/rootReducer'; +import { getMeasuresAppAllMetrics, getMeasuresAppComponent } from '../../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js index 055ce5225e3..b569c01636b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js @@ -27,7 +27,7 @@ import { getMeasuresAppDetailsSecondaryMeasure, getMeasuresAppDetailsPeriods , getMeasuresAppComponent -} from '../../../app/store/rootReducer'; +} from '../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/actions.js b/server/sonar-web/src/main/js/apps/component-measures/details/actions.js index 608c7e2b97c..a7523787d22 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/actions.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/actions.js @@ -19,7 +19,7 @@ */ import { getMeasuresAndMeta } from '../../../api/measures'; import { enhanceWithLeak } from '../utils'; -import { getMeasuresAppComponent, getMeasuresAppAllMetrics } from '../../../app/store/rootReducer'; +import { getMeasuresAppComponent, getMeasuresAppAllMetrics } from '../../../store/rootReducer'; /* * Actions diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js index d982d7aef88..57d20b41a46 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListViewContainer.js @@ -29,7 +29,7 @@ import { getMeasuresAppDetailsMetric, isMeasuresAppFetching , getMeasuresAppComponent -} from '../../../../app/store/rootReducer'; +} from '../../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js index 114b9ef08e2..cb5e2a0e76b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeViewContainer.js @@ -38,7 +38,7 @@ import { getMeasuresAppDetailsMetric, isMeasuresAppFetching , getMeasuresAppComponent -} from '../../../../app/store/rootReducer'; +} from '../../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistoryContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistoryContainer.js index b70189eedb5..d60569a17c2 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistoryContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistoryContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import MeasureHistory from './MeasureHistory'; -import { getMeasuresAppDetailsMetric, getMeasuresAppComponent } from '../../../../app/store/rootReducer'; +import { getMeasuresAppDetailsMetric, getMeasuresAppComponent } from '../../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemapContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemapContainer.js index e24858b82e3..2a040d7b0c2 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemapContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/treemap/MeasureTreemapContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import MeasureTreemap from './MeasureTreemap'; -import { getMeasuresAppDetailsMetric, getMeasuresAppComponent } from '../../../../app/store/rootReducer'; +import { getMeasuresAppDetailsMetric, getMeasuresAppComponent } from '../../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresContainer.js b/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresContainer.js index d02d06bfcc3..b690cf7e21c 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/AllMeasuresContainer.js @@ -23,7 +23,7 @@ import { getMeasuresAppHomeDomains, getMeasuresAppHomePeriods, getMeasuresAppComponent -} from '../../../app/store/rootReducer'; +} from '../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasuresContainer.js b/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasuresContainer.js index 53094eb9bc7..858b09dbe1e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasuresContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/DomainMeasuresContainer.js @@ -23,7 +23,7 @@ import { getMeasuresAppHomeDomains, getMeasuresAppHomePeriods, getMeasuresAppComponent -} from '../../../app/store/rootReducer'; +} from '../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/HomeContainer.js b/server/sonar-web/src/main/js/apps/component-measures/home/HomeContainer.js index 58e3285c181..9c16840b0c1 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/HomeContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/HomeContainer.js @@ -25,7 +25,7 @@ import { getMeasuresAppHomeDomains, getMeasuresAppHomePeriods, getMeasuresAppComponent -} from '../../../app/store/rootReducer'; +} from '../../../store/rootReducer'; const mapStateToProps = state => { return { diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/actions.js b/server/sonar-web/src/main/js/apps/component-measures/home/actions.js index 006d4680523..04a2f11da5c 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/actions.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/actions.js @@ -21,7 +21,7 @@ import { startFetching, stopFetching } from '../store/statusActions'; import { getMeasuresAndMeta } from '../../../api/measures'; import { getLeakPeriod } from '../../../helpers/periods'; import { getLeakValue } from '../utils'; -import { getMeasuresAppComponent, getMeasuresAppAllMetrics } from '../../../app/store/rootReducer'; +import { getMeasuresAppComponent, getMeasuresAppAllMetrics } from '../../../store/rootReducer'; export const RECEIVE_MEASURES = 'measuresApp/home/RECEIVE_MEASURES'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/store/listViewActions.js b/server/sonar-web/src/main/js/apps/component-measures/store/listViewActions.js index 1f48656bfb8..857c82b41c1 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/store/listViewActions.js +++ b/server/sonar-web/src/main/js/apps/component-measures/store/listViewActions.js @@ -21,7 +21,7 @@ import { getComponentTree } from '../../../api/components'; import { enhanceWithMeasure } from '../utils'; import { startFetching, stopFetching } from './statusActions'; import complementary from '../config/complementary'; -import { getMeasuresAppList } from '../../../app/store/rootReducer'; +import { getMeasuresAppList } from '../../../store/rootReducer'; export const UPDATE_STORE = 'measuresApp/drilldown/list/UPDATE_STORE'; diff --git a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js index 81d2896c9d8..5697f7a2a79 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js +++ b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js @@ -23,7 +23,7 @@ import { getComponentTree } from '../../../api/components'; import { enhanceWithMeasure } from '../utils'; import { startFetching, stopFetching } from './statusActions'; import complementary from '../config/complementary'; -import { getMeasuresAppTree } from '../../../app/store/rootReducer'; +import { getMeasuresAppTree } from '../../../store/rootReducer'; /* * Actions diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js b/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js index ad4b91936c6..3eb2a0b1db2 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js @@ -20,7 +20,7 @@ import React from 'react'; import { connect } from 'react-redux'; import init from '../init'; -import { getComponent } from '../../../app/store/rootReducer'; +import { getComponent } from '../../../store/rootReducer'; class CustomMeasuresAppContainer extends React.Component { componentDidMount () { diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesAppContainer.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesAppContainer.js index 4d5c56374ef..b33d4907d2a 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesAppContainer.js @@ -20,7 +20,7 @@ import React from 'react'; import { connect } from 'react-redux'; import init from '../init'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; class IssuesAppContainer extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/apps/overview/components/AppContainer.js b/server/sonar-web/src/main/js/apps/overview/components/AppContainer.js index e697ff24c18..814390fbf37 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/overview/components/AppContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import App from './App'; -import { getComponent } from '../../../app/store/rootReducer'; +import { getComponent } from '../../../store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ component: getComponent(state, ownProps.location.query.id) diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js index 0530d58e218..8cdeb817cf1 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js @@ -24,7 +24,7 @@ import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../helpers/urls'; import { searchRules } from '../../../api/rules'; -import { getLanguages } from '../../../app/store/rootReducer'; +import { getLanguages } from '../../../store/rootReducer'; class MetaQualityProfiles extends React.Component { state = { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/AppContainer.js b/server/sonar-web/src/main/js/apps/permission-templates/components/AppContainer.js index 48ca02edbd8..e00ff5087b6 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/AppContainer.js @@ -19,8 +19,8 @@ */ import { connect } from 'react-redux'; import App from './App'; -import { getAppState } from '../../../app/store/rootReducer'; -import { getRootQualifiers } from '../../../app/store/appState/duck'; +import { getAppState } from '../../../store/rootReducer'; +import { getRootQualifiers } from '../../../store/appState/duck'; const mapStateToProps = state => ({ topQualifiers: getRootQualifiers(getAppState(state)) diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js index c22c27d9ec0..1639f5cb6c3 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.js @@ -27,7 +27,7 @@ import SearchForm from '../../permissions/shared/components/SearchForm'; import { PERMISSIONS_ORDER_FOR_PROJECT } from '../../permissions/project/constants'; import * as api from '../../../api/permissions'; import { translate } from '../../../helpers/l10n'; -import withStore from '../../../components/store/withStore'; +import withStore from '../../../store/utils/withStore'; class Template extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js index 56343415027..dd781c3cd25 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js @@ -38,7 +38,7 @@ import { getPermissionsAppQuery, getPermissionsAppFilter, getPermissionsAppSelectedPermission -} from '../../../../app/store/rootReducer'; +} from '../../../../store/rootReducer'; const PERMISSIONS_ORDER = [ 'admin', diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js index 299de992836..260c26c9ea0 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { translate } from '../../../../helpers/l10n'; import { loadHolders } from '../store/actions'; -import { isPermissionsAppLoading } from '../../../../app/store/rootReducer'; +import { isPermissionsAppLoading } from '../../../../store/rootReducer'; class PageHeader extends React.Component { static propTypes = { 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 207a0cf7e0a..eb2021a3b19 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 @@ -35,7 +35,7 @@ import { getPermissionsAppQuery, getPermissionsAppFilter, getPermissionsAppSelectedPermission -} from '../../../../app/store/rootReducer'; +} from '../../../../store/rootReducer'; export const loadHolders = () => (dispatch, getState) => { const query = getPermissionsAppQuery(getState()); diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js index 63b041b2fcf..dabcf13e564 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js @@ -39,7 +39,7 @@ import { getPermissionsAppQuery, getPermissionsAppFilter, getPermissionsAppSelectedPermission -} from '../../../../app/store/rootReducer'; +} from '../../../../store/rootReducer'; class AllHoldersList extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js index c7657ddcc51..16e9f10db80 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js @@ -22,7 +22,7 @@ import { connect } from 'react-redux'; import PageHeader from './PageHeader'; import AllHoldersList from './AllHoldersList'; import PageError from '../../shared/components/PageError'; -import { getComponent, getCurrentUser } from '../../../../app/store/rootReducer'; +import { getComponent, getCurrentUser } from '../../../../store/rootReducer'; import '../../styles.css'; // TODO helmet diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js index 456a16cf7a3..700b2b48ea3 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js @@ -22,7 +22,7 @@ import { connect } from 'react-redux'; import { translate } from '../../../../helpers/l10n'; import ApplyTemplateView from '../views/ApplyTemplateView'; import { loadHolders } from '../store/actions'; -import { isPermissionsAppLoading } from '../../../../app/store/rootReducer'; +import { isPermissionsAppLoading } from '../../../../store/rootReducer'; import { isUserAdmin } from '../../../../helpers/users'; class PageHeader extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js index b705876a6a2..1982d34ea05 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js @@ -35,7 +35,7 @@ import { getPermissionsAppQuery, getPermissionsAppFilter, getPermissionsAppSelectedPermission -} from '../../../../app/store/rootReducer'; +} from '../../../../store/rootReducer'; export const loadHolders = projectKey => (dispatch, getState) => { const query = getPermissionsAppQuery(getState()); diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js b/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js index 289a6c196a0..e5fb83bfc38 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js @@ -19,7 +19,7 @@ */ import React from 'react'; import { connect } from 'react-redux'; -import { getPermissionsAppError } from '../../../../app/store/rootReducer'; +import { getPermissionsAppError } from '../../../../store/rootReducer'; class PageError extends React.Component { static propTypes = { 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 0fd141962aa..b609589522d 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 @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import Header from './Header'; import Form from './Form'; -import { getComponent } from '../../../app/store/rootReducer'; +import { getComponent } from '../../../store/rootReducer'; class Deletion extends React.Component { static propTypes = { 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 4bc8050a464..a740ededa6c 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 @@ -28,7 +28,7 @@ import { addGlobalErrorMessage, addGlobalSuccessMessage, closeAllGlobalMessages -} from '../../../components/store/globalMessages'; +} from '../../../store/globalMessages/duck'; import { reloadUpdateKeyPage } from './utils'; import RecentHistory from '../../../app/components/nav/component/RecentHistory'; 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 7b4c04846bb..c8256ced455 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 @@ -30,11 +30,11 @@ import { addGlobalErrorMessage, closeAllGlobalMessages, addGlobalSuccessMessage -} from '../../../components/store/globalMessages'; +} from '../../../store/globalMessages/duck'; import { parseError } from '../../code/utils'; import { reloadUpdateKeyPage } from './utils'; import RecentHistory from '../../../app/components/nav/component/RecentHistory'; -import { getProjectAdminProjectModules, getComponent } from '../../../app/store/rootReducer'; +import { getProjectAdminProjectModules, getComponent } from '../../../store/rootReducer'; class Key extends React.Component { static propTypes = { 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 d1e611c87c4..f3d3c36991e 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 @@ -28,7 +28,7 @@ import { deleteProjectLink, createProjectLink } from '../store/actions'; -import { getProjectAdminProjectLinks, getComponent } from '../../../app/store/rootReducer'; +import { getProjectAdminProjectLinks, getComponent } from '../../../store/rootReducer'; class Links extends React.Component { static propTypes = { 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 50eabdecb47..7dcd84df403 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,7 +23,7 @@ import shallowCompare from 'react-addons-shallow-compare'; import Header from './Header'; import Form from './Form'; import { fetchProjectGate, setProjectGate } from '../store/actions'; -import { getProjectAdminAllGates, getProjectAdminProjectGate, getComponent } from '../../../app/store/rootReducer'; +import { getProjectAdminAllGates, getProjectAdminProjectGate, getComponent } from '../../../store/rootReducer'; class QualityGate extends React.Component { static propTypes = { 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 5d4263cf6eb..591ede496bc 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 @@ -27,7 +27,7 @@ import { getProjectAdminAllProfiles, getProjectAdminProjectProfiles, getComponent -} from '../../../app/store/rootReducer'; +} from '../../../store/rootReducer'; class QualityProfiles extends React.Component { static propTypes = { 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 b5c3c1a5f21..eafbd8853ae 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 @@ -26,9 +26,9 @@ import { } from '../../../api/quality-gates'; import { getProjectLinks, createLink } from '../../../api/projectLinks'; import { getTree, changeKey as changeKeyApi } from '../../../api/components'; -import { addGlobalSuccessMessage } from '../../../components/store/globalMessages'; +import { addGlobalSuccessMessage } from '../../../store/globalMessages/duck'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { getProjectAdminProfileByKey } from '../../../app/store/rootReducer'; +import { getProjectAdminProfileByKey } from '../../../store/rootReducer'; export const RECEIVE_PROFILES = 'projectAdmin/RECEIVE_PROFILES'; export const receiveProfiles = profiles => ({ 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 a5c56087ce9..1a49d87e3e0 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 @@ -35,7 +35,7 @@ import modulesByProject, { } from './modulesByProject'; import globalMessages, { getGlobalMessages as nextGetGlobalMessages -} from '../../../components/store/globalMessages'; +} from '../../../store/globalMessages/duck'; const rootReducer = combineReducers({ profiles, diff --git a/server/sonar-web/src/main/js/apps/projects-admin/AppContainer.js b/server/sonar-web/src/main/js/apps/projects-admin/AppContainer.js index 11eb059ad02..ebf5317536f 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/AppContainer.js @@ -20,8 +20,8 @@ import React from 'react'; import { connect } from 'react-redux'; import Main from './main'; -import { getCurrentUser, getAppState } from '../../app/store/rootReducer'; -import { getRootQualifiers } from '../../app/store/appState/duck'; +import { getCurrentUser, getAppState } from '../../store/rootReducer'; +import { getRootQualifiers } from '../../store/appState/duck'; class AppContainer extends React.Component { render () { diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjectsContainer.js b/server/sonar-web/src/main/js/apps/projects/components/AllProjectsContainer.js index d003248d72c..60dafe9a7e4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjectsContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjectsContainer.js @@ -20,7 +20,7 @@ import { connect } from 'react-redux'; import AllProjects from './AllProjects'; import { fetchProjects } from '../store/actions'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; const mapStateToProps = state => ({ user: getCurrentUser(state), diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilterContainer.js b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilterContainer.js index c6437cf58f9..01555a84f6f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilterContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import FavoriteFilter from './FavoriteFilter'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; const mapStateToProps = state => ({ user: getCurrentUser(state) diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteProjectsContainer.js b/server/sonar-web/src/main/js/apps/projects/components/FavoriteProjectsContainer.js index 3e383549f3e..567388b3af5 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteProjectsContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteProjectsContainer.js @@ -20,7 +20,7 @@ import { connect } from 'react-redux'; import AllProjects from './AllProjects'; import { fetchProjects } from '../store/actions'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; const mapStateToProps = state => ({ user: getCurrentUser(state), diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeaderContainer.js b/server/sonar-web/src/main/js/apps/projects/components/PageHeaderContainer.js index fe8c6fd6043..c1400cd6cf9 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeaderContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeaderContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import PageHeader from './PageHeader'; -import { getProjectsAppState } from '../../../app/store/rootReducer'; +import { getProjectsAppState } from '../../../store/rootReducer'; export default connect( state => getProjectsAppState(state) diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js index e260f56ca15..87e4447ae54 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import ProjectCard from './ProjectCard'; -import { getComponent, getComponentMeasures } from '../../../app/store/rootReducer'; +import { getComponent, getComponentMeasures } from '../../../store/rootReducer'; export default connect( (state, ownProps) => ({ diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.js index f91571ab8c3..53f29902449 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.js @@ -20,7 +20,7 @@ import React from 'react'; import sortBy from 'lodash/sortBy'; import { connect } from 'react-redux'; -import { getLanguages } from '../../../app/store/rootReducer'; +import { getLanguages } from '../../../store/rootReducer'; import { translate } from '../../../helpers/l10n'; class ProjectCardLanguages extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsListContainer.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectsListContainer.js index 3bbd31c3280..37f627b4da1 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsListContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsListContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import ProjectsList from './ProjectsList'; -import { getProjects, getProjectsAppState } from '../../../app/store/rootReducer'; +import { getProjects, getProjectsAppState } from '../../../store/rootReducer'; export default connect( state => ({ diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsListFooterContainer.js b/server/sonar-web/src/main/js/apps/projects/components/ProjectsListFooterContainer.js index 210b4312b9c..1e22e34a92d 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsListFooterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsListFooterContainer.js @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { connect } from 'react-redux'; -import { getProjects, getProjectsAppState } from '../../../app/store/rootReducer'; +import { getProjects, getProjectsAppState } from '../../../store/rootReducer'; import { fetchMoreProjects } from '../store/actions'; import ProjectsListFooter from './ProjectsListFooter'; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js b/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js index e943a6b2847..c753e163909 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js +++ b/server/sonar-web/src/main/js/apps/projects/filters/FilterContainer.js @@ -22,7 +22,7 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import omitBy from 'lodash/omitBy'; import isNil from 'lodash/isNil'; -import { getProjectsAppFacetByProperty, getProjectsAppMaxFacetValue } from '../../../app/store/rootReducer'; +import { getProjectsAppFacetByProperty, getProjectsAppMaxFacetValue } from '../../../store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ value: ownProps.query[ownProps.property], diff --git a/server/sonar-web/src/main/js/apps/projects/store/actions.js b/server/sonar-web/src/main/js/apps/projects/store/actions.js index d14f38e08c8..5a6f5affdec 100644 --- a/server/sonar-web/src/main/js/apps/projects/store/actions.js +++ b/server/sonar-web/src/main/js/apps/projects/store/actions.js @@ -19,16 +19,16 @@ */ import groupBy from 'lodash/groupBy'; import { searchProjects } from '../../../api/components'; -import { addGlobalErrorMessage } from '../../../components/store/globalMessages'; +import { addGlobalErrorMessage } from '../../../store/globalMessages/duck'; import { parseError } from '../../code/utils'; -import { receiveComponents } from '../../../app/store/components/actions'; +import { receiveComponents } from '../../../store/components/actions'; import { receiveProjects, receiveMoreProjects } from './projectsDuck'; import { updateState } from './stateDuck'; -import { getProjectsAppState } from '../../../app/store/rootReducer'; +import { getProjectsAppState } from '../../../store/rootReducer'; import { getMeasuresForProjects } from '../../../api/measures'; -import { receiveComponentsMeasures } from '../../../app/store/measures/actions'; +import { receiveComponentsMeasures } from '../../../store/measures/actions'; import { convertToFilter } from './utils'; -import { receiveFavorites } from '../../../app/store/favorites/duck'; +import { receiveFavorites } from '../../../store/favorites/duck'; const PAGE_SIZE = 50; diff --git a/server/sonar-web/src/main/js/apps/projects/store/facetsDuck.js b/server/sonar-web/src/main/js/apps/projects/store/facetsDuck.js index 9a12aa620bf..0f7fbf95005 100644 --- a/server/sonar-web/src/main/js/apps/projects/store/facetsDuck.js +++ b/server/sonar-web/src/main/js/apps/projects/store/facetsDuck.js @@ -19,7 +19,7 @@ */ import flatMap from 'lodash/flatMap'; import sumBy from 'lodash/sumBy'; -import { createMap } from '../../../components/store/generalReducers'; +import { createMap } from '../../../store/utils/generalReducers'; import { actions } from './projectsDuck'; import { mapMetricToProperty } from './utils'; diff --git a/server/sonar-web/src/main/js/apps/projects/store/stateDuck.js b/server/sonar-web/src/main/js/apps/projects/store/stateDuck.js index d74a8f910ff..772a6467ffc 100644 --- a/server/sonar-web/src/main/js/apps/projects/store/stateDuck.js +++ b/server/sonar-web/src/main/js/apps/projects/store/stateDuck.js @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { createValue } from '../../../components/store/generalReducers'; +import { createValue } from '../../../store/utils/generalReducers'; export const actions = { UPDATE_STATE: 'projects/UPDATE_STATE' diff --git a/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js b/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js index ae53d592b69..a134c697572 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js @@ -30,7 +30,7 @@ import { saveCondition } from '../store/actions'; import Details from '../components/Details'; -import { getQualityGatesAppState } from '../../../app/store/rootReducer'; +import { getQualityGatesAppState } from '../../../store/rootReducer'; const mapStateToProps = state => ( getQualityGatesAppState(state) diff --git a/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js b/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js index 4eaf763bb2b..033660a7f38 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js @@ -21,7 +21,7 @@ import { connect } from 'react-redux'; import { setState, addQualityGate, deleteQualityGate } from '../store/actions'; import QualityGateApp from '../components/QualityGatesApp'; -import { getQualityGatesAppState } from '../../../app/store/rootReducer'; +import { getQualityGatesAppState } from '../../../store/rootReducer'; const mapStateToProps = state => ( getQualityGatesAppState(state) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js index 8d0749f0fc8..95197769f90 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import App from './App'; -import { getLanguages, getCurrentUser } from '../../../app/store/rootReducer'; +import { getLanguages, getCurrentUser } from '../../../store/rootReducer'; export default connect( state => ({ diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js b/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js index f3171181aed..15f6822e766 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginFormContainer.js @@ -21,8 +21,8 @@ import React from 'react'; import { connect } from 'react-redux'; import LoginForm from './LoginForm'; -import { doLogin } from '../../../app/store/rootActions'; -import { getAppState } from '../../../app/store/rootReducer'; +import { doLogin } from '../../../store/rootActions'; +import { getAppState } from '../../../store/rootReducer'; import { getIdentityProviders } from '../../../api/users'; class LoginFormContainer extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/sessions/components/Logout.js b/server/sonar-web/src/main/js/apps/sessions/components/Logout.js index 409a099aa18..e234f4a9a48 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/Logout.js +++ b/server/sonar-web/src/main/js/apps/sessions/components/Logout.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import GlobalMessagesContainer from '../../../app/components/GlobalMessagesContainer'; -import { doLogout } from '../../../app/store/rootActions'; +import { doLogout } from '../../../store/rootActions'; class Logout extends React.Component { componentDidMount () { diff --git a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.js b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.js index 96fccd0abfe..4ef1a719f59 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.js +++ b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import CategoriesList from './CategoriesList'; -import { getSettingsAppAllCategories } from '../../../app/store/rootReducer'; +import { getSettingsAppAllCategories } from '../../../store/rootReducer'; class AllCategoriesList extends React.Component { render () { diff --git a/server/sonar-web/src/main/js/apps/settings/components/App.js b/server/sonar-web/src/main/js/apps/settings/components/App.js index 1ff0e46f97b..9a55ff3b008 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/App.js +++ b/server/sonar-web/src/main/js/apps/settings/components/App.js @@ -26,7 +26,7 @@ import CategoryDefinitionsList from './CategoryDefinitionsList'; import AllCategoriesList from './AllCategoriesList'; import WildcardsHelp from './WildcardsHelp'; import { fetchSettings } from '../store/actions'; -import { getSettingsAppDefaultCategory } from '../../../app/store/rootReducer'; +import { getSettingsAppDefaultCategory } from '../../../store/rootReducer'; import '../styles.css'; type Props = { diff --git a/server/sonar-web/src/main/js/apps/settings/components/AppContainer.js b/server/sonar-web/src/main/js/apps/settings/components/AppContainer.js index 288129ff5ec..3fdd465309b 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/settings/components/AppContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import App from './App'; -import { getComponent } from '../../../app/store/rootReducer'; +import { getComponent } from '../../../store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ component: ownProps.location.query.id ? getComponent(state, ownProps.location.query.id) : undefined diff --git a/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.js b/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.js index 510cffb443a..49ebc13ded1 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.js +++ b/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import SubCategoryDefinitionsList from './SubCategoryDefinitionsList'; -import { getSettingsAppSettingsForCategory } from '../../../app/store/rootReducer'; +import { getSettingsAppSettingsForCategory } from '../../../store/rootReducer'; class CategoryDefinitionsList extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/settings/components/Definition.js b/server/sonar-web/src/main/js/apps/settings/components/Definition.js index 0aa95078681..7f607de7f78 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/Definition.js +++ b/server/sonar-web/src/main/js/apps/settings/components/Definition.js @@ -35,7 +35,7 @@ import { getSettingsAppChangedValue, isSettingsAppLoading, getSettingsAppValidationMessage -} from '../../../app/store/rootReducer'; +} from '../../../store/rootReducer'; class Definition extends React.Component { mounted: boolean; diff --git a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js index 3b236e0d52b..1af5a0a8014 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js +++ b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.js @@ -22,7 +22,7 @@ import { connect } from 'react-redux'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { sendTestEmail } from '../../../api/settings'; import { parseError } from '../../code/utils'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; class EmailForm extends React.Component { constructor (props) { diff --git a/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionAppContainer.js b/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionAppContainer.js index 0dd8e051b67..3883c8b9f40 100644 --- a/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionAppContainer.js +++ b/server/sonar-web/src/main/js/apps/settings/encryption/EncryptionAppContainer.js @@ -20,7 +20,7 @@ import { connect } from 'react-redux'; import EncryptionApp from './EncryptionApp'; import { checkSecretKey, generateSecretKey, encryptValue, startGeneration } from '../store/encryptionPage/actions'; -import { getSettingsAppEncryptionState } from '../../../app/store/rootReducer'; +import { getSettingsAppEncryptionState } from '../../../store/rootReducer'; export default connect( state => getSettingsAppEncryptionState(state), diff --git a/server/sonar-web/src/main/js/apps/settings/licenses/LicenseRowContainer.js b/server/sonar-web/src/main/js/apps/settings/licenses/LicenseRowContainer.js index 0b8fefd5c39..38eae34bea4 100644 --- a/server/sonar-web/src/main/js/apps/settings/licenses/LicenseRowContainer.js +++ b/server/sonar-web/src/main/js/apps/settings/licenses/LicenseRowContainer.js @@ -20,7 +20,7 @@ import { connect } from 'react-redux'; import LicenseRow from './LicenseRow'; import { setLicense } from '../store/licenses/actions'; -import { getSettingsAppLicenseByKey } from '../../../app/store/rootReducer'; +import { getSettingsAppLicenseByKey } from '../../../store/rootReducer'; const mapStateToProps = (state, ownProps) => ({ license: getSettingsAppLicenseByKey(state, ownProps.licenseKey) diff --git a/server/sonar-web/src/main/js/apps/settings/licenses/LicensesListContainer.js b/server/sonar-web/src/main/js/apps/settings/licenses/LicensesListContainer.js index ca19e0a2b41..0267a02ab17 100644 --- a/server/sonar-web/src/main/js/apps/settings/licenses/LicensesListContainer.js +++ b/server/sonar-web/src/main/js/apps/settings/licenses/LicensesListContainer.js @@ -20,7 +20,7 @@ import { connect } from 'react-redux'; import LicensesList from './LicensesList'; import { fetchLicenses } from '../store/licenses/actions'; -import { getSettingsAppAllLicenseKeys } from '../../../app/store/rootReducer'; +import { getSettingsAppAllLicenseKeys } from '../../../store/rootReducer'; const mapStateToProps = state => ({ licenses: getSettingsAppAllLicenseKeys(state) diff --git a/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdAppContainer.js b/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdAppContainer.js index efa82327677..5ca187259d6 100644 --- a/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdAppContainer.js +++ b/server/sonar-web/src/main/js/apps/settings/serverId/ServerIdAppContainer.js @@ -19,7 +19,7 @@ */ import { connect } from 'react-redux'; import ServerIdApp from './ServerIdApp'; -import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../components/store/globalMessages'; +import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../store/globalMessages/duck'; export default connect( () => ({}), diff --git a/server/sonar-web/src/main/js/apps/settings/store/actions.js b/server/sonar-web/src/main/js/apps/settings/store/actions.js index 79f4d15ed9c..169234c47a6 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/actions.js @@ -22,12 +22,12 @@ import { receiveValues } from './values/actions'; import { receiveDefinitions } from './definitions/actions'; import { startLoading, stopLoading } from './settingsPage/loading/actions'; import { parseError } from '../../code/utils'; -import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../components/store/globalMessages'; +import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../store/globalMessages/duck'; import { passValidation, failValidation } from './settingsPage/validationMessages/actions'; import { cancelChange } from './settingsPage/changedValues/actions'; import { isEmptyValue } from '../utils'; import { translate } from '../../../helpers/l10n'; -import { getSettingsAppDefinition, getSettingsAppChangedValue } from '../../../app/store/rootReducer'; +import { getSettingsAppDefinition, getSettingsAppChangedValue } from '../../../store/rootReducer'; export const fetchSettings = componentKey => dispatch => { return getDefinitions(componentKey) diff --git a/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js b/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js index 54bc6de0cec..ab1a9155a87 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/encryptionPage/actions.js @@ -19,7 +19,7 @@ */ import * as api from '../../../../api/settings'; import { parseError } from '../../../code/utils'; -import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../../components/store/globalMessages'; +import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../../store/globalMessages/duck'; export const UPDATE_ENCRYPTION = 'UPDATE_ENCRYPTION'; diff --git a/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js b/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js index 9071be540b5..0b8ae6f073f 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js +++ b/server/sonar-web/src/main/js/apps/settings/store/licenses/actions.js @@ -19,7 +19,7 @@ */ import * as licenses from '../../../../api/licenses'; import { parseError } from '../../../code/utils'; -import { addGlobalSuccessMessage, addGlobalErrorMessage } from '../../../../components/store/globalMessages'; +import { addGlobalSuccessMessage, addGlobalErrorMessage } from '../../../../store/globalMessages/duck'; import { translate } from '../../../../helpers/l10n'; import { isLicenseFromListInvalid, isLicenseInvalid } from '../../licenses/licenseUtils'; diff --git a/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js b/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js index 92b15323978..1d343e15873 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js +++ b/server/sonar-web/src/main/js/apps/settings/store/rootReducer.js @@ -23,8 +23,8 @@ import definitions, * as fromDefinitions from './definitions/reducer'; import values, * as fromValues from './values/reducer'; import settingsPage, * as fromSettingsPage from './settingsPage/reducer'; import licenses, * as fromLicenses from './licenses/reducer'; -import globalMessages, * as fromGlobalMessages from '../../../components/store/globalMessages'; -import type { State as GlobalMessagesState } from '../../../components/store/globalMessages'; +import globalMessages, * as fromGlobalMessages from '../../../store/globalMessages/duck'; +import type { State as GlobalMessagesState } from '../../../store/globalMessages/duck'; import encryptionPage from './encryptionPage/reducer'; type State = { diff --git a/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js b/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js index 196687f245f..c57ed067c36 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js +++ b/server/sonar-web/src/main/js/apps/settings/store/values/reducer.js @@ -20,7 +20,7 @@ // @flow import keyBy from 'lodash/keyBy'; import { RECEIVE_VALUES } from './actions'; -import { actions as appStateActions } from '../../../../app/store/appState/duck'; +import { actions as appStateActions } from '../../../../store/appState/duck'; type State = { [key: string]: {} }; diff --git a/server/sonar-web/src/main/js/apps/update-center/components/UpdateCenterAppContainer.js b/server/sonar-web/src/main/js/apps/update-center/components/UpdateCenterAppContainer.js index 31a8392fb67..5386aadc263 100644 --- a/server/sonar-web/src/main/js/apps/update-center/components/UpdateCenterAppContainer.js +++ b/server/sonar-web/src/main/js/apps/update-center/components/UpdateCenterAppContainer.js @@ -20,7 +20,7 @@ import React from 'react'; import { connect } from 'react-redux'; import init from '../init'; -import { getSettingValue } from '../../../app/store/rootReducer'; +import { getSettingValue } from '../../../store/rootReducer'; class UpdateCenterAppContainer extends React.Component { componentDidMount () { diff --git a/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js b/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js index 8abe6fce357..6737d46a9d0 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js +++ b/server/sonar-web/src/main/js/apps/users/components/UsersAppContainer.js @@ -20,7 +20,7 @@ import React from 'react'; import { connect } from 'react-redux'; import init from '../init'; -import { getCurrentUser } from '../../../app/store/rootReducer'; +import { getCurrentUser } from '../../../store/rootReducer'; class UsersAppContainer extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js b/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js index b2157ced05f..f3c7c17f289 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js +++ b/server/sonar-web/src/main/js/components/controls/FavoriteContainer.js @@ -19,10 +19,10 @@ */ import { connect } from 'react-redux'; import FavoriteBaseStateless from './FavoriteBaseStateless'; -import { isFavorite } from '../../app/store/rootReducer'; -import * as actionCreators from '../../app/store/favorites/duck'; +import { isFavorite } from '../../store/rootReducer'; +import * as actionCreators from '../../store/favorites/duck'; import * as api from '../../api/favorites'; -import { addGlobalErrorMessage } from '../store/globalMessages'; +import { addGlobalErrorMessage } from '../../store/globalMessages/duck'; import { parseError } from '../../apps/code/utils'; const addFavorite = componentKey => dispatch => { diff --git a/server/sonar-web/src/main/js/components/controls/GlobalMessages.js b/server/sonar-web/src/main/js/components/controls/GlobalMessages.js index 4d95243cfec..e10af5d714a 100644 --- a/server/sonar-web/src/main/js/components/controls/GlobalMessages.js +++ b/server/sonar-web/src/main/js/components/controls/GlobalMessages.js @@ -19,7 +19,7 @@ */ import React from 'react'; import classNames from 'classnames'; -import { ERROR, SUCCESS } from '../store/globalMessages'; +import { ERROR, SUCCESS } from '../../store/globalMessages/duck'; export default class GlobalMessages extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/components/store/configureStore.js b/server/sonar-web/src/main/js/components/store/configureStore.js deleted file mode 100644 index 97397d836cd..00000000000 --- a/server/sonar-web/src/main/js/components/store/configureStore.js +++ /dev/null @@ -1,40 +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 { createStore, applyMiddleware, compose } from 'redux'; -import thunk from 'redux-thunk'; - -const middlewares = [thunk]; -const composed = []; - -if (process.env.NODE_ENV !== 'production') { - const createLogger = require('redux-logger'); - middlewares.push(createLogger()); - - composed.push(window.devToolsExtension ? window.devToolsExtension() : f => f); -} - -const finalCreateStore = compose( - applyMiddleware(...middlewares), - ...composed -)(createStore); - -export default function configureStore (rootReducer, initialState) { - return finalCreateStore(rootReducer, initialState); -} diff --git a/server/sonar-web/src/main/js/components/store/generalReducers.js b/server/sonar-web/src/main/js/components/store/generalReducers.js deleted file mode 100644 index 8f88ff41b0b..00000000000 --- a/server/sonar-web/src/main/js/components/store/generalReducers.js +++ /dev/null @@ -1,95 +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. - */ -// Author: Christoffer Niska -// https://gist.github.com/crisu83/42ecffccad9d04c74605fbc75c9dc9d1 -import uniq from 'lodash/uniq'; - -/** - * Creates a reducer that manages a single value. - * - * @param {function(state, action)} shouldUpdate - * @param {function(state, action)} shouldReset - * @param {function(state, action)} getValue - * @param {*} defaultValue - * @returns {function(state, action)} - */ -export const createValue = ( - shouldUpdate = () => true, - shouldReset = () => false, - getValue = (state, action) => action.payload, - defaultValue = null -) => (state = defaultValue, action = {}) => { - if (shouldReset(state, action)) { - return defaultValue; - } - if (shouldUpdate(state, action)) { - return getValue(state, action); - } - return state; -}; - -/** - * Creates a reducer that manages a map. - * - * @param {function(state, action)} shouldUpdate - * @param {function(state, action)} shouldReset - * @param {function(state, action)} getValues - * @returns {function(state, action)} - */ -export const createMap = ( - shouldUpdate = () => true, - shouldReset = () => false, - getValues = (state, action) => action.payload -) => createValue(shouldUpdate, shouldReset, (state, action) => - ({ ...state, ...getValues(state, action) }), {}); - -/** - * Creates a reducer that manages a set. - * - * @param {function(state, action)} shouldUpdate - * @param {function(state, action)} shouldReset - * @param {function(state, action)} getValues - * @returns {function(state, action)} - */ -export const createSet = ( - shouldUpdate = () => true, - shouldReset = () => false, - getValues = (state, action) => action.payload -) => createValue(shouldUpdate, shouldReset, (state, action) => - uniq([...state, ...getValues(state, action)]), []); - -/** - * Creates a reducer that manages a flag. - * - * @param {function(state, action)} shouldTurnOn - * @param {function(state, action)} shouldTurnOff - * @param {bool} defaultValue - * @returns {function(state, action)} - */ -export const createFlag = (shouldTurnOn, shouldTurnOff, defaultValue = false) => - (state = defaultValue, action = {}) => { - if (shouldTurnOn(state, action)) { - return true; - } - if (shouldTurnOff(state, action)) { - return false; - } - return state; - }; diff --git a/server/sonar-web/src/main/js/components/store/globalMessages.js b/server/sonar-web/src/main/js/components/store/globalMessages.js deleted file mode 100644 index b5e11e1f5df..00000000000 --- a/server/sonar-web/src/main/js/components/store/globalMessages.js +++ /dev/null @@ -1,113 +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. - */ -// @flow -import uniqueId from 'lodash/uniqueId'; -import { actions } from '../../app/store/appState/duck'; - -type Level = 'ERROR' | 'SUCCESS'; - -type Message = { - id: string, - message: string, - level: Level -}; - -export type State = Array; - -type Action = Object; - -export const ERROR = 'ERROR'; -export const SUCCESS = 'SUCCESS'; - -/* Actions */ -const ADD_GLOBAL_MESSAGE = 'ADD_GLOBAL_MESSAGE'; -const CLOSE_GLOBAL_MESSAGE = 'CLOSE_GLOBAL_MESSAGE'; -const CLOSE_ALL_GLOBAL_MESSAGES = 'CLOSE_ALL_GLOBAL_MESSAGES'; - -const addGlobalMessageActionCreator = (id: string, message: string, level: Level) => ({ - type: ADD_GLOBAL_MESSAGE, - message, - level, - id -}); - -export const closeGlobalMessage = (id: string) => ({ - type: CLOSE_GLOBAL_MESSAGE, - id -}); - -export const closeAllGlobalMessages = (id: string) => ({ - type: CLOSE_ALL_GLOBAL_MESSAGES, - id -}); - -const addGlobalMessage = (message: string, level: Level) => (dispatch: Function) => { - const id = uniqueId('global-message-'); - dispatch(addGlobalMessageActionCreator(id, message, level)); - setTimeout(() => dispatch(closeGlobalMessage(id)), 5000); -}; - -export const addGlobalErrorMessage = (message: string) => - addGlobalMessage(message, ERROR); - -export const addGlobalSuccessMessage = (message: string) => - addGlobalMessage(message, SUCCESS); - -/* Reducer */ -const globalMessages = (state: State = [], action: Action = {}) => { - switch (action.type) { - case ADD_GLOBAL_MESSAGE: - return [{ - id: action.id, - message: action.message, - level: action.level - }]; - - case actions.REQUIRE_AUTHENTICATION: - // FIXME l10n - return [{ - id: uniqueId('global-message-'), - message: 'Authentication required to see this page.', - level: ERROR - }]; - - case actions.REQUIRE_AUTHORIZATION: - // FIXME l10n - return [{ - id: uniqueId('global-message-'), - message: 'You are not authorized to access this page. Please log in with more privileges and try again.', - level: ERROR - }]; - - case CLOSE_GLOBAL_MESSAGE: - return state.filter(message => message.id !== action.id); - - - case CLOSE_ALL_GLOBAL_MESSAGES: - return []; - default: - return state; - } -}; - -export default globalMessages; - -/* Selectors */ -export const getGlobalMessages = (state: State) => state; diff --git a/server/sonar-web/src/main/js/components/store/withStore.js b/server/sonar-web/src/main/js/components/store/withStore.js deleted file mode 100644 index 4518fc0547f..00000000000 --- a/server/sonar-web/src/main/js/components/store/withStore.js +++ /dev/null @@ -1,54 +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'; - -const withStore = (ComposedComponent, initial = {}) => { - let store = initial; - - const updateStore = changes => { - store = { ...store, ...changes }; - }; - - const getStore = () => ({ ...store }); - - return class extends React.Component { - static displayName = `withStore(${ComposedComponent.displayName})}`; - - componentWillMount () { - this.handleUpdateStore = this.handleUpdateStore.bind(this); - } - - handleUpdateStore (changes) { - updateStore(changes); - this.forceUpdate(); - } - - render () { - return ( - - ); - } - }; -}; - -export default withStore; diff --git a/server/sonar-web/src/main/js/components/ui/Avatar.js b/server/sonar-web/src/main/js/components/ui/Avatar.js index 8e96bb380ae..8ec297fda8c 100644 --- a/server/sonar-web/src/main/js/components/ui/Avatar.js +++ b/server/sonar-web/src/main/js/components/ui/Avatar.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import md5 from 'blueimp-md5'; import classNames from 'classnames'; -import { getSettingValue } from '../../app/store/rootReducer'; +import { getSettingValue } from '../../store/rootReducer'; class Avatar extends React.Component { static propTypes = { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js index c790508b1c0..cfd1b8041a1 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js @@ -22,7 +22,7 @@ import Handlebars from 'handlebars/runtime'; function gravatarServer () { const getStore = require('../../app/utils/getStore').default; - const { getSettingValue } = require('../../app/store/rootReducer'); + const { getSettingValue } = require('../../store/rootReducer'); const store = getStore(); return (getSettingValue(store.getState(), 'sonar.lf.gravatarServerUrl') || {}).value; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js b/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js index 87f038f1fa6..c50d7467e8a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js @@ -19,7 +19,7 @@ */ function enableGravatar () { const getStore = require('../../app/utils/getStore').default; - const { getSettingValue } = require('../../app/store/rootReducer'); + const { getSettingValue } = require('../../store/rootReducer'); const store = getStore(); return (getSettingValue(store.getState(), 'sonar.lf.enableGravatar') || {}).value === 'true'; diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js index 6a7cd4a2d0e..0ec44e63753 100644 --- a/server/sonar-web/src/main/js/helpers/measures.js +++ b/server/sonar-web/src/main/js/helpers/measures.js @@ -305,7 +305,7 @@ function formatDurationShort (isNegative, days, hours, minutes) { function getHoursInDay () { // workaround cyclic dependencies const getStore = require('../app/utils/getStore').default; - const { getSettingValue } = require('../app/store/rootReducer'); + const { getSettingValue } = require('../store/rootReducer'); const store = getStore(); const settingValue = getSettingValue(store.getState(), 'sonar.technicalDebt.hoursInDay'); @@ -360,7 +360,7 @@ function shortDurationVariationFormatter (value) { function getRatingGrid () { // workaround cyclic dependencies const getStore = require('../app/utils/getStore').default; - const { getSettingValue } = require('../app/store/rootReducer'); + const { getSettingValue } = require('../store/rootReducer'); const store = getStore(); const settingValue = getSettingValue(store.getState(), 'sonar.technicalDebt.ratingGrid'); diff --git a/server/sonar-web/src/main/js/store/appState/duck.js b/server/sonar-web/src/main/js/store/appState/duck.js new file mode 100644 index 00000000000..cd313870e19 --- /dev/null +++ b/server/sonar-web/src/main/js/store/appState/duck.js @@ -0,0 +1,75 @@ +/* + * 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. + */ +// @flow +type AppState = { + authenticationError: boolean, + authorizationError: boolean, + qualifiers: ?Array +}; + +export type Action = { + type: string, + appState: AppState +} + +export const actions = { + SET_APP_STATE: 'SET_APP_STATE', + REQUIRE_AUTHENTICATION: 'REQUIRE_AUTHENTICATION', + REQUIRE_AUTHORIZATION: 'REQUIRE_AUTHORIZATION' +}; + +export const setAppState = (appState: AppState): Action => ({ + type: actions.SET_APP_STATE, + appState +}); + +export const requireAuthentication = () => ({ + type: actions.REQUIRE_AUTHENTICATION +}); + +export const requireAuthorization = () => ({ + type: actions.REQUIRE_AUTHORIZATION +}); + +const defaultValue = { + authenticationError: false, + authorizationError: false, + qualifiers: null +}; + +export default (state: AppState = defaultValue, action: Action) => { + if (action.type === actions.SET_APP_STATE) { + return { ...state, ...action.appState }; + } + + if (action.type === actions.REQUIRE_AUTHENTICATION) { + return { ...state, authenticationError: true }; + } + + if (action.type === actions.REQUIRE_AUTHORIZATION) { + return { ...state, authorizationError: true }; + } + + return state; +}; + +export const getRootQualifiers = (state: AppState) => ( + state.qualifiers +); diff --git a/server/sonar-web/src/main/js/store/components/actions.js b/server/sonar-web/src/main/js/store/components/actions.js new file mode 100644 index 00000000000..3ba34eb2eb8 --- /dev/null +++ b/server/sonar-web/src/main/js/store/components/actions.js @@ -0,0 +1,25 @@ +/* + * 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. + */ +export const RECEIVE_COMPONENTS = 'RECEIVE_COMPONENTS'; + +export const receiveComponents = components => ({ + type: RECEIVE_COMPONENTS, + components +}); diff --git a/server/sonar-web/src/main/js/store/components/reducer.js b/server/sonar-web/src/main/js/store/components/reducer.js new file mode 100644 index 00000000000..c2d609a1066 --- /dev/null +++ b/server/sonar-web/src/main/js/store/components/reducer.js @@ -0,0 +1,47 @@ +/* + * 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 { combineReducers } from 'redux'; +import keyBy from 'lodash/keyBy'; +import uniq from 'lodash/uniq'; +import { RECEIVE_COMPONENTS } from './actions'; + +const byKey = (state = {}, action = {}) => { + if (action.type === RECEIVE_COMPONENTS) { + const changes = keyBy(action.components, 'key'); + return { ...state, ...changes }; + } + + return state; +}; + +const keys = (state = [], action = {}) => { + if (action.type === RECEIVE_COMPONENTS) { + const changes = action.components.map(f => f.key); + return uniq([...state, ...changes]); + } + + return state; +}; + +export default combineReducers({ byKey, keys }); + +export const getComponent = (state, key) => ( + state.byKey[key] +); diff --git a/server/sonar-web/src/main/js/store/favorites/duck.js b/server/sonar-web/src/main/js/store/favorites/duck.js new file mode 100644 index 00000000000..7c6d4b52012 --- /dev/null +++ b/server/sonar-web/src/main/js/store/favorites/duck.js @@ -0,0 +1,63 @@ +/* + * 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 uniq from 'lodash/uniq'; +import without from 'lodash/without'; + +export const actions = { + RECEIVE_FAVORITES: 'RECEIVE_FAVORITES', + ADD_FAVORITE: 'ADD_FAVORITE', + REMOVE_FAVORITE: 'REMOVE_FAVORITE' +}; + +export const receiveFavorites = favorites => ({ + type: actions.RECEIVE_FAVORITES, + favorites +}); + +export const addFavorite = componentKey => ({ + type: actions.ADD_FAVORITE, + componentKey +}); + +export const removeFavorite = componentKey => ({ + type: actions.REMOVE_FAVORITE, + componentKey +}); + +export default (state = [], action = {}) => { + if (action.type === actions.RECEIVE_FAVORITES) { + return uniq([...state, ...action.favorites.map(f => f.key)]); + } + + if (action.type === actions.ADD_FAVORITE) { + return uniq([...state, action.componentKey]); + } + + if (action.type === actions.REMOVE_FAVORITE) { + return without(state, action.componentKey); + } + + return state; +}; + +export const isFavorite = (state, componentKey) => ( + state.includes(componentKey) +); + diff --git a/server/sonar-web/src/main/js/store/globalMessages/duck.js b/server/sonar-web/src/main/js/store/globalMessages/duck.js new file mode 100644 index 00000000000..38e92ca1693 --- /dev/null +++ b/server/sonar-web/src/main/js/store/globalMessages/duck.js @@ -0,0 +1,113 @@ +/* + * 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. + */ +// @flow +import uniqueId from 'lodash/uniqueId'; +import { actions } from '../appState/duck'; + +type Level = 'ERROR' | 'SUCCESS'; + +type Message = { + id: string, + message: string, + level: Level +}; + +export type State = Array; + +type Action = Object; + +export const ERROR = 'ERROR'; +export const SUCCESS = 'SUCCESS'; + +/* Actions */ +const ADD_GLOBAL_MESSAGE = 'ADD_GLOBAL_MESSAGE'; +const CLOSE_GLOBAL_MESSAGE = 'CLOSE_GLOBAL_MESSAGE'; +const CLOSE_ALL_GLOBAL_MESSAGES = 'CLOSE_ALL_GLOBAL_MESSAGES'; + +const addGlobalMessageActionCreator = (id: string, message: string, level: Level) => ({ + type: ADD_GLOBAL_MESSAGE, + message, + level, + id +}); + +export const closeGlobalMessage = (id: string) => ({ + type: CLOSE_GLOBAL_MESSAGE, + id +}); + +export const closeAllGlobalMessages = (id: string) => ({ + type: CLOSE_ALL_GLOBAL_MESSAGES, + id +}); + +const addGlobalMessage = (message: string, level: Level) => (dispatch: Function) => { + const id = uniqueId('global-message-'); + dispatch(addGlobalMessageActionCreator(id, message, level)); + setTimeout(() => dispatch(closeGlobalMessage(id)), 5000); +}; + +export const addGlobalErrorMessage = (message: string) => + addGlobalMessage(message, ERROR); + +export const addGlobalSuccessMessage = (message: string) => + addGlobalMessage(message, SUCCESS); + +/* Reducer */ +const globalMessages = (state: State = [], action: Action = {}) => { + switch (action.type) { + case ADD_GLOBAL_MESSAGE: + return [{ + id: action.id, + message: action.message, + level: action.level + }]; + + case actions.REQUIRE_AUTHENTICATION: + // FIXME l10n + return [{ + id: uniqueId('global-message-'), + message: 'Authentication required to see this page.', + level: ERROR + }]; + + case actions.REQUIRE_AUTHORIZATION: + // FIXME l10n + return [{ + id: uniqueId('global-message-'), + message: 'You are not authorized to access this page. Please log in with more privileges and try again.', + level: ERROR + }]; + + case CLOSE_GLOBAL_MESSAGE: + return state.filter(message => message.id !== action.id); + + + case CLOSE_ALL_GLOBAL_MESSAGES: + return []; + default: + return state; + } +}; + +export default globalMessages; + +/* Selectors */ +export const getGlobalMessages = (state: State) => state; diff --git a/server/sonar-web/src/main/js/store/languages/actions.js b/server/sonar-web/src/main/js/store/languages/actions.js new file mode 100644 index 00000000000..9d2d517acc2 --- /dev/null +++ b/server/sonar-web/src/main/js/store/languages/actions.js @@ -0,0 +1,25 @@ +/* + * 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. + */ +export const RECEIVE_LANGUAGES = 'RECEIVE_LANGUAGES'; + +export const receiveLanguages = languages => ({ + type: RECEIVE_LANGUAGES, + languages +}); diff --git a/server/sonar-web/src/main/js/store/languages/reducer.js b/server/sonar-web/src/main/js/store/languages/reducer.js new file mode 100644 index 00000000000..73eb9d5f037 --- /dev/null +++ b/server/sonar-web/src/main/js/store/languages/reducer.js @@ -0,0 +1,35 @@ +/* + * 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 keyBy from 'lodash/keyBy'; +import { RECEIVE_LANGUAGES } from './actions'; + +const reducer = (state = {}, action = {}) => { + if (action.type === RECEIVE_LANGUAGES) { + return keyBy(action.languages, 'key'); + } + + return state; +}; + +export default reducer; + +export const getLanguages = state => ( + state +); diff --git a/server/sonar-web/src/main/js/store/measures/actions.js b/server/sonar-web/src/main/js/store/measures/actions.js new file mode 100644 index 00000000000..2321163afd0 --- /dev/null +++ b/server/sonar-web/src/main/js/store/measures/actions.js @@ -0,0 +1,42 @@ +/* + * 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. + */ +export const RECEIVE_COMPONENT_MEASURE = 'RECEIVE_COMPONENT_MEASURE'; + +export const receiveComponentMeasure = (componentKey, metricKey, value) => ({ + type: RECEIVE_COMPONENT_MEASURE, + componentKey, + metricKey, + value +}); + +export const RECEIVE_COMPONENT_MEASURES = 'RECEIVE_COMPONENT_MEASURES'; + +export const receiveComponentMeasures = (componentKey, measures) => ({ + type: RECEIVE_COMPONENT_MEASURES, + componentKey, + measures +}); + +export const RECEIVE_COMPONENTS_MEASURES = 'RECEIVE_COMPONENTS_MEASURES'; + +export const receiveComponentsMeasures = componentsWithMeasures => ({ + type: RECEIVE_COMPONENTS_MEASURES, + componentsWithMeasures +}); diff --git a/server/sonar-web/src/main/js/store/measures/reducer.js b/server/sonar-web/src/main/js/store/measures/reducer.js new file mode 100644 index 00000000000..3d166663836 --- /dev/null +++ b/server/sonar-web/src/main/js/store/measures/reducer.js @@ -0,0 +1,65 @@ +/* + * 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 { RECEIVE_COMPONENT_MEASURE, RECEIVE_COMPONENT_MEASURES, RECEIVE_COMPONENTS_MEASURES } from './actions'; + +const byMetricKey = (state = {}, action = {}) => { + if (action.type === RECEIVE_COMPONENT_MEASURE) { + return { ...state, [action.metricKey]: action.value }; + } + + if (action.type === RECEIVE_COMPONENT_MEASURES) { + return { ...state, ...action.measures }; + } + + return state; +}; + +const reducer = (state = {}, action = {}) => { + if ([RECEIVE_COMPONENT_MEASURE, RECEIVE_COMPONENT_MEASURES].includes(action.type)) { + const component = state[action.componentKey]; + return { ...state, [action.componentKey]: byMetricKey(component, action) }; + } + + if (action.type === RECEIVE_COMPONENTS_MEASURES) { + const newState = { ...state }; + Object.keys(action.componentsWithMeasures).forEach(componentKey => { + Object.assign(newState, { + [componentKey]: byMetricKey(state[componentKey], { + type: RECEIVE_COMPONENT_MEASURES, + measures: action.componentsWithMeasures[componentKey] + }) + }); + }); + return newState; + } + + return state; +}; + +export default reducer; + +export const getComponentMeasure = (state, componentKey, metricKey) => { + const component = state[componentKey]; + return component && component[metricKey]; +}; + +export const getComponentMeasures = (state, componentKey) => ( + state[componentKey] +); diff --git a/server/sonar-web/src/main/js/store/rootActions.js b/server/sonar-web/src/main/js/store/rootActions.js new file mode 100644 index 00000000000..005c1158025 --- /dev/null +++ b/server/sonar-web/src/main/js/store/rootActions.js @@ -0,0 +1,77 @@ +/* + * 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 { getLanguages } from '../api/languages'; +import { getGlobalNavigation, getComponentNavigation } from '../api/nav'; +import * as auth from '../api/auth'; +import { receiveLanguages } from './languages/actions'; +import { receiveComponents } from './components/actions'; +import { addGlobalErrorMessage } from './globalMessages/duck'; +import { parseError } from '../apps/code/utils'; +import { setAppState } from './appState/duck'; + +const onFail = dispatch => error => ( + parseError(error).then(message => dispatch(addGlobalErrorMessage(message))) +); + +export const fetchAppState = () => dispatch => ( + getGlobalNavigation().then( + appState => dispatch(setAppState(appState)), + onFail(dispatch) + ) +); + +export const fetchLanguages = () => dispatch => { + return getLanguages().then( + languages => dispatch(receiveLanguages(languages)), + onFail(dispatch) + ); +}; + +const addQualifier = project => ({ + ...project, + qualifier: project.breadcrumbs[project.breadcrumbs.length - 1].qualifier +}); + +export const fetchProject = key => dispatch => ( + getComponentNavigation(key).then( + component => dispatch(receiveComponents([addQualifier(component)])), + onFail(dispatch) + ) +); + +export const doLogin = (login, password) => dispatch => ( + auth.login(login, password).then( + () => { /* everything is fine */ }, + () => { + dispatch(addGlobalErrorMessage('Authentication failed')); + return Promise.reject(); + } + ) +); + +export const doLogout = () => dispatch => ( + auth.logout().then( + () => { /* everything is fine */ }, + () => { + dispatch(addGlobalErrorMessage('Logout failed')); + return Promise.reject(); + } + ) +); diff --git a/server/sonar-web/src/main/js/store/rootReducer.js b/server/sonar-web/src/main/js/store/rootReducer.js new file mode 100644 index 00000000000..1a9e8793369 --- /dev/null +++ b/server/sonar-web/src/main/js/store/rootReducer.js @@ -0,0 +1,304 @@ +/* + * 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 { combineReducers } from 'redux'; +import appState from './appState/duck'; +import components, * as fromComponents from './components/reducer'; +import users, * as fromUsers from './users/reducer'; +import favorites, * as fromFavorites from './favorites/duck'; +import languages, * as fromLanguages from './languages/reducer'; +import measures, * as fromMeasures from './measures/reducer'; +import globalMessages, * as fromGlobalMessages from './globalMessages/duck'; + +import measuresApp, * as fromMeasuresApp from '../apps/component-measures/store/rootReducer'; +import permissionsApp, * as fromPermissionsApp from '../apps/permissions/shared/store/rootReducer'; +import projectAdminApp, * as fromProjectAdminApp from '../apps/project-admin/store/rootReducer'; +import projectsApp, * as fromProjectsApp from '../apps/projects/store/reducer'; +import qualityGatesApp from '../apps/quality-gates/store/rootReducer'; +import settingsApp, * as fromSettingsApp from '../apps/settings/store/rootReducer'; + +export default combineReducers({ + appState, + components, + globalMessages, + favorites, + languages, + measures, + users, + + // apps + measuresApp, + permissionsApp, + projectAdminApp, + projectsApp, + qualityGatesApp, + settingsApp +}); + +export const getAppState = state => ( + state.appState +); + +export const getComponent = (state, key) => ( + fromComponents.getComponent(state.components, key) +); + +export const getGlobalMessages = state => ( + fromGlobalMessages.getGlobalMessages(state.globalMessages) +); + +export const getLanguages = (state, key) => ( + fromLanguages.getLanguages(state.languages, key) +); + +export const getCurrentUser = state => ( + fromUsers.getCurrentUser(state.users) +); + +export const isFavorite = (state, componentKey) => ( + fromFavorites.isFavorite(state.favorites, componentKey) +); + +export const getComponentMeasure = (state, componentKey, metricKey) => ( + fromMeasures.getComponentMeasure(state.measures, componentKey, metricKey) +); + +export const getComponentMeasures = (state, componentKey) => ( + fromMeasures.getComponentMeasures(state.measures, componentKey) +); + +export const getProjects = state => ( + fromProjectsApp.getProjects(state.projectsApp) +); + +export const getProjectsAppState = state => ( + fromProjectsApp.getState(state.projectsApp) +); + +export const getProjectsAppFacetByProperty = (state, property) => ( + fromProjectsApp.getFacetByProperty(state.projectsApp, property) +); + +export const getProjectsAppMaxFacetValue = state => ( + fromProjectsApp.getMaxFacetValue(state.projectsApp) +); + +export const getQualityGatesAppState = state => ( + state.qualityGatesApp +); + +export const getPermissionsAppUsers = state => ( + fromPermissionsApp.getUsers(state.permissionsApp) +); + +export const getPermissionsAppGroups = state => ( + fromPermissionsApp.getGroups(state.permissionsApp) +); + +export const isPermissionsAppLoading = state => ( + fromPermissionsApp.isLoading(state.permissionsApp) +); + +export const getPermissionsAppQuery = state => ( + fromPermissionsApp.getQuery(state.permissionsApp) +); + +export const getPermissionsAppFilter = state => ( + fromPermissionsApp.getFilter(state.permissionsApp) +); + +export const getPermissionsAppSelectedPermission = state => ( + fromPermissionsApp.getSelectedPermission(state.permissionsApp) +); + +export const getPermissionsAppError = state => ( + fromPermissionsApp.getError(state.permissionsApp) +); + +export const getSettingValue = (state, key) => ( + fromSettingsApp.getValue(state.settingsApp, key) +); + +export const getSettingsAppDefinition = (state, key) => ( + fromSettingsApp.getDefinition(state.settingsApp, key) +); + +export const getSettingsAppAllCategories = state => ( + fromSettingsApp.getAllCategories(state.settingsApp) +); + +export const getSettingsAppDefaultCategory = state => ( + fromSettingsApp.getDefaultCategory(state.settingsApp) +); + +export const getSettingsAppSettingsForCategory = (state, category) => ( + fromSettingsApp.getSettingsForCategory(state.settingsApp, category) +); + +export const getSettingsAppChangedValue = (state, key) => ( + fromSettingsApp.getChangedValue(state.settingsApp, key) +); + +export const isSettingsAppLoading = (state, key) => ( + fromSettingsApp.isLoading(state.settingsApp, key) +); + +export const getSettingsAppLicenseByKey = (state, key) => ( + fromSettingsApp.getLicenseByKey(state.settingsApp, key) +); + +export const getSettingsAppAllLicenseKeys = state => ( + fromSettingsApp.getAllLicenseKeys(state.settingsApp) +); + +export const getSettingsAppValidationMessage = (state, key) => ( + fromSettingsApp.getValidationMessage(state.settingsApp, key) +); + +export const getSettingsAppEncryptionState = state => ( + fromSettingsApp.getEncryptionState(state.settingsApp) +); + +export const getSettingsAppGlobalMessages = state => ( + fromSettingsApp.getGlobalMessages(state.settingsApp) +); + +export const getProjectAdminProfileByKey = (state, profileKey) => ( + fromProjectAdminApp.getProfileByKey(state.projectAdminApp, profileKey) +); + +export const getProjectAdminAllProfiles = state => ( + fromProjectAdminApp.getAllProfiles(state.projectAdminApp) +); + +export const getProjectAdminProjectProfiles = (state, projectKey) => ( + fromProjectAdminApp.getProjectProfiles(state.projectAdminApp, projectKey) +); + +export const getProjectAdminGateById = (state, gateId) => ( + fromProjectAdminApp.getGateById(state.projectAdminApp, gateId) +); + +export const getProjectAdminAllGates = state => ( + fromProjectAdminApp.getAllGates(state.projectAdminApp) +); + +export const getProjectAdminProjectGate = (state, projectKey) => ( + fromProjectAdminApp.getProjectGate(state.projectAdminApp, projectKey) +); + +export const getProjectAdminLinkById = (state, linkId) => ( + fromProjectAdminApp.getLinkById(state.projectAdminApp, linkId) +); + +export const getProjectAdminProjectLinks = (state, projectKey) => ( + fromProjectAdminApp.getProjectLinks(state.projectAdminApp, projectKey) +); + +export const getProjectAdminComponentByKey = (state, componentKey) => ( + fromProjectAdminApp.getComponentByKey(state.projectAdminApp, componentKey) +); + +export const getProjectAdminProjectModules = (state, projectKey) => ( + fromProjectAdminApp.getProjectModules(state.projectAdminApp, projectKey) +); + +export const getProjectAdminGlobalMessages = state => ( + fromProjectAdminApp.getGlobalMessages(state.projectAdminApp) +); + +export const getMeasuresAppComponent = state => ( + fromMeasuresApp.getComponent(state.measuresApp) +); + +export const getMeasuresAppAllMetrics = state => ( + fromMeasuresApp.getAllMetrics(state.measuresApp) +); + +export const getMeasuresAppDetailsMetric = state => ( + fromMeasuresApp.getDetailsMetric(state.measuresApp) +); + +export const getMeasuresAppDetailsMeasure = state => ( + fromMeasuresApp.getDetailsMeasure(state.measuresApp) +); + +export const getMeasuresAppDetailsSecondaryMeasure = state => ( + fromMeasuresApp.getDetailsSecondaryMeasure(state.measuresApp) +); + +export const getMeasuresAppDetailsPeriods = state => ( + fromMeasuresApp.getDetailsPeriods(state.measuresApp) +); + +export const isMeasuresAppFetching = state => ( + fromMeasuresApp.isFetching(state.measuresApp) +); + +export const getMeasuresAppList = state => ( + fromMeasuresApp.getList(state.measuresApp) +); + +export const getMeasuresAppListComponents = state => ( + fromMeasuresApp.getListComponents(state.measuresApp) +); + +export const getMeasuresAppListSelected = state => ( + fromMeasuresApp.getListSelected(state.measuresApp) +); + +export const getMeasuresAppListTotal = state => ( + fromMeasuresApp.getListTotal(state.measuresApp) +); + +export const getMeasuresAppListPageIndex = state => ( + fromMeasuresApp.getListPageIndex(state.measuresApp) +); + +export const getMeasuresAppTree = state => ( + fromMeasuresApp.getTree(state.measuresApp) +); + +export const getMeasuresAppTreeComponents = state => ( + fromMeasuresApp.getTreeComponents(state.measuresApp) +); + +export const getMeasuresAppTreeBreadcrumbs = state => ( + fromMeasuresApp.getTreeBreadcrumbs(state.measuresApp) +); + +export const getMeasuresAppTreeSelected = state => ( + fromMeasuresApp.getTreeSelected(state.measuresApp) +); + +export const getMeasuresAppTreeTotal = state => ( + fromMeasuresApp.getTreeTotal(state.measuresApp) +); + +export const getMeasuresAppTreePageIndex = state => ( + fromMeasuresApp.getTreePageIndex(state.measuresApp) +); + +export const getMeasuresAppHomeDomains = state => ( + fromMeasuresApp.getHomeDomains(state.measuresApp) +); + +export const getMeasuresAppHomePeriods = state => ( + fromMeasuresApp.getHomePeriods(state.measuresApp) +); diff --git a/server/sonar-web/src/main/js/store/users/actions.js b/server/sonar-web/src/main/js/store/users/actions.js new file mode 100644 index 00000000000..27efd8b0c16 --- /dev/null +++ b/server/sonar-web/src/main/js/store/users/actions.js @@ -0,0 +1,31 @@ +/* + * 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 { getCurrentUser } from '../../api/users'; + +export const RECEIVE_CURRENT_USER = 'RECEIVE_CURRENT_USER'; + +export const receiveCurrentUser = user => ({ + type: RECEIVE_CURRENT_USER, + user +}); + +export const fetchCurrentUser = () => dispatch => ( + getCurrentUser().then(user => dispatch(receiveCurrentUser(user))) +); diff --git a/server/sonar-web/src/main/js/store/users/reducer.js b/server/sonar-web/src/main/js/store/users/reducer.js new file mode 100644 index 00000000000..03dd5f9df28 --- /dev/null +++ b/server/sonar-web/src/main/js/store/users/reducer.js @@ -0,0 +1,52 @@ +/* + * 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 { combineReducers } from 'redux'; +import uniq from 'lodash/uniq'; +import { RECEIVE_CURRENT_USER } from './actions'; + +const usersByLogin = (state = {}, action = {}) => { + if (action.type === RECEIVE_CURRENT_USER) { + return { ...state, [action.user.login]: action.user }; + } + + return state; +}; + +const userLogins = (state = [], action = {}) => { + if (action.type === RECEIVE_CURRENT_USER) { + return uniq([...state, action.user.login]); + } + + return state; +}; + +const currentUser = (state = null, action = {}) => { + if (action.type === RECEIVE_CURRENT_USER) { + return action.user; + } + + return state; +}; + +export default combineReducers({ usersByLogin, userLogins, currentUser }); + +export const getCurrentUser = state => ( + state.currentUser +); diff --git a/server/sonar-web/src/main/js/store/utils/configureStore.js b/server/sonar-web/src/main/js/store/utils/configureStore.js new file mode 100644 index 00000000000..97397d836cd --- /dev/null +++ b/server/sonar-web/src/main/js/store/utils/configureStore.js @@ -0,0 +1,40 @@ +/* + * 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 { createStore, applyMiddleware, compose } from 'redux'; +import thunk from 'redux-thunk'; + +const middlewares = [thunk]; +const composed = []; + +if (process.env.NODE_ENV !== 'production') { + const createLogger = require('redux-logger'); + middlewares.push(createLogger()); + + composed.push(window.devToolsExtension ? window.devToolsExtension() : f => f); +} + +const finalCreateStore = compose( + applyMiddleware(...middlewares), + ...composed +)(createStore); + +export default function configureStore (rootReducer, initialState) { + return finalCreateStore(rootReducer, initialState); +} diff --git a/server/sonar-web/src/main/js/store/utils/generalReducers.js b/server/sonar-web/src/main/js/store/utils/generalReducers.js new file mode 100644 index 00000000000..8f88ff41b0b --- /dev/null +++ b/server/sonar-web/src/main/js/store/utils/generalReducers.js @@ -0,0 +1,95 @@ +/* + * 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. + */ +// Author: Christoffer Niska +// https://gist.github.com/crisu83/42ecffccad9d04c74605fbc75c9dc9d1 +import uniq from 'lodash/uniq'; + +/** + * Creates a reducer that manages a single value. + * + * @param {function(state, action)} shouldUpdate + * @param {function(state, action)} shouldReset + * @param {function(state, action)} getValue + * @param {*} defaultValue + * @returns {function(state, action)} + */ +export const createValue = ( + shouldUpdate = () => true, + shouldReset = () => false, + getValue = (state, action) => action.payload, + defaultValue = null +) => (state = defaultValue, action = {}) => { + if (shouldReset(state, action)) { + return defaultValue; + } + if (shouldUpdate(state, action)) { + return getValue(state, action); + } + return state; +}; + +/** + * Creates a reducer that manages a map. + * + * @param {function(state, action)} shouldUpdate + * @param {function(state, action)} shouldReset + * @param {function(state, action)} getValues + * @returns {function(state, action)} + */ +export const createMap = ( + shouldUpdate = () => true, + shouldReset = () => false, + getValues = (state, action) => action.payload +) => createValue(shouldUpdate, shouldReset, (state, action) => + ({ ...state, ...getValues(state, action) }), {}); + +/** + * Creates a reducer that manages a set. + * + * @param {function(state, action)} shouldUpdate + * @param {function(state, action)} shouldReset + * @param {function(state, action)} getValues + * @returns {function(state, action)} + */ +export const createSet = ( + shouldUpdate = () => true, + shouldReset = () => false, + getValues = (state, action) => action.payload +) => createValue(shouldUpdate, shouldReset, (state, action) => + uniq([...state, ...getValues(state, action)]), []); + +/** + * Creates a reducer that manages a flag. + * + * @param {function(state, action)} shouldTurnOn + * @param {function(state, action)} shouldTurnOff + * @param {bool} defaultValue + * @returns {function(state, action)} + */ +export const createFlag = (shouldTurnOn, shouldTurnOff, defaultValue = false) => + (state = defaultValue, action = {}) => { + if (shouldTurnOn(state, action)) { + return true; + } + if (shouldTurnOff(state, action)) { + return false; + } + return state; + }; diff --git a/server/sonar-web/src/main/js/store/utils/withStore.js b/server/sonar-web/src/main/js/store/utils/withStore.js new file mode 100644 index 00000000000..4518fc0547f --- /dev/null +++ b/server/sonar-web/src/main/js/store/utils/withStore.js @@ -0,0 +1,54 @@ +/* + * 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'; + +const withStore = (ComposedComponent, initial = {}) => { + let store = initial; + + const updateStore = changes => { + store = { ...store, ...changes }; + }; + + const getStore = () => ({ ...store }); + + return class extends React.Component { + static displayName = `withStore(${ComposedComponent.displayName})}`; + + componentWillMount () { + this.handleUpdateStore = this.handleUpdateStore.bind(this); + } + + handleUpdateStore (changes) { + updateStore(changes); + this.forceUpdate(); + } + + render () { + return ( + + ); + } + }; +}; + +export default withStore; -- cgit v1.2.3