Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
@@ -8,12 +8,13 @@ const initialState = {
|
||||
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
switch (type) {
|
||||
case ActionTypes.AUTHENTICATE_SUCCEEDED:
|
||||
case ActionTypes.AUTHENTICATE__SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
accessToken: payload.accessToken,
|
||||
};
|
||||
case ActionTypes.CURRENT_USER_FETCH_SUCCEEDED:
|
||||
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
return {
|
||||
...state,
|
||||
userId: payload.user.id,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { LOCATION_CHANGE } from 'connected-react-router';
|
||||
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
import ModalTypes from '../constants/ModalTypes';
|
||||
|
||||
const initialState = {
|
||||
isInitializing: true,
|
||||
@@ -15,7 +16,7 @@ export default (state = initialState, { type, payload }) => {
|
||||
...state,
|
||||
currentModal: null,
|
||||
};
|
||||
case ActionTypes.CORE_INITIALIZED:
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
return {
|
||||
...state,
|
||||
isInitializing: false,
|
||||
@@ -25,6 +26,29 @@ export default (state = initialState, { type, payload }) => {
|
||||
...state,
|
||||
currentModal: payload.type,
|
||||
};
|
||||
case ActionTypes.USER_UPDATE_HANDLE:
|
||||
if (state.currentModal === ModalTypes.USERS && payload.isCurrent && !payload.user.isAdmin) {
|
||||
return {
|
||||
...state,
|
||||
currentModal: null,
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
case ActionTypes.PROJECT_MANAGER_DELETE:
|
||||
case ActionTypes.PROJECT_MANAGER_DELETE_HANDLE:
|
||||
if (
|
||||
state.currentModal === ModalTypes.PROJECT_SETTINGS &&
|
||||
payload.isCurrentUser &&
|
||||
payload.isCurrentProject
|
||||
) {
|
||||
return {
|
||||
...state,
|
||||
currentModal: null,
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
import authenticate from './authenticate';
|
||||
import userCreate from './user-create';
|
||||
import projectCreate from './project-create';
|
||||
|
||||
export default combineReducers({
|
||||
authenticate,
|
||||
userCreate,
|
||||
projectCreate,
|
||||
});
|
||||
@@ -5,9 +5,7 @@ import socket from './socket';
|
||||
import orm from './orm';
|
||||
import auth from './auth';
|
||||
import core from './core';
|
||||
import authenticateForm from './forms/authenticate';
|
||||
import userCreateForm from './forms/user-create';
|
||||
import projectCreateForm from './forms/project-create';
|
||||
import ui from './ui';
|
||||
|
||||
export default combineReducers({
|
||||
router,
|
||||
@@ -15,7 +13,5 @@ export default combineReducers({
|
||||
orm,
|
||||
auth,
|
||||
core,
|
||||
authenticateForm,
|
||||
userCreateForm,
|
||||
projectCreateForm,
|
||||
ui,
|
||||
});
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
const initialState = {
|
||||
status: null,
|
||||
isDisconnected: false,
|
||||
};
|
||||
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
export default (state = initialState, { type }) => {
|
||||
switch (type) {
|
||||
case ActionTypes.SOCKET_STATUS_CHANGED:
|
||||
case ActionTypes.SOCKET_DISCONNECT_HANDLE:
|
||||
return {
|
||||
...state,
|
||||
status: payload.status,
|
||||
isDisconnected: true,
|
||||
};
|
||||
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
||||
return {
|
||||
...state,
|
||||
isDisconnected: false,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -18,25 +18,21 @@ export default (state = initialState, { type, payload }) => {
|
||||
...state.data,
|
||||
...payload.data,
|
||||
},
|
||||
isSubmitting: true,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE__SUCCESS:
|
||||
return initialState;
|
||||
case ActionTypes.AUTHENTICATE__FAILURE:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: false,
|
||||
error: payload.error,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE_ERROR_CLEAR:
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE_REQUESTED:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: true,
|
||||
};
|
||||
case ActionTypes.AUTHENTICATE_SUCCEEDED:
|
||||
return initialState;
|
||||
case ActionTypes.AUTHENTICATE_FAILED:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: false,
|
||||
error: payload.error,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
11
client/src/reducers/ui/index.js
Normal file
11
client/src/reducers/ui/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
import authenticateForm from './authenticate-form';
|
||||
import userCreateForm from './user-create-form';
|
||||
import projectCreateForm from './project-create-form';
|
||||
|
||||
export default combineReducers({
|
||||
authenticateForm,
|
||||
userCreateForm,
|
||||
projectCreateForm,
|
||||
});
|
||||
@@ -16,15 +16,11 @@ export default (state = initialState, { type, payload }) => {
|
||||
...state.data,
|
||||
...payload.data,
|
||||
},
|
||||
};
|
||||
case ActionTypes.PROJECT_CREATE_REQUESTED:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: true,
|
||||
};
|
||||
case ActionTypes.PROJECT_CREATE_SUCCEEDED:
|
||||
case ActionTypes.PROJECT_CREATE__SUCCESS:
|
||||
return initialState;
|
||||
case ActionTypes.PROJECT_CREATE_FAILED:
|
||||
case ActionTypes.PROJECT_CREATE__FAILURE:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: false,
|
||||
@@ -19,25 +19,21 @@ export default (state = initialState, { type, payload }) => {
|
||||
...state.data,
|
||||
...payload.data,
|
||||
},
|
||||
isSubmitting: true,
|
||||
};
|
||||
case ActionTypes.USER_CREATE__SUCCESS:
|
||||
return initialState;
|
||||
case ActionTypes.USER_CREATE__FAILURE:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: false,
|
||||
error: payload.error,
|
||||
};
|
||||
case ActionTypes.USER_CREATE_ERROR_CLEAR:
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
};
|
||||
case ActionTypes.USER_CREATE_REQUESTED:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: true,
|
||||
};
|
||||
case ActionTypes.USER_CREATE_SUCCEEDED:
|
||||
return initialState;
|
||||
case ActionTypes.USER_CREATE_FAILED:
|
||||
return {
|
||||
...state,
|
||||
isSubmitting: false,
|
||||
error: payload.error,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
Reference in New Issue
Block a user