Merge branch 'master'
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 18 Jun 2018 09:55:54 +0000 (11:55 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 18 Jun 2018 09:55:54 +0000 (11:55 +0200)
Feature #13601

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

1  2 
src/services/project-service/project-service.ts
src/store/project/project-reducer.test.ts
src/store/project/project-reducer.ts
src/views/workbench/workbench.tsx

Simple merge
index 4f1671cae0516c9aa5bdec3317b15ab59da8ee92,8884f3a8d84ad46df4c189aa9b37774bdfc82815..20e3648e0561151c8d63fd57ef04858206f5d914
@@@ -16,10 -27,9 +16,10 @@@ import { Breadcrumb } from '../../compo
  import { push } from 'react-router-redux';
  import projectActions from "../../store/project/project-action";
  import ProjectTree from '../../components/project-tree/project-tree';
- import { TreeItem } from "../../components/tree/tree";
+ import { TreeItem, TreeItemStatus } from "../../components/tree/tree";
  import { Project } from "../../models/project";
  import { projectService } from '../../services/services';
 +import DataExplorer from '../data-explorer/data-explorer';
  
  const drawerWidth = 240;
  
@@@ -133,13 -143,16 +133,19 @@@ class Workbench extends React.Component
          onMenuItemClick: (menuItem: NavMenuItem) => menuItem.action()
      };
  
-     toggleProjectTreeItem = (itemId: string) => {
-         this.props.dispatch<any>(projectService.getProjectList(itemId)).then(() => {
-             this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId));
-             this.props.dispatch(push(`/project/${itemId}`));
-         });
+     toggleProjectTreeItem = (itemId: string, status: TreeItemStatus) => {
+         if (status === TreeItemStatus.Loaded) {
 -            this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId));
++            this.openProjectItem(itemId);
+         } else {
 -            this.props.dispatch<any>(projectService.getProjectList(itemId)).then(() => {
 -                this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId));
 -            });
++            this.props.dispatch<any>(projectService.getProjectList(itemId)).then(() => this.openProjectItem(itemId));
+         }
+     }
++    openProjectItem = (itemId: string) => {
++        this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(itemId));
++        this.props.dispatch(push(`/project/${itemId}`));
 +    }
 +
      render() {
          const { classes, user } = this.props;
          return (
                      />
                  </div>
                  {user &&
-                 <Drawer
-                     variant="permanent"
-                     classes={{
-                         paper: classes.drawerPaper,
-                     }}>
-                     <div className={classes.toolbar}/>
-                     <ProjectTree
-                         projects={this.props.projects}
-                         toggleProjectTreeItem={this.toggleProjectTreeItem}/>
-                 </Drawer>}
+                     <Drawer
+                         variant="permanent"
+                         classes={{
+                             paper: classes.drawerPaper,
+                         }}>
+                         <div className={classes.toolbar} />
+                         <ProjectTree
+                             projects={this.props.projects}
+                             toggleProjectTreeItem={this.toggleProjectTreeItem} />
+                     </Drawer>}
                  <main className={classes.content}>
-                     <div className={classes.toolbar} />
                      <div className={classes.toolbar} />
                      <Switch>
-                         <Route path="/project/:name" component={DataExplorer}/>
 -                        <Route path="/project/:name" component={ProjectList} />
++                        <Route path="/project/:name" component={DataExplorer} />
                      </Switch>
                  </main>
              </div>