Add clearing inputs after collection create, improved disabled create collection...
[arvados-workbench2.git] / src / store / project / project-reducer.ts
index a329e81242f4b8d7e4fd0ab37555281297a16c56..f5af23ab3a3f6e5501bcd115ab0bf994b79ab0e1 100644 (file)
@@ -4,7 +4,7 @@
 
 import * as _ from "lodash";
 
-import actions, { ProjectAction } from "./project-action";
+import { projectActions, ProjectAction } from "./project-action";
 import { TreeItem, TreeItemStatus } from "../../components/tree/tree";
 import { ProjectResource } from "../../models/project";
 
@@ -16,7 +16,6 @@ export type ProjectState = {
 
 interface ProjectCreator {
     opened: boolean;
-    pending: boolean;
     ownerUuid: string;
     error?: string;
 }
@@ -73,14 +72,14 @@ function updateProjectTree(tree: Array<TreeItem<ProjectResource>>, projects: Pro
     if (parentItemId) {
         treeItem = findTreeItem(tree, parentItemId);
         if (treeItem) {
-            treeItem.status = TreeItemStatus.Loaded;
+            treeItem.status = TreeItemStatus.LOADED;
         }
     }
     const items = projects.map(p => ({
         id: p.uuid,
         open: false,
         active: false,
-        status: TreeItemStatus.Initial,
+        status: TreeItemStatus.INITIAL,
         data: p,
         items: []
     } as TreeItem<ProjectResource>));
@@ -106,14 +105,13 @@ const initialState: ProjectState = {
     currentItemId: "",
     creator: {
         opened: false,
-        pending: false,
         ownerUuid: ""
     }
 };
 
 
-const projectsReducer = (state: ProjectState = initialState, action: ProjectAction) => {
-    return actions.match(action, {
+export const projectsReducer = (state: ProjectState = initialState, action: ProjectAction) => {
+    return projectActions.match(action, {
         OPEN_PROJECT_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
         CLOSE_PROJECT_CREATOR: () => updateCreator(state, { opened: false }),
         CREATE_PROJECT: () => updateCreator(state, { error: undefined }),
@@ -123,7 +121,7 @@ const projectsReducer = (state: ProjectState = initialState, action: ProjectActi
             const items = _.cloneDeep(state.items);
             const item = findTreeItem(items, itemId);
             if (item) {
-                item.status = TreeItemStatus.Pending;
+                item.status = TreeItemStatus.PENDING;
                 state.items = items;
             }
             return { ...state, items };
@@ -139,7 +137,6 @@ const projectsReducer = (state: ProjectState = initialState, action: ProjectActi
             const items = _.cloneDeep(state.items);
             const item = findTreeItem(items, itemId);
             if (item) {
-                item.toggled = true;
                 item.open = !item.open;
             }
             return {
@@ -153,7 +150,6 @@ const projectsReducer = (state: ProjectState = initialState, action: ProjectActi
             resetTreeActivity(items);
             const item = findTreeItem(items, itemId);
             if (item) {
-                item.toggled = true;
                 item.active = true;
             }
             return {
@@ -174,5 +170,3 @@ const projectsReducer = (state: ProjectState = initialState, action: ProjectActi
         default: () => state
     });
 };
-
-export default projectsReducer;