Added central action for navigation
[arvados-workbench2.git] / src / views / data-explorer / data-explorer.tsx
index a667469a2e5317678ea31909132d0aee68b2f64a..8d225cdf9b6961c9856ace0820f187590c633776 100644 (file)
@@ -8,15 +8,12 @@ import { Project } from '../../models/project';
 import { ProjectState } from '../../store/project/project-reducer';
 import { RootState } from '../../store/store';
 import { connect, DispatchProp } from 'react-redux';
-import { push } from 'react-router-redux';
 import { DataColumns } from "../../components/data-table/data-table";
 import DataExplorer, { DataExplorerContextActions } from "../../views-components/data-explorer/data-explorer";
 import { projectExplorerItems } from "./data-explorer-selectors";
 import { DataItem } from "../../views-components/data-explorer/data-item";
 import { CollectionState } from "../../store/collection/collection-reducer";
-import { ResourceKind } from "../../models/resource";
-import projectActions from "../../store/project/project-action";
-import { getCollectionList } from "../../store/collection/collection-action";
+import { setProjectItem } from "../../store/navigation/navigation-action";
 
 interface DataExplorerViewDataProps {
     projects: ProjectState;
@@ -28,8 +25,12 @@ type DataExplorerViewState = DataColumns<Project>;
 
 class DataExplorerView extends React.Component<DataExplorerViewProps, DataExplorerViewState> {
     render() {
-        const treeItemId = this.props.match.params.uuid;
-        const items = projectExplorerItems(this.props.projects, treeItemId, this.props.collections);
+        console.log('VIEW!');
+        const items = projectExplorerItems(
+            this.props.projects.items,
+            this.props.projects.currentItemId,
+            this.props.collections
+        );
         return (
             <DataExplorer
                 items={items}
@@ -50,12 +51,7 @@ class DataExplorerView extends React.Component<DataExplorerViewProps, DataExplor
     };
 
     goToItem = (item: DataItem) => {
-        // FIXME: Unify project tree switch action
-        this.props.dispatch(push(item.url));
-        if (item.type === ResourceKind.PROJECT || item.type === ResourceKind.LEVEL_UP) {
-            this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(item.uuid));
-        }
-        this.props.dispatch<any>(getCollectionList(item.uuid));
+        this.props.dispatch<any>(setProjectItem(this.props.projects.items, item.uuid, item.kind));
     }
 }