X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f1065fb7260dd562ea2e826e9cbc508d7932ecca..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 9e32700d..b92557f9 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -5,22 +5,28 @@ import * as React from 'react'; import { StyleRulesCallback, WithStyles, withStyles, Card, - CardHeader, IconButton, CardContent, Grid, Chip + 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 { TagResource } from '~/models/tag'; import { CollectionTagForm } from './collection-tag-form'; -import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action'; +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' | 'value'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { @@ -34,65 +40,80 @@ 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' + textTransform: 'none', + fontSize: '0.875rem' + }, + link: { + fontSize: '0.875rem', + color: theme.palette.primary.main, + '&:hover': { + cursor: 'pointer' + } } }); interface CollectionPanelDataProps { item: CollectionResource; - tags: TagResource[]; } -interface CollectionPanelActionProps { - onItemRouteChange: (collectionId: string) => void; - onContextMenu: (event: React.MouseEvent, item: CollectionResource) => void; -} - -type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps & DispatchProp - & WithStyles & RouteComponentProps<{ id: string }>; - +type CollectionPanelProps = CollectionPanelDataProps & DispatchProp + & WithStyles & RouteComponentProps<{ id: string }>; export const CollectionPanel = withStyles(styles)( - connect((state: RootState) => ({ - item: state.collectionPanel.item, - tags: state.collectionPanel.tags - }))( + connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { + const item = getResource(props.match.params.id)(state.resources); + return { item }; + })( class extends React.Component { + render() { - const { classes, item, tags, onContextMenu } = this.props; - return
+ const { classes, item, dispatch } = this.props; + return item + ? <> } - action={ - onContextMenu(event, item)}> - + avatar={ + + } - title={item && item.name } - subheader={item && item.description} /> + action={ + + + + + + } + title={item && {item.name}} + titleTypographyProps={this.titleProps} + subheader={item && item.description} + subheaderTypographyProps={this.titleProps} /> - - + - - - - - - - + linkToUuid={item && item.uuid} /> + + + + + {(item.properties.container_request || item.properties.containerRequest) && + dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> + + + } @@ -102,39 +123,64 @@ export const CollectionPanel = withStyles(styles)( - - { - tags.map(tag => { - return ; - }) - } + + + + {Object.keys(item.properties).map(k => + + )}
- +
-
; + + : null; } - handleDelete = (uuid: string) => () => { - this.props.dispatch(deleteCollectionTag(uuid)); + handleContextMenu = (event: React.MouseEvent) => { + const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item; + const resource = { + uuid, + ownerUuid, + name, + description, + kind, + menuKind: isTrashed + ? ContextMenuKind.TRASHED_COLLECTION + : ContextMenuKind.COLLECTION + }; + this.props.dispatch(openContextMenu(event, resource)); } - componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) { - if (!item || match.params.id !== item.uuid) { - onItemRouteChange(match.params.id); + onCopy = (message: string) => + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })) + + handleDelete = (key: string) => () => { + this.props.dispatch(deleteCollectionTag(key)); + } + + openCollectionDetails = () => { + const { item } = this.props; + if (item) { + this.props.dispatch(openDetailsPanel(item.uuid)); } } + + titleProps = { + onClick: this.openCollectionDetails + }; + } ) ); - -const renderTagLabel = (tag: TagResource) => { - const { properties } = tag; - return `${properties.key}: ${properties.value}`; -};