[ARVADOS-WORKBENCH2] updated: 1.2.0-171-gcda707f

Git user git at public.curoverse.com
Mon Aug 27 10:38:53 EDT 2018


Summary of changes:
 src/index.tsx                                      |  2 +-
 src/routes/routes.ts                               |  2 +-
 src/store/navigation/navigation-action.ts          | 84 +------------------
 src/store/project-panel/project-panel-action.ts    |  2 +-
 src/store/projects/project-create-actions.ts       | 22 +----
 src/store/projects/project-move-actions.ts         | 17 +---
 src/store/projects/project-update-actions.ts       | 14 +---
 .../side-panel-tree/side-panel-tree-actions.ts     | 32 ++++----
 src/store/tree-picker/tree-picker-reducer.ts       | 19 +++--
 .../workbench-actions.ts}                          | 93 ++++++++++++++--------
 src/views-components/api-token/api-token.tsx       |  7 +-
 .../create-collection-dialog-with-selected.tsx     | 29 -------
 .../dialog-forms/create-project-dialog.ts          |  5 +-
 .../dialog-forms/move-project-dialog.ts            |  2 +-
 .../dialog-forms/update-project-dialog.ts          |  5 +-
 src/views/workbench/workbench.tsx                  |  2 -
 16 files changed, 118 insertions(+), 219 deletions(-)
 copy src/store/{navigation/navigation-action.ts => workbench/workbench-actions.ts} (50%)
 delete mode 100644 src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx

       via  cda707f957a027a484f24f44090a4e5b995572a8 (commit)
      from  b979b48045c915f0ea95bb95d591f8ac306ddf06 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit cda707f957a027a484f24f44090a4e5b995572a8
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 27 16:38:38 2018 +0200

    Delegate workbench refreshing actions from project dialog actions
    
    Feature #14102
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/index.tsx b/src/index.tsx
index ad77162..c7f76c6 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -28,7 +28,7 @@ import { collectionFilesItemActionSet } from './views-components/context-menu/ac
 import { collectionActionSet } from './views-components/context-menu/action-sets/collection-action-set';
 import { collectionResourceActionSet } from './views-components/context-menu/action-sets/collection-resource-action-set';
 import { addRouteChangeHandlers } from './routes/routes';
-import { loadWorkbench } from './store/navigation/navigation-action';
+import { loadWorkbench } from './store/workbench/workbench-actions';
 import { Routes } from '~/routes/routes';
 
 const getBuildNumber = () => "BN-" + (process.env.REACT_APP_BUILD_NUMBER || "dev");
diff --git a/src/routes/routes.ts b/src/routes/routes.ts
index cacdd4b..0279bb0 100644
--- a/src/routes/routes.ts
+++ b/src/routes/routes.ts
@@ -8,7 +8,7 @@ import { matchPath } from 'react-router';
 import { ResourceKind, RESOURCE_UUID_PATTERN, extractUuidKind } from '~/models/resource';
 import { getProjectUrl } from '../models/project';
 import { getCollectionUrl } from '~/models/collection';
-import { loadProject, loadFavorites, loadCollection } from '../store/navigation/navigation-action';
+import { loadProject, loadFavorites, loadCollection } from '../store/workbench/workbench-actions';
 
 export const Routes = {
     ROOT: '/',
diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts
index 3256846..1d36bee 100644
--- a/src/store/navigation/navigation-action.ts
+++ b/src/store/navigation/navigation-action.ts
@@ -4,24 +4,12 @@
 
 import { Dispatch, compose } from 'redux';
 import { push } from "react-router-redux";
-import { RootState } from "../store";
-import { ResourceKind, Resource, extractUuidKind } from '~/models/resource';
+import { ResourceKind, extractUuidKind } from '~/models/resource';
 import { getCollectionUrl } from "~/models/collection";
 import { getProjectUrl } from "~/models/project";
-import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
-import { loadCollectionPanel } from '~/store/collection-panel/collection-panel-action';
-import { snackbarActions } from '../snackbar/snackbar-actions';
-import { resourceLabel } from "~/common/labels";
-import { loadFavoritePanel } from '../favorite-panel/favorite-panel-action';
-import { openProjectPanel, projectPanelActions } from '~/store/project-panel/project-panel-action';
-import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory } from '../side-panel-tree/side-panel-tree-actions';
+
+import { SidePanelTreeCategory } from '../side-panel-tree/side-panel-tree-actions';
 import { Routes } from '~/routes/routes';
-import { loadResource } from '../resources/resources-actions';
-import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
-import { projectPanelColumns } from '~/views/project-panel/project-panel';
-import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
-import { matchRootRoute } from '~/routes/routes';
-import { setCollectionBreadcrumbs, setProjectBreadcrumbs, setSidePanelBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
 
 export const navigateTo = (uuid: string) =>
     async (dispatch: Dispatch) => {
@@ -36,74 +24,8 @@ export const navigateTo = (uuid: string) =>
         }
     };
 
-export const loadWorkbench = () =>
-    async (dispatch: Dispatch, getState: () => RootState) => {
-        const { auth, router } = getState();
-        const { user } = auth;
-        if (user) {
-            const userResource = await dispatch<any>(loadResource(user.uuid));
-            if (userResource) {
-                dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
-                dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
-                dispatch<any>(initSidePanelTree());
-                if (router.location) {
-                    const match = matchRootRoute(router.location.pathname);
-                    if (match) {
-                        dispatch(navigateToProject(userResource.uuid));
-                    }
-                }
-            } else {
-                dispatch(userIsNotAuthenticated);
-            }
-        } else {
-            dispatch(userIsNotAuthenticated);
-        }
-    };
-
 export const navigateToFavorites = push(Routes.FAVORITES);
 
-export const loadFavorites = () =>
-    (dispatch: Dispatch) => {
-        dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
-        dispatch<any>(loadFavoritePanel());
-        dispatch<any>(setSidePanelBreadcrumbs(SidePanelTreeCategory.FAVORITES));
-    };
-
-
 export const navigateToProject = compose(push, getProjectUrl);
 
-export const loadProject = (uuid: string) =>
-    async (dispatch: Dispatch) => {
-        await dispatch<any>(activateSidePanelTreeItem(uuid));
-        dispatch<any>(setProjectBreadcrumbs(uuid));
-        dispatch<any>(openProjectPanel(uuid));
-        dispatch(loadDetailsPanel(uuid));
-    };
-
 export const navigateToCollection = compose(push, getCollectionUrl);
-
-export const loadCollection = (uuid: string) =>
-    async (dispatch: Dispatch) => {
-        const collection = await dispatch<any>(loadCollectionPanel(uuid));
-        await dispatch<any>(activateSidePanelTreeItem(collection.ownerUuid));
-        dispatch<any>(setCollectionBreadcrumbs(collection.uuid));
-        dispatch(loadDetailsPanel(uuid));
-    };
-
-export const cannotNavigateToResource = ({ kind, uuid }: Resource) =>
-    snackbarActions.OPEN_SNACKBAR({
-        message: `${resourceLabel(kind)} identified by ${uuid} cannot be opened.`
-    });
-
-export const resourceIsNotLoaded = (uuid: string) =>
-    snackbarActions.OPEN_SNACKBAR({
-        message: `Resource identified by ${uuid} is not loaded.`
-    });
-
-export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
-    message: 'User is not authenticated'
-});
-
-export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
-    message: 'Could not load user'
-});
\ No newline at end of file
diff --git a/src/store/project-panel/project-panel-action.ts b/src/store/project-panel/project-panel-action.ts
index 4904103..6e63901 100644
--- a/src/store/project-panel/project-panel-action.ts
+++ b/src/store/project-panel/project-panel-action.ts
@@ -18,5 +18,5 @@ export const openProjectPanel = (projectUuid: string) =>
         dispatch(projectPanelActions.REQUEST_ITEMS());
     };
 
-export const getProjectPanelCurrentUuid = (state: RootState) => getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties);
+export const getProjectPanelCurrentUuid = (state: RootState) => getProperty<string>(PROJECT_PANEL_CURRENT_UUID)(state.properties);
 
diff --git a/src/store/projects/project-create-actions.ts b/src/store/projects/project-create-actions.ts
index d1bc827..76f2059 100644
--- a/src/store/projects/project-create-actions.ts
+++ b/src/store/projects/project-create-actions.ts
@@ -5,15 +5,11 @@
 import { Dispatch } from "redux";
 import { reset, startSubmit, stopSubmit, initialize } from 'redux-form';
 import { RootState } from '~/store/store';
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { dialogActions } from "~/store/dialog/dialog-actions";
-import { projectPanelActions } from '~/store/project-panel/project-panel-action';
-import { getProjectList } from '~/store/project/project-action';
 import { getCommonResourceServiceError, CommonResourceServiceError } from '~/common/api/common-resource-service';
 import { ProjectResource } from '~/models/project';
 import { ServiceRepository } from '~/services/services';
 
-
 export interface ProjectCreateFormDialogData {
     ownerUuid: string;
     name: string;
@@ -28,29 +24,19 @@ export const openProjectCreateDialog = (ownerUuid: string) =>
         dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_CREATE_FORM_NAME, data: {} }));
     };
 
-export const addProject = (data: ProjectCreateFormDialogData) =>
-    async (dispatch: Dispatch) => {
-        await dispatch<any>(createProject(data));
-        dispatch(snackbarActions.OPEN_SNACKBAR({
-            message: "Project has been successfully created.",
-            hideDuration: 2000
-        }));
-    };
-
-
-const createProject = (project: Partial<ProjectResource>) =>
+export const createProject = (project: Partial<ProjectResource>) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(startSubmit(PROJECT_CREATE_FORM_NAME));
         try {
             const newProject = await services.projectService.create(project);
-            dispatch<any>(getProjectList(newProject.ownerUuid));
-            dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_CREATE_FORM_NAME }));
             dispatch(reset(PROJECT_CREATE_FORM_NAME));
+            return newProject;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
                 dispatch(stopSubmit(PROJECT_CREATE_FORM_NAME, { name: 'Project with the same name already exists.' }));
             }
+            return undefined;
         }
-    };
\ No newline at end of file
+    };
diff --git a/src/store/projects/project-move-actions.ts b/src/store/projects/project-move-actions.ts
index 52d17ac..6e24314 100644
--- a/src/store/projects/project-move-actions.ts
+++ b/src/store/projects/project-move-actions.ts
@@ -8,12 +8,8 @@ import { startSubmit, stopSubmit, initialize } from 'redux-form';
 import { ServiceRepository } from '~/services/services';
 import { RootState } from '~/store/store';
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { projectPanelActions } from '~/store/project-panel/project-panel-action';
-import { getProjectList } from '~/store/project/project-action';
 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
 import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
-import { findTreeItem } from '~/store/project/project-reducer';
 
 export const PROJECT_MOVE_FORM_NAME = 'projectMoveFormName';
 
@@ -29,15 +25,9 @@ export const moveProject = (resource: MoveToFormDialogData) =>
         dispatch(startSubmit(PROJECT_MOVE_FORM_NAME));
         try {
             const project = await services.projectService.get(resource.uuid);
-            await services.projectService.update(resource.uuid, { ...project, ownerUuid: resource.ownerUuid });
-            dispatch(projectPanelActions.REQUEST_ITEMS());
-            dispatch<any>(getProjectList(project.ownerUuid));
-            const { projects } = getState();
-            if (findTreeItem(projects.items, resource.ownerUuid)) {
-                dispatch<any>(getProjectList(resource.ownerUuid));
-            }
+            const newProject = await services.projectService.update(resource.uuid, { ...project, ownerUuid: resource.ownerUuid });
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_MOVE_FORM_NAME }));
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000 }));
+            return newProject;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
@@ -46,7 +36,8 @@ export const moveProject = (resource: MoveToFormDialogData) =>
                 dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'Cannot move a project into itself.' }));
             } else {
                 dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_MOVE_FORM_NAME }));
-                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the project.', hideDuration: 2000 }));
+                throw new Error('Could not move the project.');
             }
+            return;
         }
     };
diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts
index dac931e..7a4ed89 100644
--- a/src/store/projects/project-update-actions.ts
+++ b/src/store/projects/project-update-actions.ts
@@ -29,29 +29,19 @@ export const openProjectUpdateDialog = (resource: ContextMenuResource) =>
         dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: {} }));
     };
 
-export const editProject = (data: ProjectUpdateFormDialogData) =>
-    async (dispatch: Dispatch) => {
-        await dispatch<any>(updateProject(data));
-        dispatch(snackbarActions.OPEN_SNACKBAR({
-            message: "Project has been successfully updated.",
-            hideDuration: 2000
-        }));
-    };
-
 export const updateProject = (project: Partial<ProjectResource>) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const uuid = project.uuid || '';
         dispatch(startSubmit(PROJECT_UPDATE_FORM_NAME));
         try {
             const updatedProject = await services.projectService.update(uuid, project);
-            dispatch(projectPanelActions.REQUEST_ITEMS());
-            dispatch<any>(getProjectList(updatedProject.ownerUuid));
-            dispatch<any>(loadDetailsPanel(updatedProject.uuid));
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME }));
+            return updatedProject;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
                 dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' }));
             }
+            return ;
         }
     };
\ No newline at end of file
diff --git a/src/store/side-panel-tree/side-panel-tree-actions.ts b/src/store/side-panel-tree/side-panel-tree-actions.ts
index 574bda9..8fbc375 100644
--- a/src/store/side-panel-tree/side-panel-tree-actions.ts
+++ b/src/store/side-panel-tree/side-panel-tree-actions.ts
@@ -11,7 +11,7 @@ import { FilterBuilder } from '~/common/api/filter-builder';
 import { resourcesActions } from '../resources/resources-actions';
 import { getTreePicker, TreePicker } from '../tree-picker/tree-picker';
 import { TreeItemStatus } from "~/components/tree/tree";
-import { getNodeAncestors, getNodeValue, getNodeAncestorsIds } from '~/models/tree';
+import { getNodeAncestors, getNodeValue, getNodeAncestorsIds, getNode } from '~/models/tree';
 import { ProjectResource } from '~/models/project';
 
 export enum SidePanelTreeCategory {
@@ -71,19 +71,23 @@ export const initSidePanelTree = () =>
 
 export const loadSidePanelTreeProjects = (projectUuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ nodeId: projectUuid, pickerId: SIDE_PANEL_TREE }));
-        const params = {
-            filters: new FilterBuilder()
-                .addEqual('ownerUuid', projectUuid)
-                .getFilters()
-        };
-        const { items } = await services.projectService.list(params);
-        dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
-            nodeId: projectUuid,
-            pickerId: SIDE_PANEL_TREE,
-            nodes: items.map(item => createTreePickerNode({ nodeId: item.uuid, value: item })),
-        }));
-        dispatch(resourcesActions.SET_RESOURCES(items));
+        const treePicker = getTreePicker(SIDE_PANEL_TREE)(getState().treePicker);
+        const node = treePicker ? getNode(projectUuid)(treePicker) : undefined;
+        if (node || projectUuid === '') {
+            dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ nodeId: projectUuid, pickerId: SIDE_PANEL_TREE }));
+            const params = {
+                filters: new FilterBuilder()
+                    .addEqual('ownerUuid', projectUuid)
+                    .getFilters()
+            };
+            const { items } = await services.projectService.list(params);
+            dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
+                nodeId: projectUuid,
+                pickerId: SIDE_PANEL_TREE,
+                nodes: items.map(item => createTreePickerNode({ nodeId: item.uuid, value: item })),
+            }));
+            dispatch(resourcesActions.SET_RESOURCES(items));
+        }
     };
 
 export const activateSidePanelTreeItem = (nodeId: string) =>
diff --git a/src/store/tree-picker/tree-picker-reducer.ts b/src/store/tree-picker/tree-picker-reducer.ts
index 8eaada6..b0d9bc9 100644
--- a/src/store/tree-picker/tree-picker-reducer.ts
+++ b/src/store/tree-picker/tree-picker-reducer.ts
@@ -7,6 +7,7 @@ import { TreePicker, TreePickerNode } from "./tree-picker";
 import { treePickerActions, TreePickerAction } from "./tree-picker-actions";
 import { TreeItemStatus } from "~/components/tree/tree";
 import { compose } from "redux";
+import { getNode } from '../../models/tree';
 
 export const treePickerReducer = (state: TreePicker = {}, action: TreePickerAction) =>
     treePickerActions.match(action, {
@@ -50,11 +51,19 @@ const toggleSelect = (nodeId: string) => (value: TreePickerNode): TreePickerNode
         ? ({ ...value, selected: !value.selected })
         : ({ ...value, selected: false });
 
-const receiveNodes = (nodes: Array<TreePickerNode>) => (parent: string) => (state: Tree<TreePickerNode>) =>
-    nodes.reduce((tree, node) =>
-        setNode(
-            createTreeNode(parent)(node)
-        )(tree), state);
+const receiveNodes = (nodes: Array<TreePickerNode>) => (parent: string) => (state: Tree<TreePickerNode>) => {
+    const parentNode = getNode(parent)(state);
+    let newState = state;
+    if (parentNode) {
+        newState = setNode({ ...parentNode, children: [] })(state);
+    }
+    return nodes.reduce((tree, node) => {
+        const oldNode = getNode(node.nodeId)(state) || { value: {} };
+        const newNode = createTreeNode(parent)(node);
+        const value = { ...oldNode.value, ...newNode.value };
+        return setNode({ ...newNode, value })(tree);
+    }, newState);
+};
 
 const createTreeNode = (parent: string) => (node: TreePickerNode): TreeNode<TreePickerNode> => ({
     children: [],
diff --git a/src/store/navigation/navigation-action.ts b/src/store/workbench/workbench-actions.ts
similarity index 50%
copy from src/store/navigation/navigation-action.ts
copy to src/store/workbench/workbench-actions.ts
index 3256846..4a0756c 100644
--- a/src/store/navigation/navigation-action.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -2,39 +2,29 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { Dispatch, compose } from 'redux';
-import { push } from "react-router-redux";
+import { Dispatch } from 'redux';
 import { RootState } from "../store";
-import { ResourceKind, Resource, extractUuidKind } from '~/models/resource';
-import { getCollectionUrl } from "~/models/collection";
-import { getProjectUrl } from "~/models/project";
 import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
 import { loadCollectionPanel } from '~/store/collection-panel/collection-panel-action';
 import { snackbarActions } from '../snackbar/snackbar-actions';
-import { resourceLabel } from "~/common/labels";
 import { loadFavoritePanel } from '../favorite-panel/favorite-panel-action';
 import { openProjectPanel, projectPanelActions } from '~/store/project-panel/project-panel-action';
-import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory } from '../side-panel-tree/side-panel-tree-actions';
-import { Routes } from '~/routes/routes';
+import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory, loadSidePanelTreeProjects } from '../side-panel-tree/side-panel-tree-actions';
 import { loadResource } from '../resources/resources-actions';
 import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
 import { projectPanelColumns } from '~/views/project-panel/project-panel';
 import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
 import { matchRootRoute } from '~/routes/routes';
 import { setCollectionBreadcrumbs, setProjectBreadcrumbs, setSidePanelBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
+import { navigateToProject } from '../navigation/navigation-action';
+import * as projectCreateActions from '~/store/projects/project-create-actions';
+import * as projectMoveActions from '~/store/projects/project-move-actions';
+import * as projectUpdateActions from '~/store/projects/project-update-actions';
+import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
+import { ServiceRepository } from '~/services/services';
+import { getResource } from '../resources/resources';
+import { getProjectPanelCurrentUuid } from '../project-panel/project-panel-action';
 
-export const navigateTo = (uuid: string) =>
-    async (dispatch: Dispatch) => {
-        const kind = extractUuidKind(uuid);
-        if (kind === ResourceKind.PROJECT || kind === ResourceKind.USER) {
-            dispatch<any>(navigateToProject(uuid));
-        } else if (kind === ResourceKind.COLLECTION) {
-            dispatch<any>(navigateToCollection(uuid));
-        }
-        if (uuid === SidePanelTreeCategory.FAVORITES) {
-            dispatch<any>(navigateToFavorites);
-        }
-    };
 
 export const loadWorkbench = () =>
     async (dispatch: Dispatch, getState: () => RootState) => {
@@ -60,8 +50,6 @@ export const loadWorkbench = () =>
         }
     };
 
-export const navigateToFavorites = push(Routes.FAVORITES);
-
 export const loadFavorites = () =>
     (dispatch: Dispatch) => {
         dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.FAVORITES));
@@ -70,8 +58,6 @@ export const loadFavorites = () =>
     };
 
 
-export const navigateToProject = compose(push, getProjectUrl);
-
 export const loadProject = (uuid: string) =>
     async (dispatch: Dispatch) => {
         await dispatch<any>(activateSidePanelTreeItem(uuid));
@@ -80,7 +66,49 @@ export const loadProject = (uuid: string) =>
         dispatch(loadDetailsPanel(uuid));
     };
 
-export const navigateToCollection = compose(push, getCollectionUrl);
+export const createProject = (data: projectCreateActions.ProjectCreateFormDialogData) =>
+    async (dispatch: Dispatch) => {
+        const newProject = await dispatch<any>(projectCreateActions.createProject(data));
+        if (newProject) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Project has been successfully created.",
+                hideDuration: 2000
+            }));
+            await dispatch<any>(loadSidePanelTreeProjects(newProject.ownerUuid));
+            dispatch<any>(reloadProjectMatchingUuid([newProject.ownerUuid]));
+        }
+    };
+
+export const moveProject = (data: MoveToFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            const oldProject = getResource(data.uuid)(getState().resources);
+            const oldOwnerUuid = oldProject ? oldProject.ownerUuid : '';
+            const movedProject = await dispatch<any>(projectMoveActions.moveProject(data));
+            if (movedProject) {
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000 }));
+                if (oldProject) {
+                    await dispatch<any>(loadSidePanelTreeProjects(oldProject.ownerUuid));
+                }
+                dispatch<any>(reloadProjectMatchingUuid([oldOwnerUuid, movedProject.ownerUuid, movedProject.uuid]));
+            }
+        } catch (e) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
+        }
+    };
+
+export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
+        if (updatedProject) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Project has been successfully updated.",
+                hideDuration: 2000
+            }));
+            await dispatch<any>(loadSidePanelTreeProjects(updatedProject.ownerUuid));
+            dispatch<any>(reloadProjectMatchingUuid([updatedProject.ownerUuid, updatedProject.uuid]));
+        }
+    };
 
 export const loadCollection = (uuid: string) =>
     async (dispatch: Dispatch) => {
@@ -90,11 +118,6 @@ export const loadCollection = (uuid: string) =>
         dispatch(loadDetailsPanel(uuid));
     };
 
-export const cannotNavigateToResource = ({ kind, uuid }: Resource) =>
-    snackbarActions.OPEN_SNACKBAR({
-        message: `${resourceLabel(kind)} identified by ${uuid} cannot be opened.`
-    });
-
 export const resourceIsNotLoaded = (uuid: string) =>
     snackbarActions.OPEN_SNACKBAR({
         message: `Resource identified by ${uuid} is not loaded.`
@@ -106,4 +129,12 @@ export const userIsNotAuthenticated = snackbarActions.OPEN_SNACKBAR({
 
 export const couldNotLoadUser = snackbarActions.OPEN_SNACKBAR({
     message: 'Could not load user'
-});
\ No newline at end of file
+});
+
+const reloadProjectMatchingUuid = (matchingUuids: string[]) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const currentProjectPanelUuid = getProjectPanelCurrentUuid(getState());
+        if (currentProjectPanelUuid && matchingUuids.some(uuid => uuid === currentProjectPanelUuid)) {
+            dispatch<any>(loadProject(currentProjectPanelUuid));
+        }
+    };
\ No newline at end of file
diff --git a/src/views-components/api-token/api-token.tsx b/src/views-components/api-token/api-token.tsx
index 4fa87a2..41fce72 100644
--- a/src/views-components/api-token/api-token.tsx
+++ b/src/views-components/api-token/api-token.tsx
@@ -6,10 +6,8 @@ import { Redirect, RouteProps } from "react-router";
 import * as React from "react";
 import { connect, DispatchProp } from "react-redux";
 import { getUserDetails, saveApiToken } from "~/store/auth/auth-action";
-import { getProjectList } from "~/store/project/project-action";
 import { getUrlParameter } from "~/common/url";
 import { AuthService } from "~/services/auth-service/auth-service";
-import { loadWorkbench } from '../../store/navigation/navigation-action';
 
 interface ApiTokenProps {
     authService: AuthService;
@@ -21,10 +19,7 @@ export const ApiToken = connect()(
             const search = this.props.location ? this.props.location.search : "";
             const apiToken = getUrlParameter(search, 'api_token');
             this.props.dispatch(saveApiToken(apiToken));
-            this.props.dispatch<any>(getUserDetails()).then(() => {
-                const rootUuid = this.props.authService.getRootUuid();
-                this.props.dispatch(loadWorkbench());
-            });
+            this.props.dispatch<any>(getUserDetails());
         }
         render() {
             return <Redirect to="/"/>;
diff --git a/src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx b/src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx
deleted file mode 100644
index fb5f094..0000000
--- a/src/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { Dispatch } from "redux";
-import { reduxForm, reset, startSubmit, stopSubmit } from "redux-form";
-import { withDialog } from "~/store/dialog/with-dialog";
-import { dialogActions } from "~/store/dialog/dialog-actions";
-import { DialogCollectionCreateWithSelected } from "../dialog-create/dialog-collection-create-selected";
-import { resetPickerProjectTree } from "~/store/project-tree-picker/project-tree-picker-actions";
-
-export const DIALOG_COLLECTION_CREATE_WITH_SELECTED = 'dialogCollectionCreateWithSelected';
-
-export const createCollectionWithSelected = () =>
-    (dispatch: Dispatch) => {
-        dispatch(reset(DIALOG_COLLECTION_CREATE_WITH_SELECTED));
-        dispatch<any>(resetPickerProjectTree());
-        dispatch(dialogActions.OPEN_DIALOG({ id: DIALOG_COLLECTION_CREATE_WITH_SELECTED, data: {} }));
-    };
-
-export const [DialogCollectionCreateWithSelectedFile] = [DialogCollectionCreateWithSelected]
-    .map(withDialog(DIALOG_COLLECTION_CREATE_WITH_SELECTED))
-    .map(reduxForm({
-        form: DIALOG_COLLECTION_CREATE_WITH_SELECTED,
-        onSubmit: (data, dispatch) => {
-            dispatch(startSubmit(DIALOG_COLLECTION_CREATE_WITH_SELECTED));
-            setTimeout(() => dispatch(stopSubmit(DIALOG_COLLECTION_CREATE_WITH_SELECTED, { name: 'Invalid name' })), 2000);
-        }
-    }));
diff --git a/src/views-components/dialog-forms/create-project-dialog.ts b/src/views-components/dialog-forms/create-project-dialog.ts
index 2e87517..fc9fa2b 100644
--- a/src/views-components/dialog-forms/create-project-dialog.ts
+++ b/src/views-components/dialog-forms/create-project-dialog.ts
@@ -5,15 +5,16 @@
 import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
-import { addProject, PROJECT_CREATE_FORM_NAME, ProjectCreateFormDialogData } from '~/store/projects/project-create-actions';
+import { PROJECT_CREATE_FORM_NAME, ProjectCreateFormDialogData } from '~/store/projects/project-create-actions';
 import { DialogProjectCreate } from '~/views-components/dialog-create/dialog-project-create';
+import { createProject } from "~/store/workbench/workbench-actions";
 
 export const CreateProjectDialog = compose(
     withDialog(PROJECT_CREATE_FORM_NAME),
     reduxForm<ProjectCreateFormDialogData>({
         form: PROJECT_CREATE_FORM_NAME,
         onSubmit: (data, dispatch) => {
-            dispatch(addProject(data));
+            dispatch(createProject(data));
         }
     })
 )(DialogProjectCreate);
\ No newline at end of file
diff --git a/src/views-components/dialog-forms/move-project-dialog.ts b/src/views-components/dialog-forms/move-project-dialog.ts
index dd102b1..c1fbb76 100644
--- a/src/views-components/dialog-forms/move-project-dialog.ts
+++ b/src/views-components/dialog-forms/move-project-dialog.ts
@@ -6,9 +6,9 @@ import { compose } from "redux";
 import { withDialog } from "~/store/dialog/with-dialog";
 import { reduxForm } from 'redux-form';
 import { PROJECT_MOVE_FORM_NAME } from '~/store/projects/project-move-actions';
-import { moveProject } from '~/store/projects/project-move-actions';
 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
 import { DialogMoveTo } from '~/views-components/dialog-move/dialog-move-to';
+import { moveProject } from '~/store/workbench/workbench-actions';
 
 export const MoveProjectDialog = compose(
     withDialog(PROJECT_MOVE_FORM_NAME),
diff --git a/src/views-components/dialog-forms/update-project-dialog.ts b/src/views-components/dialog-forms/update-project-dialog.ts
index 598d0b1..36d5106 100644
--- a/src/views-components/dialog-forms/update-project-dialog.ts
+++ b/src/views-components/dialog-forms/update-project-dialog.ts
@@ -6,14 +6,15 @@ import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
 import { DialogProjectUpdate } from '~/views-components/dialog-update/dialog-project-update';
-import { editProject, PROJECT_UPDATE_FORM_NAME, ProjectUpdateFormDialogData } from '~/store/projects/project-update-actions';
+import { PROJECT_UPDATE_FORM_NAME, ProjectUpdateFormDialogData } from '~/store/projects/project-update-actions';
+import { updateProject } from '~/store/workbench/workbench-actions';
 
 export const UpdateProjectDialog = compose(
     withDialog(PROJECT_UPDATE_FORM_NAME),
     reduxForm<ProjectUpdateFormDialogData>({
         form: PROJECT_UPDATE_FORM_NAME,
         onSubmit: (data, dispatch) => {
-            dispatch(editProject(data));
+            dispatch(updateProject(data));
         }
     })
 )(DialogProjectUpdate);
\ No newline at end of file
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 37c247e..643bf0a 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -26,7 +26,6 @@ import { AuthService } from "~/services/auth-service/auth-service";
 import { RenameFileDialog } from '~/views-components/rename-file-dialog/rename-file-dialog';
 import { FileRemoveDialog } from '~/views-components/file-remove-dialog/file-remove-dialog';
 import { MultipleFilesRemoveDialog } from '~/views-components/file-remove-dialog/multiple-files-remove-dialog';
-import { DialogCollectionCreateWithSelectedFile } from '~/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected';
 import { UploadCollectionFilesDialog } from '~/views-components/upload-collection-files-dialog/upload-collection-files-dialog';
 import { CollectionPartialCopyDialog } from '~/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog';
 import { SidePanel } from '~/views-components/side-panel/side-panel';
@@ -182,7 +181,6 @@ export const Workbench = withStyles(styles)(
                         <CreateCollectionDialog />
                         <RenameFileDialog />
                         <CollectionPartialCopyDialog />
-                        <DialogCollectionCreateWithSelectedFile />
                         <FileRemoveDialog />
                         <CopyCollectionDialog />
                         <MultipleFilesRemoveDialog />

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list