From: Daniel Kos Date: Tue, 26 Jun 2018 06:31:16 +0000 (+0200) Subject: Post merge fixes X-Git-Tag: 1.2.0~67^2~2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/e9fe89a00d2aea95b7e6c5ecdbeb4f6a583070b1 Post merge fixes Feature #13666 Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts index 6d1754d9..6e4b4bef 100644 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@ -22,12 +22,24 @@ export const getResourceUrl = (resource: Resource): string => { } }; -export const setProjectItem = (projects: Array>, itemId: string, itemKind: ResourceKind) => (dispatch: Dispatch) => { +export enum ItemMode { + BOTH, + OPEN, + ACTIVE +} + +export const setProjectItem = (projects: Array>, 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>, itemId: strin dispatch(getProjectList(itemId)) .then(() => openProjectItem(treeItem.data)); } - dispatch(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(getCollectionList(item.uuid)); - + if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) { + dispatch(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(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)); - // }); - // } - // } diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index 68cbc8ec..830ea7b8 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -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 { } goToItem = (item: ProjectExplorerItem) => { - this.props.dispatch(setProjectItem(this.props.projects.items, item.uuid, item.kind)); + this.props.dispatch(setProjectItem(this.props.projects.items, item.uuid, item.kind, ItemMode.BOTH)); } } diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index b6a8457a..a597c597 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -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 { projects={this.props.projects} toggleOpen={itemId => this.props.dispatch( - setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT) + setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.OPEN) )} toggleActive={itemId => this.props.dispatch( - setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT) + setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.ACTIVE) )} /> @@ -196,7 +196,7 @@ class Workbench extends React.Component {
- +
@@ -204,14 +204,6 @@ class Workbench extends React.Component { ); } } -/* - - this.props.dispatch( - setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT) - )}/> -*/ export default connect( (state: RootState) => ({