X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f19ab2e744a310d392fdea0b1b6636604cf55065..22821296e913d4be63d4a40c33e7c28c5582cdd5:/src/components/collection-panel-files/collection-panel-files.tsx diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx index 581c3a76..f9c24b62 100644 --- a/src/components/collection-panel-files/collection-panel-files.tsx +++ b/src/components/collection-panel-files/collection-panel-files.tsx @@ -3,32 +3,52 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { TreeItem, TreeItemStatus } from '../tree/tree'; -import { FileTreeData } from '../file-tree/file-tree-data'; -import { FileTree } from '../file-tree/file-tree'; -import { IconButton, Grid, Typography, StyleRulesCallback, withStyles, WithStyles, CardHeader, Card, Button, Tooltip } from '@material-ui/core'; -import { CustomizeTableIcon } from '../icon/icon'; +import { TreeItem, TreeItemStatus } from '~/components/tree/tree'; +import { FileTreeData } from '~/components/file-tree/file-tree-data'; +import { FileTree } from '~/components/file-tree/file-tree'; +import { CollectionFileType } from "~/models/collection-file"; +import { IconButton, Grid, Typography, StyleRulesCallback, withStyles, WithStyles, CardHeader, Card, Button, Tooltip, CircularProgress } from '@material-ui/core'; +import { CustomizeTableIcon } from '~/components/icon/icon'; import { DownloadIcon } from '~/components/icon/icon'; +import { SearchInput } from '../search-input/search-input'; export interface CollectionPanelFilesProps { items: Array>; + isWritable: boolean; + isLoading: boolean; + tooManyFiles: boolean; onUploadDataClick: () => void; - onItemMenuOpen: (event: React.MouseEvent, item: TreeItem) => void; - onOptionsMenuOpen: (event: React.MouseEvent) => void; + onSearchChange: (searchValue: string) => void; + onItemMenuOpen: (event: React.MouseEvent, item: TreeItem, isWritable: boolean) => void; + onOptionsMenuOpen: (event: React.MouseEvent, isWritable: boolean) => void; onSelectionToggle: (event: React.MouseEvent, item: TreeItem) => void; onCollapseToggle: (id: string, status: TreeItemStatus) => void; onFileClick: (id: string) => void; + loadFilesFunc: () => void; + currentItemUuid?: string; } -type CssRules = 'root' | 'cardSubheader' | 'nameHeader' | 'fileSizeHeader' | 'uploadIcon' | 'button'; +type CssRules = 'root' | 'cardSubheader' | 'nameHeader' | 'fileSizeHeader' | 'uploadIcon' | 'button' | 'centeredLabel' | 'cardHeaderContent' | 'cardHeaderContentTitle'; const styles: StyleRulesCallback = theme => ({ root: { - paddingBottom: theme.spacing.unit + paddingBottom: theme.spacing.unit, + height: '100%' }, cardSubheader: { paddingTop: 0, - paddingBottom: 0 + paddingBottom: 0, + minHeight: 8 * theme.spacing.unit, + }, + cardHeaderContent: { + display: 'flex', + paddingRight: 2 * theme.spacing.unit, + justifyContent: 'space-between', + }, + cardHeaderContentTitle: { + paddingLeft: theme.spacing.unit, + paddingTop: 2 * theme.spacing.unit, + paddingRight: 2 * theme.spacing.unit, }, nameHeader: { marginLeft: '75px' @@ -41,42 +61,88 @@ const styles: StyleRulesCallback = theme => ({ }, button: { marginRight: -theme.spacing.unit, - marginTop: '0px' - } + marginTop: '8px' + }, + centeredLabel: { + fontSize: '0.875rem', + textAlign: 'center' + }, }); + + export const CollectionPanelFiles = withStyles(styles)( - ({ onItemMenuOpen, onOptionsMenuOpen, onUploadDataClick, classes, ...treeProps }: CollectionPanelFilesProps & WithStyles) => - + ({ onItemMenuOpen, onSearchChange, onOptionsMenuOpen, onUploadDataClick, classes, + isWritable, isLoading, tooManyFiles, loadFilesFunc, ...treeProps }: CollectionPanelFilesProps & WithStyles) => { + const { useState, useEffect } = React; + const [searchValue, setSearchValue] = useState(''); + + useEffect(() => { + onSearchChange(searchValue); + }, [searchValue]); + + return ( + Files + + + } + className={classes.cardSubheader} classes={{ action: classes.button }} - action={ - - } /> - - - - - + } + {!tooManyFiles && + + onOptionsMenuOpen(ev, isWritable)}> + + + } + } /> - - - Name - - - File size - - - + {tooManyFiles + ?
+ File listing may take some time, please click to browse: +
+ : <> + + + Name + + + File size + + + {isLoading + ?
+ :
+ onItemMenuOpen(ev, item, isWritable)} + {...treeProps} + items={treeProps.items.filter((item) => { + if (item.data.type === CollectionFileType.FILE) { + return item.data.name.toLowerCase().indexOf(searchValue.toLowerCase()) > -1; + } + + return true; + })} />
} + + }
); + } + );