X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a4e2c41eb689b86b04a88ea2971282ce14de2b88..a855a03082f2d521ed64ef1405ed186655659f26:/src/views/collection-panel/collection-panel.tsx diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 379a2eb8..b92557f9 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -5,25 +5,28 @@ import * as React from 'react'; import { StyleRulesCallback, WithStyles, withStyles, Card, - CardHeader, IconButton, CardContent, Grid, Chip, Tooltip + CardHeader, IconButton, CardContent, Grid, Tooltip } from '@material-ui/core'; import { connect, DispatchProp } from "react-redux"; import { RouteComponentProps } from 'react-router'; import { ArvadosTheme } from '~/common/custom-theme'; import { RootState } from '~/store/store'; -import { MoreOptionsIcon, CollectionIcon, CopyIcon } from '~/components/icon/icon'; +import { MoreOptionsIcon, CollectionIcon } from '~/components/icon/icon'; import { DetailsAttribute } from '~/components/details-attribute/details-attribute'; import { CollectionResource } from '~/models/collection'; import { CollectionPanelFiles } from '~/views-components/collection-panel-files/collection-panel-files'; -import * as CopyToClipboard from 'react-copy-to-clipboard'; import { CollectionTagForm } from './collection-tag-form'; -import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action'; -import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { deleteCollectionTag, navigateToProcess } from '~/store/collection-panel/collection-panel-action'; import { getResource } from '~/store/resources/resources'; import { openContextMenu } from '~/store/context-menu/context-menu-actions'; import { ContextMenuKind } from '~/views-components/context-menu/context-menu'; +import { formatFileSize } from "~/common/formatters"; +import { openDetailsPanel } from '~/store/details-panel/details-panel-action'; +import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; +import { PropertyChipComponent } from '~/views-components/resource-properties-form/property-chip'; +import { IllegalNamingWarning } from '~/components/warning/warning'; -type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { @@ -37,18 +40,19 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ marginRight: theme.spacing.unit, marginBottom: theme.spacing.unit }, - copyIcon: { - marginLeft: theme.spacing.unit, - fontSize: '1.125rem', - color: theme.palette.grey["500"], - cursor: 'pointer' - }, label: { fontSize: '0.875rem' }, value: { textTransform: 'none', fontSize: '0.875rem' + }, + link: { + fontSize: '0.875rem', + color: theme.palette.primary.main, + '&:hover': { + cursor: 'pointer' + } } }); @@ -59,24 +63,26 @@ interface CollectionPanelDataProps { type CollectionPanelProps = CollectionPanelDataProps & DispatchProp & WithStyles & RouteComponentProps<{ id: string }>; - export const CollectionPanel = withStyles(styles)( connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { - const collection = getResource(props.match.params.id)(state.resources); - return { - item: collection - }; + const item = getResource(props.match.params.id)(state.resources); + return { item }; })( class extends React.Component { + render() { - const { classes, item } = this.props; + const { classes, item, dispatch } = this.props; return item ? <> } + avatar={ + + + + } action={ - + @@ -84,26 +90,30 @@ export const CollectionPanel = withStyles(styles)( } - title={item && item.name} - subheader={item && item.description} /> + title={item && {item.name}} + titleTypographyProps={this.titleProps} + subheader={item && item.description} + subheaderTypographyProps={this.titleProps} /> - + - - this.onCopy()}> - - - - + linkToUuid={item && item.uuid} /> + + label='Number of files' value={item && item.fileCount} /> + label='Content size' value={item && formatFileSize(item.fileSizeTotal)} /> + label='Owner' linkToUuid={item && item.ownerUuid} /> + {(item.properties.container_request || item.properties.containerRequest) && + dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> + + + } @@ -117,14 +127,12 @@ export const CollectionPanel = withStyles(styles)( - { - Object.keys(item.properties).map(k => { - console.log('k: ', k); - return ; - }) - } + {Object.keys(item.properties).map(k => + + )} @@ -151,16 +159,28 @@ export const CollectionPanel = withStyles(styles)( this.props.dispatch(openContextMenu(event, resource)); } + onCopy = (message: string) => + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })) + handleDelete = (key: string) => () => { this.props.dispatch(deleteCollectionTag(key)); } - onCopy = () => { - this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ - message: "Uuid has been copied", - hideDuration: 2000 - })); + openCollectionDetails = () => { + const { item } = this.props; + if (item) { + this.props.dispatch(openDetailsPanel(item.uuid)); + } } + + titleProps = { + onClick: this.openCollectionDetails + }; + } ) );