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, Tooltip } from '@material-ui/core';
10 import { CustomizeTableIcon } from '../icon/icon';
11 import { DownloadIcon } from '~/components/icon/icon';
13 export interface CollectionPanelFilesProps {
14 items: Array<TreeItem<FileTreeData>>;
15 onUploadDataClick: () => void;
16 onItemMenuOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
17 onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>) => void;
18 onSelectionToggle: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
19 onCollapseToggle: (id: string, status: TreeItemStatus) => void;
22 type CssRules = 'root' | 'cardSubheader' | 'nameHeader' | 'fileSizeHeader' | 'uploadIcon';
24 const styles: StyleRulesCallback<CssRules> = theme => ({
26 paddingBottom: theme.spacing.unit
39 transform: 'rotate(180deg)'
43 export const CollectionPanelFiles =
45 ({ onItemMenuOpen, onOptionsMenuOpen, onUploadDataClick, classes, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) =>
46 <Card className={classes.root}>
50 <Button onClick={onUploadDataClick}
54 <DownloadIcon className={classes.uploadIcon}/>
59 className={classes.cardSubheader}
61 <Tooltip title="More options">
62 <IconButton onClick={onOptionsMenuOpen}>
63 <CustomizeTableIcon />
67 <Grid container justify="space-between">
68 <Typography variant="caption" className={classes.nameHeader}>
71 <Typography variant="caption" className={classes.fileSizeHeader}>
75 <FileTree onMenuOpen={onItemMenuOpen} {...treeProps} />