// 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";
import { TreeItem, TreeItemStatus } from "../../components/tree/tree";
import { Project } from "../../models/project";
import { getTreePath } from '../../store/project/project-reducer';
-import DataExplorer from '../data-explorer/data-explorer';
+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;
drawerPaper: {
position: 'relative',
width: drawerWidth,
+ display: 'flex',
+ flexDirection: 'column',
},
contentWrapper: {
backgroundColor: theme.palette.background.default,
interface WorkbenchDataProps {
projects: Array<TreeItem<Project>>;
user?: User;
+ sidePanelItems: SidePanelItem[];
}
interface WorkbenchActionProps {
mainAppBarActions: MainAppBarActionProps = {
onBreadcrumbClick: ({ itemId, status }: NavBreadcrumb) => {
- this.toggleProjectTreeItem(itemId, status);
+ this.toggleProjectTreeItemOpen(itemId, status);
},
onSearch: searchText => {
this.setState({ searchText });
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<any>(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<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));
+ });
+ }
+ }
+
+ 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({
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 (
<div className={classes.root}>
<div className={classes.appBar}>
paper: classes.drawerPaper,
}}>
<div className={classes.toolbar} />
- <ProjectTree
- projects={this.props.projects}
- toggleProjectTreeItem={this.toggleProjectTreeItem} />
+ <SidePanel
+ toggleOpen={this.toggleSidePanelOpen}
+ toggleActive={this.toggleSidePanelActive}
+ sidePanelItems={sidePanelItems}>
+ <ProjectTree
+ projects={projects}
+ toggleOpen={this.toggleProjectTreeItemOpen}
+ toggleActive={this.toggleProjectTreeItemActive} />
+ </SidePanel>
</Drawer>}
<main className={classes.contentWrapper}>
<div className={classes.content}>
<Switch>
- <Route path="/project/:name" component={DataExplorer} />
+ <Route path="/project/:name" component={ProjectPanel} />
</Switch>
</div>
</main>
export default connect<WorkbenchDataProps>(
(state: RootState) => ({
projects: state.projects,
- user: state.auth.user
+ user: state.auth.user,
+ sidePanelItems: state.sidePanel,
})
)(
withStyles(styles)(Workbench)