X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/5e88476747d9fb0c77ef76d63430192fa4b77f22..c90e813adcec89899d9db95843295a84fb058c3e:/src/views/workbench/workbench.tsx diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index bac0b473..4f9843cb 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -3,7 +3,6 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; - import { StyleRulesCallback, Theme, WithStyles, withStyles } from '@material-ui/core/styles'; import Drawer from '@material-ui/core/Drawer'; import { connect, DispatchProp } from "react-redux"; @@ -20,6 +19,9 @@ import { TreeItem, TreeItemStatus } from "../../components/tree/tree"; import { Project } from "../../models/project"; import { getTreePath } from '../../store/project/project-reducer'; import ProjectPanel from '../project-panel/project-panel'; +import sidePanelActions from '../../store/side-panel/side-panel-action'; +import { projectService } from '../../services/services'; +import SidePanel, { SidePanelItem } from '../../components/side-panel/side-panel'; const drawerWidth = 240; const appBarHeight = 102; @@ -45,6 +47,8 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ drawerPaper: { position: 'relative', width: drawerWidth, + display: 'flex', + flexDirection: 'column', }, contentWrapper: { backgroundColor: theme.palette.background.default, @@ -64,6 +68,7 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ interface WorkbenchDataProps { projects: Array>; user?: User; + sidePanelItems: SidePanelItem[]; } interface WorkbenchActionProps { @@ -125,7 +130,7 @@ class Workbench extends React.Component { mainAppBarActions: MainAppBarActionProps = { onBreadcrumbClick: ({ itemId, status }: NavBreadcrumb) => { - this.toggleProjectTreeItem(itemId, status); + this.toggleProjectTreeItemOpen(itemId, status); }, onSearch: searchText => { this.setState({ searchText }); @@ -134,15 +139,45 @@ class Workbench extends React.Component { onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action() }; - toggleProjectTreeItem = (itemId: string, status: TreeItemStatus) => { + toggleProjectTreeItemOpen = (itemId: string, status: TreeItemStatus) => { if (status === TreeItemStatus.Loaded) { this.openProjectItem(itemId); + this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(itemId)); + this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(itemId)); } else { this.props.dispatch(getProjectList(itemId)) - .then(() => this.openProjectItem(itemId)); + .then(() => { + this.openProjectItem(itemId); + this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(itemId)); + this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(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)); + }); + } + } + + toggleSidePanelOpen = (itemId: string) => { + this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_OPEN(itemId)); + } + + toggleSidePanelActive = (itemId: string) => { + this.props.dispatch(sidePanelActions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(itemId)); + this.props.dispatch(projectActions.RESET_PROJECT_TREE_ACTIVITY(itemId)); + } + openProjectItem = (itemId: string) => { const branch = getTreePath(this.props.projects, itemId); this.setState({ @@ -152,12 +187,12 @@ class Workbench extends React.Component { status: item.status })) }); - this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId)); + this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(itemId)); this.props.dispatch(push(`/project/${itemId}`)); } render() { - const { classes, user } = this.props; + const { classes, user, projects, sidePanelItems } = this.props; return (
@@ -176,9 +211,15 @@ class Workbench extends React.Component { paper: classes.drawerPaper, }}>
- + + + }
@@ -195,7 +236,8 @@ class Workbench extends React.Component { export default connect( (state: RootState) => ({ projects: state.projects, - user: state.auth.user + user: state.auth.user, + sidePanelItems: state.sidePanel, }) )( withStyles(styles)(Workbench)