Fix side panel item double collapsing
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Sat, 25 Aug 2018 21:15:41 +0000 (23:15 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Sat, 25 Aug 2018 21:15:41 +0000 (23:15 +0200)
Feature #14102

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/store/side-panel-tree/side-panel-tree-actions.ts

index 2fe5aba8921050a7d6a35941bed8ef949b7e2e52..377f4205b801a4a71fa7c90c88e70ffb1d71b2ce 100644 (file)
@@ -102,9 +102,7 @@ export const activateSidePanelTreeProject = (nodeId: string) =>
         const node = getSidePanelTreeNode(nodeId)(getState());
         if (node && node.status !== TreeItemStatus.LOADED) {
             await dispatch<any>(loadSidePanelTreeProjects(nodeId));
-            if (node.collapsed) {
-                dispatch<any>(toggleSidePanelTreeItemCollapse(nodeId));
-            }
+            dispatch<any>(expandSidePanelTreeItem(nodeId));
         } else if (node === undefined) {
             await dispatch<any>(activateSidePanelTreeBranch(nodeId));
         }
@@ -117,11 +115,24 @@ export const activateSidePanelTreeBranch = (nodeId: string) =>
             await dispatch<any>(loadSidePanelTreeProjects(ancestor.uuid));
         }
         for (const ancestor of ancestors) {
-            dispatch<any>(toggleSidePanelTreeItemCollapse(ancestor.uuid));
+            dispatch<any>(expandSidePanelTreeItem(ancestor.uuid));
         }
         dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_SELECT({ nodeId, pickerId: SIDE_PANEL_TREE }));
     };
 
+export const toggleSidePanelTreeItemCollapse = (nodeId: string) =>
+    async (dispatch: Dispatch, getState: () => RootState) => {
+        dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ nodeId, pickerId: SIDE_PANEL_TREE }));
+    };
+
+export const expandSidePanelTreeItem = (nodeId: string) =>
+    async (dispatch: Dispatch, getState: () => RootState) => {
+        const node = getSidePanelTreeNode(nodeId)(getState());
+        if (node && node.collapsed) {
+            dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ nodeId, pickerId: SIDE_PANEL_TREE }));
+        }
+    };
+
 const getSidePanelTreeNode = (nodeId: string) => (state: RootState) => {
     const sidePanelTree = getTreePicker(SIDE_PANEL_TREE)(state.treePicker);
     return sidePanelTree
@@ -129,7 +140,3 @@ const getSidePanelTreeNode = (nodeId: string) => (state: RootState) => {
         : undefined;
 };
 
-export const toggleSidePanelTreeItemCollapse = (nodeId: string) =>
-    async (dispatch: Dispatch, getState: () => RootState) => {
-        dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ nodeId, pickerId: SIDE_PANEL_TREE }));
-    };