Move reducers to separate folders
authorDaniel Kos <daniel.kos@contractors.roche.com>
Wed, 6 Jun 2018 15:01:26 +0000 (17:01 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Wed, 6 Jun 2018 15:01:26 +0000 (17:01 +0200)
Feature #13563

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>:

src/components/api-token/api-token.tsx
src/index.tsx
src/store/auth/auth-action.ts [moved from src/store/auth-action.ts with 94% similarity]
src/store/auth/auth-reducer.ts [moved from src/store/auth-reducer.ts with 91% similarity]
src/store/project/project-action.ts [moved from src/store/project-action.ts with 89% similarity]
src/store/project/project-reducer.ts [moved from src/store/project-reducer.ts with 90% similarity]
src/store/root-reducer.ts [deleted file]
src/store/store.ts
src/views/workbench/workbench.tsx

index bc0caf56dff4e976a2952e185c3cf766f607001a..daebe9b93ca5292952da8107fbc5c9864eaacc80 100644 (file)
@@ -5,7 +5,7 @@
 import { Redirect, RouteProps } from "react-router";
 import * as React from "react";
 import { connect, DispatchProp } from "react-redux";
-import authActions, { getUserDetails } from "../../store/auth-action";
+import authActions, { getUserDetails } from "../../store/auth/auth-action";
 
 interface ApiTokenProps {
 }
index c1785c8b155d8629adf9b20dfc471f203aef959e..cb868eb229c3401e80da78983c031f4ee4e82aac 100644 (file)
@@ -13,7 +13,7 @@ import createBrowserHistory from "history/createBrowserHistory";
 import configureStore from "./store/store";
 import { ConnectedRouter } from "react-router-redux";
 import ApiToken from "./components/api-token/api-token";
-import authActions from "./store/auth-action";
+import authActions from "./store/auth/auth-action";
 
 const history = createBrowserHistory();
 const store = configureStore({
similarity index 94%
rename from src/store/auth-action.ts
rename to src/store/auth/auth-action.ts
index 3343a57e86bc9e7c7a07a2f185c1fd6978f8ebcc..dbf9a0f4190db63905525b41f3185787d25e86f8 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { serverApi } from "../common/server-api";
+import { serverApi } from "../../common/server-api";
 import { ofType, default as unionize, UnionOf } from "unionize";
 import { Dispatch } from "redux";
 
similarity index 91%
rename from src/store/auth-reducer.ts
rename to src/store/auth/auth-reducer.ts
index 7901e62ec5d51b08e2c1e142880ee947fc58a155..730312f7ce1ce88e71422638fe6a437c8fec4bf3 100644 (file)
@@ -3,9 +3,9 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import actions, { AuthAction, UserDetailsResponse } from "./auth-action";
-import { User } from "../models/user";
-import { authService } from "../services/services";
-import { removeServerApiAuthorizationHeader, setServerApiAuthorizationHeader } from "../common/server-api";
+import { User } from "../../models/user";
+import { authService } from "../../services/services";
+import { removeServerApiAuthorizationHeader, setServerApiAuthorizationHeader } from "../../common/server-api";
 
 export interface AuthState {
     user?: User;
similarity index 89%
rename from src/store/project-action.ts
rename to src/store/project/project-action.ts
index 904a34d4f09498319bd78289c9be308bac2c8d5e..8d57d2b932f5345dad6d1010891942395ce07766 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { Project } from "../models/project";
+import { Project } from "../../models/project";
 import { default as unionize, ofType, UnionOf } from "unionize";
 
 const actions = unionize({
similarity index 90%
rename from src/store/project-reducer.ts
rename to src/store/project/project-reducer.ts
index a321265c619e26c22564216c2c7eeb16add908bc..de11d51f1c2e9cfc31a894aaab8425fd4c7e569f 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { Project } from "../models/project";
+import { Project } from "../../models/project";
 import actions, { ProjectAction } from "./project-action";
 
 export type ProjectState = Project[];
diff --git a/src/store/root-reducer.ts b/src/store/root-reducer.ts
deleted file mode 100644 (file)
index 380bd53..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { combineReducers } from "redux";
-import { routerReducer, RouterState } from "react-router-redux";
-import authReducer, { AuthState } from "./auth-reducer";
-import projectsReducer, { ProjectState } from "./project-reducer";
-
-export interface RootState {
-    auth: AuthState,
-    projects: ProjectState,
-    router: RouterState
-}
-
-const rootReducer = combineReducers({
-    auth: authReducer,
-    projects: projectsReducer,
-    router: routerReducer
-});
-
-export default rootReducer;
index d3646e69155b8384fe756effcf976d4b2b59d8c9..d541156e2d3613f6ddd4bd920fb659528c6e1a2b 100644 (file)
@@ -2,17 +2,31 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { createStore, applyMiddleware, compose, Middleware } from 'redux';
-import { default as rootReducer, RootState } from "./root-reducer";
-import { routerMiddleware } from "react-router-redux";
+import { createStore, applyMiddleware, compose, Middleware, combineReducers } from 'redux';
+import { routerMiddleware, routerReducer, RouterState } from "react-router-redux";
 import thunkMiddleware from 'redux-thunk';
 import { History } from "history";
+import projectsReducer, { ProjectState } from "./project/project-reducer";
+import authReducer, { AuthState } from "./auth/auth-reducer";
 
 const composeEnhancers =
     (process.env.NODE_ENV === 'development' &&
     window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
     compose;
 
+export interface RootState {
+    auth: AuthState,
+    projects: ProjectState,
+    router: RouterState
+}
+
+const rootReducer = combineReducers({
+    auth: authReducer,
+    projects: projectsReducer,
+    router: routerReducer
+});
+
+
 export default function configureStore(initialState: RootState, history: History) {
     const middlewares: Middleware[] = [
         routerMiddleware(history),
index b5babde19210391f7af5b8080a16b20a0842fdc5..8c3145b823e1950a58aa2bca49129ab23c0e8023 100644 (file)
@@ -12,18 +12,18 @@ import Typography from '@material-ui/core/Typography';
 import { connect, DispatchProp } from "react-redux";
 import Tree from "../../components/tree/tree";
 import { Project } from "../../models/project";
-import { RootState } from "../../store/root-reducer";
 import ProjectList from "../../components/project-list/project-list";
 import { Route, Switch } from "react-router";
 import { Link } from "react-router-dom";
 import Button from "@material-ui/core/Button/Button";
-import authActions from "../../store/auth-action";
+import authActions from "../../store/auth/auth-action";
 import IconButton from "@material-ui/core/IconButton/IconButton";
 import Menu from "@material-ui/core/Menu/Menu";
 import MenuItem from "@material-ui/core/MenuItem/MenuItem";
 import { AccountCircle } from "@material-ui/icons";
 import { User } from "../../models/user";
 import Grid from "@material-ui/core/Grid/Grid";
+import { RootState } from "../../store/store";
 
 const drawerWidth = 240;