X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ec33904efe960ec3e3bddb668d892463171e50bd..f6093a73debdd7135870582088202da459386f17:/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 41a685f3..c4221937 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -5,28 +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, navigateToProcess } from '~/store/collection-panel/collection-panel-action'; -import { snackbarActions } from '~/store/snackbar/snackbar-actions'; 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 { getResourceData } from "~/store/resources-data/resources-data"; -import { ResourceData } from "~/store/resources-data/resources-data-reducer"; +import { openDetailsPanel } from '~/store/details-panel/details-panel-action'; +import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; +import { getPropertyChip } from '~/views-components/resource-properties-form/property-chip'; +import { IllegalNamingWarning } from '~/components/warning/warning'; -type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value' | 'link'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { @@ -40,12 +40,6 @@ 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' }, @@ -64,7 +58,6 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ interface CollectionPanelDataProps { item: CollectionResource; - data: ResourceData; } type CollectionPanelProps = CollectionPanelDataProps & DispatchProp @@ -73,17 +66,21 @@ type CollectionPanelProps = CollectionPanelDataProps & DispatchProp export const CollectionPanel = withStyles(styles)( connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { const item = getResource(props.match.params.id)(state.resources); - const data = getResourceData(props.match.params.id)(state.resourcesData); - return { item, data }; + return { item }; })( class extends React.Component { + render() { - const { classes, item, data, dispatch } = this.props; + const { classes, item, dispatch } = this.props; return item ? <> } + avatar={ + + + + } action={ } - 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='Portable data hash' + linkToUuid={item && item.portableDataHash} /> + label='Number of files' value={item && item.fileCount} /> - dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> - - + label='Content size' value={item && formatFileSize(item.fileSizeTotal)} /> + + {(item.properties.container_request || item.properties.containerRequest) && + dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> + + + } @@ -129,13 +127,18 @@ export const CollectionPanel = withStyles(styles)( - { - Object.keys(item.properties).map(k => { - return ; - }) - } + {Object.keys(item.properties).map(k => + Array.isArray(item.properties[k]) + ? item.properties[k].map((v: string) => + getPropertyChip( + k, v, + this.handleDelete(k, v), + classes.tag)) + : getPropertyChip( + k, item.properties[k], + this.handleDelete(k, item.properties[k]), + classes.tag) + )} @@ -162,16 +165,28 @@ export const CollectionPanel = withStyles(styles)( this.props.dispatch(openContextMenu(event, resource)); } - handleDelete = (key: string) => () => { - this.props.dispatch(deleteCollectionTag(key)); + onCopy = (message: string) => + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })) + + handleDelete = (key: string, value: string) => () => { + this.props.dispatch(deleteCollectionTag(key, value)); } - 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 + }; + } ) );