From ef649661d35999d3d6847861185172fac3e92db1 Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Sat, 25 Aug 2018 23:15:41 +0200 Subject: [PATCH] Fix side panel item double collapsing Feature #14102 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../side-panel-tree-actions.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) 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 2fe5aba8..377f4205 100644 --- a/src/store/side-panel-tree/side-panel-tree-actions.ts +++ b/src/store/side-panel-tree/side-panel-tree-actions.ts @@ -102,9 +102,7 @@ export const activateSidePanelTreeProject = (nodeId: string) => const node = getSidePanelTreeNode(nodeId)(getState()); if (node && node.status !== TreeItemStatus.LOADED) { await dispatch(loadSidePanelTreeProjects(nodeId)); - if (node.collapsed) { - dispatch(toggleSidePanelTreeItemCollapse(nodeId)); - } + dispatch(expandSidePanelTreeItem(nodeId)); } else if (node === undefined) { await dispatch(activateSidePanelTreeBranch(nodeId)); } @@ -117,11 +115,24 @@ export const activateSidePanelTreeBranch = (nodeId: string) => await dispatch(loadSidePanelTreeProjects(ancestor.uuid)); } for (const ancestor of ancestors) { - dispatch(toggleSidePanelTreeItemCollapse(ancestor.uuid)); + dispatch(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 })); - }; -- 2.30.2