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;
20 onFileClick: (id: string) => void;
23 type CssRules = 'root' | 'cardSubheader' | 'nameHeader' | 'fileSizeHeader' | 'uploadIcon' | 'button';
25 const styles: StyleRulesCallback<CssRules> = theme => ({
27 paddingBottom: theme.spacing.unit
40 transform: 'rotate(180deg)'
43 marginRight: -theme.spacing.unit,
48 export const CollectionPanelFiles =
50 ({ onItemMenuOpen, onOptionsMenuOpen, onUploadDataClick, classes, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) =>
51 <Card className={classes.root}>
54 classes={{ action: classes.button }}
56 <Button onClick={onUploadDataClick}
60 <DownloadIcon className={classes.uploadIcon} />
65 className={classes.cardSubheader}
67 <Tooltip title="More options" disableFocusListener>
68 <IconButton onClick={onOptionsMenuOpen}>
69 <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} />