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 {
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;
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 () {
*/
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)
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 = {
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 = {
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 = {
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 () {
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 {
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) {
+++ /dev/null
-/*
- * 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<string>
-};
-
-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
-);
+++ /dev/null
-/*
- * 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
-});
+++ /dev/null
-/*
- * 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]
-);
+++ /dev/null
-/*
- * 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)
-);
-
+++ /dev/null
-/*
- * 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
-});
+++ /dev/null
-/*
- * 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
-);
+++ /dev/null
-/*
- * 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
-});
+++ /dev/null
-/*
- * 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]
-);
+++ /dev/null
-/*
- * 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();
- }
- )
-);
+++ /dev/null
-/*
- * 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)
-);
+++ /dev/null
-/*
- * 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)))
-);
+++ /dev/null
-/*
- * 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
-);
* 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 = () => {
* 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;
// @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();
// @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();
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';
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 {
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 () {
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 () {
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 {
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 {
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 () {
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),
*/
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 {
getMeasuresAppDetailsSecondaryMeasure,
getMeasuresAppDetailsPeriods
, getMeasuresAppComponent
-} from '../../../app/store/rootReducer';
+} from '../../../store/rootReducer';
const mapStateToProps = state => {
return {
*/
import { getMeasuresAndMeta } from '../../../api/measures';
import { enhanceWithLeak } from '../utils';
-import { getMeasuresAppComponent, getMeasuresAppAllMetrics } from '../../../app/store/rootReducer';
+import { getMeasuresAppComponent, getMeasuresAppAllMetrics } from '../../../store/rootReducer';
/*
* Actions
getMeasuresAppDetailsMetric,
isMeasuresAppFetching
, getMeasuresAppComponent
-} from '../../../../app/store/rootReducer';
+} from '../../../../store/rootReducer';
const mapStateToProps = state => {
return {
getMeasuresAppDetailsMetric,
isMeasuresAppFetching
, getMeasuresAppComponent
-} from '../../../../app/store/rootReducer';
+} from '../../../../store/rootReducer';
const mapStateToProps = state => {
return {
*/
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 {
*/
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 {
getMeasuresAppHomeDomains,
getMeasuresAppHomePeriods,
getMeasuresAppComponent
-} from '../../../app/store/rootReducer';
+} from '../../../store/rootReducer';
const mapStateToProps = state => {
return {
getMeasuresAppHomeDomains,
getMeasuresAppHomePeriods,
getMeasuresAppComponent
-} from '../../../app/store/rootReducer';
+} from '../../../store/rootReducer';
const mapStateToProps = state => {
return {
getMeasuresAppHomeDomains,
getMeasuresAppHomePeriods,
getMeasuresAppComponent
-} from '../../../app/store/rootReducer';
+} from '../../../store/rootReducer';
const mapStateToProps = state => {
return {
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';
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';
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
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 () {
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 = {
*/
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)
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 = {
*/
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))
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 = {
getPermissionsAppQuery,
getPermissionsAppFilter,
getPermissionsAppSelectedPermission
-} from '../../../../app/store/rootReducer';
+} from '../../../../store/rootReducer';
const PERMISSIONS_ORDER = [
'admin',
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 = {
getPermissionsAppQuery,
getPermissionsAppFilter,
getPermissionsAppSelectedPermission
-} from '../../../../app/store/rootReducer';
+} from '../../../../store/rootReducer';
export const loadHolders = () => (dispatch, getState) => {
const query = getPermissionsAppQuery(getState());
getPermissionsAppQuery,
getPermissionsAppFilter,
getPermissionsAppSelectedPermission
-} from '../../../../app/store/rootReducer';
+} from '../../../../store/rootReducer';
class AllHoldersList extends React.Component {
static propTypes = {
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
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 {
getPermissionsAppQuery,
getPermissionsAppFilter,
getPermissionsAppSelectedPermission
-} from '../../../../app/store/rootReducer';
+} from '../../../../store/rootReducer';
export const loadHolders = projectKey => (dispatch, getState) => {
const query = getPermissionsAppQuery(getState());
*/
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 = {
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 = {
addGlobalErrorMessage,
addGlobalSuccessMessage,
closeAllGlobalMessages
-} from '../../../components/store/globalMessages';
+} from '../../../store/globalMessages/duck';
import { reloadUpdateKeyPage } from './utils';
import RecentHistory from '../../../app/components/nav/component/RecentHistory';
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 = {
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 = {
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 = {
getProjectAdminAllProfiles,
getProjectAdminProjectProfiles,
getComponent
-} from '../../../app/store/rootReducer';
+} from '../../../store/rootReducer';
class QualityProfiles extends React.Component {
static propTypes = {
} 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 => ({
} from './modulesByProject';
import globalMessages, {
getGlobalMessages as nextGetGlobalMessages
-} from '../../../components/store/globalMessages';
+} from '../../../store/globalMessages/duck';
const rootReducer = combineReducers({
profiles,
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 () {
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),
*/
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)
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),
*/
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)
*/
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) => ({
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 {
*/
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 => ({
* 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';
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],
*/
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;
*/
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';
* 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'
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)
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)
*/
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 => ({
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 {
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 () {
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 () {
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 = {
*/
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
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 {
getSettingsAppChangedValue,
isSettingsAppLoading,
getSettingsAppValidationMessage
-} from '../../../app/store/rootReducer';
+} from '../../../store/rootReducer';
class Definition extends React.Component {
mounted: boolean;
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) {
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),
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)
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)
*/
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(
() => ({}),
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)
*/
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';
*/
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';
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 = {
// @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]: {} };
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 () {
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 = {
*/
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 => {
*/
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 = {
+++ /dev/null
-/*
- * 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);
-}
+++ /dev/null
-/*
- * 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 <christofferniska@gmail.com>
-// 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;
- };
+++ /dev/null
-/*
- * 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<Message>;
-
-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;
+++ /dev/null
-/*
- * 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 (
- <ComposedComponent
- {...this.props}
- getStore={getStore}
- updateStore={this.handleUpdateStore}/>
- );
- }
- };
-};
-
-export default withStore;
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 = {
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;
*/
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';
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');
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');
--- /dev/null
+/*
+ * 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<string>
+};
+
+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
+);
--- /dev/null
+/*
+ * 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
+});
--- /dev/null
+/*
+ * 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]
+);
--- /dev/null
+/*
+ * 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)
+);
+
--- /dev/null
+/*
+ * 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<Message>;
+
+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;
--- /dev/null
+/*
+ * 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
+});
--- /dev/null
+/*
+ * 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
+);
--- /dev/null
+/*
+ * 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
+});
--- /dev/null
+/*
+ * 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]
+);
--- /dev/null
+/*
+ * 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();
+ }
+ )
+);
--- /dev/null
+/*
+ * 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)
+);
--- /dev/null
+/*
+ * 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)))
+);
--- /dev/null
+/*
+ * 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
+);
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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 <christofferniska@gmail.com>
+// 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;
+ };
--- /dev/null
+/*
+ * 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 (
+ <ComposedComponent
+ {...this.props}
+ getStore={getStore}
+ updateStore={this.handleUpdateStore}/>
+ );
+ }
+ };
+};
+
+export default withStore;