1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { TreeItem, TreeItemStatus } from '../tree/tree';
7 import { FileTreeData } from '../file-tree/file-tree-data';
8 import { FileTree } from '../file-tree/file-tree';
9 import { IconButton, Grid, Typography, StyleRulesCallback, withStyles, WithStyles, CardHeader, Card, Button } from '@material-ui/core';
10 import { CustomizeTableIcon } from '../icon/icon';
11 import { connect, DispatchProp } from "react-redux";
12 import { Dispatch } from "redux";
13 import { RootState } from "~/store/store";
14 import { ServiceRepository } from "~/services/services";
16 export interface CollectionPanelFilesProps {
17 items: Array<TreeItem<FileTreeData>>;
18 onUploadDataClick: () => void;
19 onItemMenuOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
20 onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>) => void;
21 onSelectionToggle: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
22 onCollapseToggle: (id: string, status: TreeItemStatus) => void;
25 type CssRules = 'root' | 'cardSubheader' | 'nameHeader' | 'fileSizeHeader';
27 const styles: StyleRulesCallback<CssRules> = theme => ({
29 paddingBottom: theme.spacing.unit
43 const renameFile = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
44 services.collectionFilesService.renameTest();
48 export const CollectionPanelFiles =
51 ({ onItemMenuOpen, onOptionsMenuOpen, classes, dispatch, ...treeProps }: CollectionPanelFilesProps & DispatchProp & WithStyles<CssRules>) =>
52 <Card className={classes.root}>
58 dispatch<any>(renameFile());
67 className={classes.cardSubheader}
69 <IconButton onClick={onOptionsMenuOpen}>
70 <CustomizeTableIcon />
73 <Grid container justify="space-between">
74 <Typography variant="caption" className={classes.nameHeader}>
77 <Typography variant="caption" className={classes.fileSizeHeader}>
81 <FileTree onMenuOpen={onItemMenuOpen} {...treeProps} />