diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-11-21 10:03:40 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-11-28 13:39:04 +0100 |
commit | 3a34147be1e725f71b8e102ba53b1f5b9bd10b13 (patch) | |
tree | 16ab51c591f124cf0e34a7005361392493a6ebc5 /server/sonar-web/src/main/js/apps/permissions | |
parent | bd96be1c6c971381952dff396e0e10ae9233a6b7 (diff) | |
download | sonarqube-3a34147be1e725f71b8e102ba53b1f5b9bd10b13.tar.gz sonarqube-3a34147be1e725f71b8e102ba53b1f5b9bd10b13.zip |
step towards a single-entry-point js app (#1362)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/permissions')
20 files changed, 178 insertions, 157 deletions
diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js index bb7b24fd24b..56343415027 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.js @@ -22,23 +22,23 @@ import { connect } from 'react-redux'; import SearchForm from '../../shared/components/SearchForm'; import HoldersList from '../../shared/components/HoldersList'; import { - loadHolders, - grantToUser, - revokeFromUser, - grantToGroup, - revokeFromGroup, - updateFilter, - updateQuery, - selectPermission + loadHolders, + grantToUser, + revokeFromUser, + grantToGroup, + revokeFromGroup, + updateFilter, + updateQuery, + selectPermission } from '../store/actions'; -import { - getUsers, - getGroups, - getQuery, - getFilter, - getSelectedPermission -} from '../../shared/store/rootReducer'; import { translate } from '../../../../helpers/l10n'; +import { + getPermissionsAppUsers, + getPermissionsAppGroups, + getPermissionsAppQuery, + getPermissionsAppFilter, + getPermissionsAppSelectedPermission +} from '../../../../app/store/rootReducer'; const PERMISSIONS_ORDER = [ 'admin', @@ -102,11 +102,11 @@ class AllHoldersList extends React.Component { } const mapStateToProps = state => ({ - users: getUsers(state), - groups: getGroups(state), - query: getQuery(state), - filter: getFilter(state), - selectedPermission: getSelectedPermission(state) + users: getPermissionsAppUsers(state), + groups: getPermissionsAppGroups(state), + query: getPermissionsAppQuery(state), + filter: getPermissionsAppFilter(state), + selectedPermission: getPermissionsAppSelectedPermission(state) }); const mapDispatchToProps = dispatch => ({ diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js index 23b750a2dd2..299de992836 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/PageHeader.js @@ -21,7 +21,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { translate } from '../../../../helpers/l10n'; import { loadHolders } from '../store/actions'; -import { isLoading } from '../../shared/store/rootReducer'; +import { isPermissionsAppLoading } from '../../../../app/store/rootReducer'; class PageHeader extends React.Component { static propTypes = { @@ -53,7 +53,7 @@ class PageHeader extends React.Component { } const mapStateToProps = state => ({ - loading: isLoading(state) + loading: isPermissionsAppLoading(state) }); const mapDispatchToProps = dispatch => ({ diff --git a/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js index 3a7d1fa158d..207a0cf7e0a 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/global/store/actions.js @@ -19,19 +19,30 @@ */ import * as api from '../../../../api/permissions'; import { parseError } from '../../../code/utils'; -import { raiseError } from '../../shared/store/actions'; import { - getQuery, - getFilter, - getSelectedPermission -} from '../../shared/store/rootReducer'; + raiseError, + REQUEST_HOLDERS, + RECEIVE_HOLDERS_SUCCESS, + UPDATE_QUERY, + UPDATE_FILTER, + SELECT_PERMISSION, + GRANT_PERMISSION_TO_USER, + REVOKE_PERMISSION_TO_USER, + GRANT_PERMISSION_TO_GROUP, + REVOKE_PERMISSION_FROM_GROUP +} from '../../shared/store/actions'; +import { + getPermissionsAppQuery, + getPermissionsAppFilter, + getPermissionsAppSelectedPermission +} from '../../../../app/store/rootReducer'; export const loadHolders = () => (dispatch, getState) => { - const query = getQuery(getState()); - const filter = getFilter(getState()); - const selectedPermission = getSelectedPermission(getState()); + const query = getPermissionsAppQuery(getState()); + const filter = getPermissionsAppFilter(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); - dispatch({ type: 'REQUEST_HOLDERS', query }); + dispatch({ type: REQUEST_HOLDERS, query }); const requests = []; @@ -49,7 +60,7 @@ export const loadHolders = () => (dispatch, getState) => { return Promise.all(requests).then(responses => ( dispatch({ - type: 'RECEIVE_HOLDERS_SUCCESS', + type: RECEIVE_HOLDERS_SUCCESS, users: responses[0], groups: responses[1], query @@ -60,30 +71,30 @@ export const loadHolders = () => (dispatch, getState) => { }; export const updateQuery = (query = '') => dispatch => { - dispatch({ type: 'UPDATE_QUERY', query }); + dispatch({ type: UPDATE_QUERY, query }); if (query.length === 0 || query.length > 2) { dispatch(loadHolders()); } }; export const updateFilter = filter => dispatch => { - dispatch({ type: 'UPDATE_FILTER', filter }); + dispatch({ type: UPDATE_FILTER, filter }); dispatch(loadHolders()); }; export const selectPermission = permission => (dispatch, getState) => { - const selectedPermission = getSelectedPermission(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); if (selectedPermission !== permission) { - dispatch({ type: 'SELECT_PERMISSION', permission }); + dispatch({ type: SELECT_PERMISSION, permission }); } else { - dispatch({ type: 'SELECT_PERMISSION', permission: null }); + dispatch({ type: SELECT_PERMISSION, permission: null }); } dispatch(loadHolders()); }; export const grantToUser = (login, permission) => dispatch => { api.grantPermissionToUser(null, login, permission).then(() => { - dispatch({ type: 'GRANT_PERMISSION_TO_USER', login, permission }); + dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); }).catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); @@ -91,7 +102,7 @@ export const grantToUser = (login, permission) => dispatch => { export const revokeFromUser = (login, permission) => dispatch => { api.revokePermissionFromUser(null, login, permission).then(() => { - dispatch({ type: 'REVOKE_PERMISSION_TO_USER', login, permission }); + dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); }).catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); @@ -100,7 +111,7 @@ export const revokeFromUser = (login, permission) => dispatch => { export const grantToGroup = (groupName, permission) => dispatch => { api.grantPermissionToGroup(null, groupName, permission).then(() => { dispatch({ - type: 'GRANT_PERMISSION_TO_GROUP', + type: GRANT_PERMISSION_TO_GROUP, groupName, permission }); @@ -112,7 +123,7 @@ export const grantToGroup = (groupName, permission) => dispatch => { export const revokeFromGroup = (groupName, permission) => dispatch => { api.revokePermissionFromGroup(null, groupName, permission).then(() => { dispatch({ - type: 'REVOKE_PERMISSION_FROM_GROUP', + type: REVOKE_PERMISSION_FROM_GROUP, groupName, permission }); diff --git a/server/sonar-web/src/main/js/apps/permissions/project/app.js b/server/sonar-web/src/main/js/apps/permissions/project/app.js deleted file mode 100644 index 1646df7ef24..00000000000 --- a/server/sonar-web/src/main/js/apps/permissions/project/app.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import React from 'react'; -import { render } from 'react-dom'; -import { Provider } from 'react-redux'; -import App from './components/App'; -import configureStore from '../../../components/store/configureStore'; -import rootReducer from '../shared/store/rootReducer'; - -window.sonarqube.appStarted.then(options => { - const el = document.querySelector(options.el); - const store = configureStore(rootReducer); - render(( - <Provider store={store}> - <App project={options.component}/> - </Provider> - ), el); -}); diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js index 6dcbe728084..63b041b2fcf 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.js @@ -22,24 +22,24 @@ import { connect } from 'react-redux'; import SearchForm from '../../shared/components/SearchForm'; import HoldersList from '../../shared/components/HoldersList'; import { - loadHolders, - grantToUser, - revokeFromUser, - grantToGroup, - revokeFromGroup, - updateQuery, - updateFilter, - selectPermission + loadHolders, + grantToUser, + revokeFromUser, + grantToGroup, + revokeFromGroup, + updateQuery, + updateFilter, + selectPermission } from '../store/actions'; -import { - getUsers, - getGroups, - getQuery, - getFilter, - getSelectedPermission -} from '../../shared/store/rootReducer'; import { translate } from '../../../../helpers/l10n'; import { PERMISSIONS_ORDER_BY_QUALIFIER } from '../constants'; +import { + getPermissionsAppUsers, + getPermissionsAppGroups, + getPermissionsAppQuery, + getPermissionsAppFilter, + getPermissionsAppSelectedPermission +} from '../../../../app/store/rootReducer'; class AllHoldersList extends React.Component { static propTypes = { @@ -128,11 +128,11 @@ class AllHoldersList extends React.Component { } const mapStateToProps = state => ({ - users: getUsers(state), - groups: getGroups(state), - query: getQuery(state), - filter: getFilter(state), - selectedPermission: getSelectedPermission(state) + users: getPermissionsAppUsers(state), + groups: getPermissionsAppGroups(state), + query: getPermissionsAppQuery(state), + filter: getPermissionsAppFilter(state), + selectedPermission: getPermissionsAppSelectedPermission(state) }); const mapDispatchToProps = dispatch => ({ diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js index d8bc447fa08..ba2b4e44e2e 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/App.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/App.js @@ -27,15 +27,19 @@ import '../../styles.css'; export default class App extends React.Component { static propTypes = { - project: React.PropTypes.object.isRequired + component: React.PropTypes.object }; render () { + if (!this.props.component) { + return null; + } + return ( <div className="page page-limited"> - <PageHeader project={this.props.project}/> + <PageHeader project={this.props.component}/> <PageError/> - <AllHoldersList project={this.props.project}/> + <AllHoldersList project={this.props.component}/> </div> ); } diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js index db60031625d..14fcf947ee9 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.js @@ -22,7 +22,7 @@ import { connect } from 'react-redux'; import { translate } from '../../../../helpers/l10n'; import ApplyTemplateView from '../views/ApplyTemplateView'; import { loadHolders } from '../store/actions'; -import { isLoading } from '../../shared/store/rootReducer'; +import { isPermissionsAppLoading } from '../../../../app/store/rootReducer'; class PageHeader extends React.Component { static propTypes = { @@ -76,7 +76,7 @@ class PageHeader extends React.Component { } const mapStateToProps = state => ({ - loading: isLoading(state) + loading: isPermissionsAppLoading(state) }); const mapDispatchToProps = dispatch => ({ diff --git a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js index 5011dc075ad..b705876a6a2 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/project/store/actions.js @@ -19,19 +19,30 @@ */ import * as api from '../../../../api/permissions'; import { parseError } from '../../../code/utils'; -import { raiseError } from '../../shared/store/actions'; import { - getQuery, - getFilter, - getSelectedPermission -} from '../../shared/store/rootReducer'; + raiseError, + REQUEST_HOLDERS, + RECEIVE_HOLDERS_SUCCESS, + UPDATE_QUERY, + UPDATE_FILTER, + SELECT_PERMISSION, + GRANT_PERMISSION_TO_USER, + REVOKE_PERMISSION_TO_USER, + GRANT_PERMISSION_TO_GROUP, + REVOKE_PERMISSION_FROM_GROUP +} from '../../shared/store/actions'; +import { + getPermissionsAppQuery, + getPermissionsAppFilter, + getPermissionsAppSelectedPermission +} from '../../../../app/store/rootReducer'; export const loadHolders = projectKey => (dispatch, getState) => { - const query = getQuery(getState()); - const filter = getFilter(getState()); - const selectedPermission = getSelectedPermission(getState()); + const query = getPermissionsAppQuery(getState()); + const filter = getPermissionsAppFilter(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); - dispatch({ type: 'REQUEST_HOLDERS', query }); + dispatch({ type: REQUEST_HOLDERS, query }); const requests = []; @@ -51,7 +62,7 @@ export const loadHolders = projectKey => (dispatch, getState) => { return Promise.all(requests).then(responses => ( dispatch({ - type: 'RECEIVE_HOLDERS_SUCCESS', + type: RECEIVE_HOLDERS_SUCCESS, users: responses[0], groups: responses[1], query @@ -62,30 +73,30 @@ export const loadHolders = projectKey => (dispatch, getState) => { }; export const updateQuery = (projectKey, query = '') => dispatch => { - dispatch({ type: 'UPDATE_QUERY', query }); + dispatch({ type: UPDATE_QUERY, query }); if (query.length === 0 || query.length > 2) { dispatch(loadHolders(projectKey)); } }; export const updateFilter = (projectKey, filter) => dispatch => { - dispatch({ type: 'UPDATE_FILTER', filter }); + dispatch({ type: UPDATE_FILTER, filter }); dispatch(loadHolders(projectKey)); }; export const selectPermission = (projectKey, permission) => (dispatch, getState) => { - const selectedPermission = getSelectedPermission(getState()); + const selectedPermission = getPermissionsAppSelectedPermission(getState()); if (selectedPermission !== permission) { - dispatch({ type: 'SELECT_PERMISSION', permission }); + dispatch({ type: SELECT_PERMISSION, permission }); } else { - dispatch({ type: 'SELECT_PERMISSION', permission: null }); + dispatch({ type: SELECT_PERMISSION, permission: null }); } dispatch(loadHolders(projectKey)); }; export const grantToUser = (projectKey, login, permission) => dispatch => { api.grantPermissionToUser(projectKey, login, permission).then(() => { - dispatch({ type: 'GRANT_PERMISSION_TO_USER', login, permission }); + dispatch({ type: GRANT_PERMISSION_TO_USER, login, permission }); }).catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); @@ -93,7 +104,7 @@ export const grantToUser = (projectKey, login, permission) => dispatch => { export const revokeFromUser = (projectKey, login, permission) => dispatch => { api.revokePermissionFromUser(projectKey, login, permission).then(() => { - dispatch({ type: 'REVOKE_PERMISSION_TO_USER', login, permission }); + dispatch({ type: REVOKE_PERMISSION_TO_USER, login, permission }); }).catch(e => { return parseError(e).then(message => dispatch(raiseError(message))); }); @@ -102,7 +113,7 @@ export const revokeFromUser = (projectKey, login, permission) => dispatch => { export const grantToGroup = (projectKey, groupName, permission) => dispatch => { api.grantPermissionToGroup(projectKey, groupName, permission).then(() => { dispatch({ - type: 'GRANT_PERMISSION_TO_GROUP', + type: GRANT_PERMISSION_TO_GROUP, groupName, permission }); @@ -114,7 +125,7 @@ export const grantToGroup = (projectKey, groupName, permission) => dispatch => { export const revokeFromGroup = (projectKey, groupName, permission) => dispatch => { api.revokePermissionFromGroup(projectKey, groupName, permission).then(() => { dispatch({ - type: 'REVOKE_PERMISSION_FROM_GROUP', + type: REVOKE_PERMISSION_FROM_GROUP, groupName, permission }); diff --git a/server/sonar-web/src/main/js/apps/permissions/global/app.js b/server/sonar-web/src/main/js/apps/permissions/routes.js index db8e2981d9c..a273a2914b6 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/app.js +++ b/server/sonar-web/src/main/js/apps/permissions/routes.js @@ -18,18 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; -import { render } from 'react-dom'; -import { Provider } from 'react-redux'; -import App from './components/App'; -import configureStore from '../../../components/store/configureStore'; -import rootReducer from '../shared/store/rootReducer'; +import { IndexRoute } from 'react-router'; +import GlobalPermissionsApp from './global/components/App'; +import ProjectPermissionsApp from './project/components/App'; -window.sonarqube.appStarted.then(options => { - const el = document.querySelector(options.el); - const store = configureStore(rootReducer); - render(( - <Provider store={store}> - <App/> - </Provider> - ), el); -}); +export const globalPermissionsRoutes = ( + <IndexRoute component={GlobalPermissionsApp}/> +); + +export const projectPermissionsRoutes = ( + <IndexRoute component={ProjectPermissionsApp}/> +); diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js b/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js index 3449153a921..289a6c196a0 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PageError.js @@ -19,7 +19,7 @@ */ import React from 'react'; import { connect } from 'react-redux'; -import { getError } from '../store/rootReducer'; +import { getPermissionsAppError } from '../../../../app/store/rootReducer'; class PageError extends React.Component { static propTypes = { @@ -42,7 +42,7 @@ class PageError extends React.Component { } const mapStateToProps = state => ({ - message: getError(state) + message: getPermissionsAppError(state) }); export default connect( diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/actions.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/actions.js index be7cee4a4b7..ceed4f2f9ec 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/actions.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/actions.js @@ -17,7 +17,18 @@ * 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_HOLDERS_SUCCESS = 'permissions/RECEIVE_HOLDERS_SUCCESS'; +export const GRANT_PERMISSION_TO_GROUP = 'permissions/GRANT_PERMISSION_TO_GROUP'; +export const REVOKE_PERMISSION_FROM_GROUP = 'permissions/REVOKE_PERMISSION_FROM_GROUP'; +export const GRANT_PERMISSION_TO_USER = 'permissions/GRANT_PERMISSION_TO_USER'; +export const REVOKE_PERMISSION_TO_USER = 'permissions/REVOKE_PERMISSION_TO_USER'; +export const UPDATE_FILTER = 'permissions/UPDATE_FILTER'; +export const UPDATE_QUERY = 'permissions/UPDATE_QUERY'; +export const SELECT_PERMISSION = 'permissions/SELECT_PERMISSION'; +export const REQUEST_HOLDERS = 'permissions/REQUEST_HOLDERS'; +export const ERROR = 'permissions/ERROR'; + export const raiseError = message => ({ - type: 'ERROR', + type: ERROR, message }); diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/error.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/error.js index 6fe0ec764c3..b56a9ee6cbf 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/error.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/error.js @@ -17,15 +17,24 @@ * 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_HOLDERS_SUCCESS, + GRANT_PERMISSION_TO_USER, + REVOKE_PERMISSION_TO_USER, + GRANT_PERMISSION_TO_GROUP, + REVOKE_PERMISSION_FROM_GROUP, + ERROR +} from './actions'; + const error = (state = null, action = {}) => { switch (action.type) { - case 'RECEIVE_HOLDERS_SUCCESS': - case 'GRANT_PERMISSION_TO_USER': - case 'REVOKE_PERMISSION_TO_USER': - case 'GRANT_PERMISSION_TO_GROUP': - case 'REVOKE_PERMISSION_FROM_GROUP': + case RECEIVE_HOLDERS_SUCCESS: + case GRANT_PERMISSION_TO_USER: + case REVOKE_PERMISSION_TO_USER: + case GRANT_PERMISSION_TO_GROUP: + case REVOKE_PERMISSION_FROM_GROUP: return null; - case 'ERROR': + case ERROR: return action.message; default: return state; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/filter.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/filter.js index 6934582b425..65fa36db24d 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/filter.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/filter.js @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { UPDATE_FILTER } from './actions'; + const filter = (state = 'all', action = {}) => { switch (action.type) { - case 'UPDATE_FILTER': + case UPDATE_FILTER: return action.filter; default: return state; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/byName.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/byName.js index c1475aa6763..a015820d0df 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/byName.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/byName.js @@ -18,16 +18,17 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import keyBy from 'lodash/keyBy'; +import { RECEIVE_HOLDERS_SUCCESS, GRANT_PERMISSION_TO_GROUP, REVOKE_PERMISSION_FROM_GROUP } from '../actions'; const byName = (state = {}, action = {}) => { - if (action.type === 'RECEIVE_HOLDERS_SUCCESS') { + if (action.type === RECEIVE_HOLDERS_SUCCESS) { const newGroups = keyBy(action.groups, 'name'); return { ...state, ...newGroups }; - } else if (action.type === 'GRANT_PERMISSION_TO_GROUP') { + } else if (action.type === GRANT_PERMISSION_TO_GROUP) { const newGroup = { ...state[action.groupName] }; newGroup.permissions = [...newGroup.permissions, action.permission]; return { ...state, [action.groupName]: newGroup }; - } else if (action.type === 'REVOKE_PERMISSION_FROM_GROUP') { + } else if (action.type === REVOKE_PERMISSION_FROM_GROUP) { const newGroup = { ...state[action.groupName] }; newGroup.permissions = newGroup.permissions .filter(p => p !== action.permission); diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/names.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/names.js index 8451a26999e..4dbf7b34c8d 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/names.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/groups/names.js @@ -17,8 +17,10 @@ * 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_HOLDERS_SUCCESS } from '../actions'; + const names = (state = [], action = {}) => { - if (action.type === 'RECEIVE_HOLDERS_SUCCESS') { + if (action.type === RECEIVE_HOLDERS_SUCCESS) { return action.groups.map(group => group.name); } else { return state; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/loading.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/loading.js index b7ff6d172bc..87d7ee4d900 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/loading.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/loading.js @@ -17,11 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { REQUEST_HOLDERS, RECEIVE_HOLDERS_SUCCESS } from './actions'; + const loading = (state = false, action = {}) => { switch (action.type) { - case 'REQUEST_HOLDERS': + case REQUEST_HOLDERS: return true; - case 'RECEIVE_HOLDERS_SUCCESS': + case RECEIVE_HOLDERS_SUCCESS: return false; default: return state; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/query.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/query.js index 49a755a3fee..b8dbc36a794 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/query.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/query.js @@ -17,10 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { UPDATE_QUERY, REQUEST_HOLDERS } from './actions'; + const query = (state = '', action = {}) => { switch (action.type) { - case 'UPDATE_QUERY': - case 'REQUEST_HOLDERS': + case UPDATE_QUERY: + case REQUEST_HOLDERS: return action.query; default: return state; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/selectedPermission.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/selectedPermission.js index c4e951745d7..b44531e3c12 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/selectedPermission.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/selectedPermission.js @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { SELECT_PERMISSION } from './actions'; + const selectedPermission = (state = null, action = {}) => { switch (action.type) { - case 'SELECT_PERMISSION': + case SELECT_PERMISSION: return action.permission; default: return state; diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/users/byLogin.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/users/byLogin.js index a571966cd92..fd3d21db256 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/users/byLogin.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/users/byLogin.js @@ -18,16 +18,17 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import keyBy from 'lodash/keyBy'; +import { RECEIVE_HOLDERS_SUCCESS, GRANT_PERMISSION_TO_USER, REVOKE_PERMISSION_TO_USER } from '../actions'; const byLogin = (state = {}, action = {}) => { - if (action.type === 'RECEIVE_HOLDERS_SUCCESS') { + if (action.type === RECEIVE_HOLDERS_SUCCESS) { const newUsers = keyBy(action.users, 'login'); return { ...state, ...newUsers }; - } else if (action.type === 'GRANT_PERMISSION_TO_USER') { + } else if (action.type === GRANT_PERMISSION_TO_USER) { const newUser = { ...state[action.login] }; newUser.permissions = [...newUser.permissions, action.permission]; return { ...state, [action.login]: newUser }; - } else if (action.type === 'REVOKE_PERMISSION_TO_USER') { + } else if (action.type === REVOKE_PERMISSION_TO_USER) { const newUser = { ...state[action.login] }; newUser.permissions = newUser.permissions .filter(p => p !== action.permission); diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/store/users/logins.js b/server/sonar-web/src/main/js/apps/permissions/shared/store/users/logins.js index b0bc1e31ca0..ad32bdc8573 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/store/users/logins.js +++ b/server/sonar-web/src/main/js/apps/permissions/shared/store/users/logins.js @@ -17,8 +17,10 @@ * 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_HOLDERS_SUCCESS } from '../actions'; + const logins = (state = [], action = {}) => { - if (action.type === 'RECEIVE_HOLDERS_SUCCESS') { + if (action.type === RECEIVE_HOLDERS_SUCCESS) { return action.users.map(user => user.login); } else { return state; |