1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { RouteComponentProps } from 'react-router';
7 import { Project } from '../../models/project';
8 import { ProjectState } from '../../store/project/project-reducer';
9 import { RootState } from '../../store/store';
10 import { connect, DispatchProp } from 'react-redux';
11 import { push } from 'react-router-redux';
12 import { DataColumns } from "../../components/data-table/data-table";
13 import DataExplorer, { DataExplorerContextActions } from "../../views-components/data-explorer/data-explorer";
14 import { projectExplorerItems } from "./data-explorer-selectors";
15 import { DataItem } from "../../views-components/data-explorer/data-item";
16 import { CollectionState } from "../../store/collection/collection-reducer";
17 import { ResourceKind } from "../../models/resource";
18 import projectActions from "../../store/project/project-action";
19 import { getCollectionList } from "../../store/collection/collection-action";
21 interface DataExplorerViewDataProps {
22 projects: ProjectState;
23 collections: CollectionState;
26 type DataExplorerViewProps = DataExplorerViewDataProps & RouteComponentProps<{ uuid: string }> & DispatchProp;
27 type DataExplorerViewState = DataColumns<Project>;
29 class DataExplorerView extends React.Component<DataExplorerViewProps, DataExplorerViewState> {
31 const treeItemId = this.props.match.params.uuid;
32 const items = projectExplorerItems(this.props.projects, treeItemId, this.props.collections);
36 onItemClick={this.goToItem}
37 contextActions={this.contextActions}
42 contextActions: DataExplorerContextActions = {
43 onAddToFavourite: console.log,
45 onDownload: console.log,
46 onMoveTo: console.log,
47 onRemove: console.log,
48 onRename: console.log,
52 goToItem = (item: DataItem) => {
53 // FIXME: Unify project tree switch action
54 this.props.dispatch(push(item.url));
55 if (item.type === ResourceKind.PROJECT || item.type === ResourceKind.LEVEL_UP) {
56 this.props.dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM(item.uuid));
58 this.props.dispatch<any>(getCollectionList(item.uuid));
62 export default connect(
63 (state: RootState) => ({
64 projects: state.projects,
65 collections: state.collections