X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/52cc3b912c703c24bc90e67aaf24e8ad912d3ebf..d116e491ef904d97dcece5ab1632bef08906ec87:/src/views/workbench/workbench.tsx

diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 72eb0ddcfe..ea8fce807f 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -6,7 +6,7 @@ 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 { Route, Switch } from "react-router";
+import { Route, Switch, RouteComponentProps, withRouter } from "react-router";
 import authActions from "../../store/auth/auth-action";
 import dataExplorerActions from "../../store/data-explorer/data-explorer-action";
 import { User } from "../../models/user";
@@ -27,6 +27,7 @@ import { ResourceKind } from "../../models/resource";
 import { ItemMode, setProjectItem } from "../../store/navigation/navigation-action";
 import projectActions from "../../store/project/project-action";
 import ProjectPanel from "../project-panel/project-panel";
+import { sidePanelData } from '../../store/side-panel/side-panel-reducer';
 
 const drawerWidth = 240;
 const appBarHeight = 102;
@@ -91,6 +92,7 @@ interface NavMenuItem extends MainAppBarMenuItem {
 }
 
 interface WorkbenchState {
+    isCreationDialogOpen: boolean;
     anchorEl: any;
     searchText: string;
     menuItems: {
@@ -102,6 +104,7 @@ interface WorkbenchState {
 
 class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
     state = {
+        isCreationDialogOpen: false,
         anchorEl: null,
         searchText: "",
         breadcrumbs: [],
@@ -133,7 +136,7 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
 
     mainAppBarActions: MainAppBarActionProps = {
         onBreadcrumbClick: ({ itemId }: NavBreadcrumb) => {
-            this.props.dispatch<any>(setProjectItem(itemId, ResourceKind.PROJECT, ItemMode.BOTH));
+            this.props.dispatch<any>(setProjectItem(itemId, ItemMode.BOTH));
         },
         onSearch: searchText => {
             this.setState({ searchText });
@@ -151,9 +154,17 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
         this.props.dispatch(projectActions.RESET_PROJECT_TREE_ACTIVITY(itemId));
     }
 
+    handleCreationDialogOpen = () => {
+        this.setState({ isCreationDialogOpen: true });
+    }
+
+    handleCreationDialogClose = () => {
+        this.setState({ isCreationDialogOpen: false });
+    }
+
     render() {
-        const branch = getTreePath(this.props.projects, this.props.currentProjectId);
-        const breadcrumbs = branch.map(item => ({
+        const path = getTreePath(this.props.projects, this.props.currentProjectId);
+        const breadcrumbs = path.map(item => ({
             label: item.data.name,
             itemId: item.data.uuid,
             status: item.status
@@ -181,30 +192,37 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
                         <SidePanel
                             toggleOpen={this.toggleSidePanelOpen}
                             toggleActive={this.toggleSidePanelActive}
-                            sidePanelItems={this.props.sidePanelItems}>
+                            sidePanelItems={this.props.sidePanelItems}
+                            handleCreationDialogOpen={this.handleCreationDialogOpen}
+                            handleCreationDialogClose={this.handleCreationDialogClose}>
                             <ProjectTree
                                 projects={this.props.projects}
-                                toggleOpen={itemId =>
-                                    this.props.dispatch<any>(
-                                        setProjectItem(itemId, ResourceKind.PROJECT, ItemMode.OPEN)
-                                    )}
-                                toggleActive={itemId =>
-                                    this.props.dispatch<any>(
-                                        setProjectItem(itemId, ResourceKind.PROJECT, ItemMode.ACTIVE)
-                                    )}
+                                toggleOpen={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.OPEN))}
+                                toggleActive={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
+                                handleCreationDialogOpen={this.handleCreationDialogOpen}
+                                handleCreationDialogClose={this.handleCreationDialogClose}
                             />
                         </SidePanel>
                     </Drawer>}
                 <main className={classes.contentWrapper}>
                     <div className={classes.content}>
                         <Switch>
-                            <Route path="/projects/:name" component={ProjectPanel} />
+                            <Route path="/projects/:id" render={this.renderProjectPanel} />
                         </Switch>
                     </div>
                 </main>
             </div>
         );
     }
+
+    renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
+        onItemRouteChange={itemId => this.props.dispatch<any>(setProjectItem(itemId, ItemMode.ACTIVE))}
+        onItemClick={item => this.props.dispatch<any>(setProjectItem(item.uuid, ItemMode.ACTIVE))}
+        handleCreationDialogOpen={this.handleCreationDialogOpen}
+        handleCreationDialogClose={this.handleCreationDialogClose}
+        isCreationDialogOpen={this.state.isCreationDialogOpen}
+        {...props} />
+    
 }
 
 export default connect<WorkbenchDataProps>(
