Post merge fixes
authorDaniel Kos <daniel.kos@contractors.roche.com>
Tue, 26 Jun 2018 06:31:16 +0000 (08:31 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Tue, 26 Jun 2018 06:31:16 +0000 (08:31 +0200)
Feature #13666

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

src/store/navigation/navigation-action.ts
src/views/project-panel/project-panel.tsx
src/views/workbench/workbench.tsx

index 6d1754d92cd827f3d191f6ff1510c50a1bd541af..6e4b4bef38cd158c52f2ccd2001839cd2ef97e44 100644 (file)
@@ -22,12 +22,24 @@ export const getResourceUrl = (resource: Resource): string => {
     }
 };
 
-export const setProjectItem = (projects: Array<TreeItem<Project>>, itemId: string, itemKind: ResourceKind) => (dispatch: Dispatch) => {
+export enum ItemMode {
+    BOTH,
+    OPEN,
+    ACTIVE
+}
+
+export const setProjectItem = (projects: Array<TreeItem<Project>>, itemId: string, itemKind: ResourceKind, itemMode: ItemMode) => (dispatch: Dispatch) => {
 
     const openProjectItem = (resource: Resource) => {
-        dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(resource.uuid));
-        dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(resource.uuid));
-        dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(resource.uuid));
+        if (itemMode === ItemMode.OPEN || itemMode === ItemMode.BOTH) {
+            dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(resource.uuid));
+        }
+
+        if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
+            dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(resource.uuid));
+            dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(resource.uuid));
+        }
+
         dispatch(push(getResourceUrl({...resource, kind: itemKind})));
     };
     const treeItem = findTreeItem(projects, itemId);
@@ -39,27 +51,8 @@ export const setProjectItem = (projects: Array<TreeItem<Project>>, itemId: strin
             dispatch<any>(getProjectList(itemId))
                 .then(() => openProjectItem(treeItem.data));
         }
-        dispatch<any>(getCollectionList(itemId));
-
-        // if (item.type === ResourceKind.PROJECT || item.type === ResourceKind.LEVEL_UP) {
-        //     this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(item.uuid));
-        // }
-        // this.props.dispatch<any>(getCollectionList(item.uuid));
-
+        if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
+            dispatch<any>(getCollectionList(itemId));
+        }
     }
 };
-
-    // toggleProjectTreeItemActive = (itemId: string, status: TreeItemStatus) => {
-    //     if (status === TreeItemStatus.Loaded) {
-    //         this.openProjectItem(itemId);
-    //         this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(itemId));
-    //         this.props.dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(itemId));
-    //     } else {
-    //         this.props.dispatch<any>(getProjectList(itemId))
-    //             .then(() => {
-    //                 this.openProjectItem(itemId);
-    //                 this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(itemId));
-    //                 this.props.dispatch(sidePanelActions.RESET_SIDE_PANEL_ACTIVITY(itemId));
-    //             });
-    //     }
-    // }
index 68cbc8ec73758b169a343b1f1581fc71333db3f1..830ea7b824123d0b9ed15122dc36ad9856eb8aac 100644 (file)
@@ -8,7 +8,7 @@ import { ProjectState } from '../../store/project/project-reducer';
 import { RootState } from '../../store/store';
 import { connect, DispatchProp } from 'react-redux';
 import { CollectionState } from "../../store/collection/collection-reducer";
-import { setProjectItem } from "../../store/navigation/navigation-action";
+import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
 import ProjectExplorer, { ProjectExplorerContextActions } from "../../views-components/project-explorer/project-explorer";
 import { projectExplorerItems } from "./project-panel-selectors";
 import { ProjectExplorerItem } from "../../views-components/project-explorer/project-explorer-item";
@@ -36,7 +36,7 @@ class ProjectPanel extends React.Component<ProjectPanelProps> {
     }
 
     goToItem = (item: ProjectExplorerItem) => {
-        this.props.dispatch<any>(setProjectItem(this.props.projects.items, item.uuid, item.kind));
+        this.props.dispatch<any>(setProjectItem(this.props.projects.items, item.uuid, item.kind, ItemMode.BOTH));
     }
 }
 
index b6a8457a6fd3e482f23b04d6e0deae6fb13c5d32..a597c5973f0cc35699b315186304bc3ebbe8f2a7 100644 (file)
@@ -24,7 +24,7 @@ import ProjectPanel from '../project-panel/project-panel';
 import sidePanelActions from '../../store/side-panel/side-panel-action';
 import SidePanel, { SidePanelItem } from '../../components/side-panel/side-panel';
 import { ResourceKind } from "../../models/resource";
-import { setProjectItem } from "../../store/navigation/navigation-action";
+import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
 
 const drawerWidth = 240;
 const appBarHeight = 102;
@@ -184,11 +184,11 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                                 projects={this.props.projects}
                                 toggleOpen={itemId =>
                                     this.props.dispatch<any>(
-                                        setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT)
+                                        setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.OPEN)
                                     )}
                                 toggleActive={itemId =>
                                     this.props.dispatch<any>(
-                                        setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT)
+                                        setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.ACTIVE)
                                     )}
                             />
                         </SidePanel>
@@ -196,7 +196,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                 <main className={classes.contentWrapper}>
                     <div className={classes.content}>
                         <Switch>
-                            <Route path="/project/:name" component={ProjectPanel} />
+                            <Route path="/projects/:name" component={ProjectPanel} />
                         </Switch>
                     </div>
                 </main>
@@ -204,14 +204,6 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
         );
     }
 }
-/*
-                    <ProjectTree
-                        projects={this.props.projects}
-                        toggleProjectTreeItem={itemId =>
-                            this.props.dispatch<any>(
-                                setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT)
-                            )}/>
-*/
 
 export default connect<WorkbenchDataProps>(
     (state: RootState) => ({