X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/de7204ffbb7255e0aa9cefb7efd06f5130b19038..fa9b3ce44a3a9315207852d1f182000a6166f9e9:/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 9672f306..4124344d 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -16,15 +16,17 @@ import { DetailsAttribute } from '~/components/details-attribute/details-attribu 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 { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { deleteCollectionTag, navigateToProcess } from '~/store/collection-panel/collection-panel-action'; +import {snackbarActions, SnackbarKind} 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"; -type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value' | 'link'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { @@ -50,118 +52,127 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ value: { textTransform: 'none', fontSize: '0.875rem' + }, + link: { + fontSize: '0.875rem', + color: theme.palette.primary.main, + '&:hover': { + cursor: 'pointer' + } } }); interface CollectionPanelDataProps { item: CollectionResource; - tags: TagResource[]; + data: ResourceData; } 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, - tags: state.collectionPanel.tags - }; + const item = getResource(props.match.params.id)(state.resources); + const data = getResourceData(props.match.params.id)(state.resourcesData); + return { item, data }; })( class extends React.Component { render() { - const { classes, item, tags } = this.props; - return
- - } - action={ - - - + const { classes, item, data, dispatch } = this.props; + return item + ? <> + + } + action={ + + + + - - } - title={item && item.name} - subheader={item && item.description} /> - - - - - - this.onCopy()}> - - - - - - - + } + title={item && item.name} + subheader={item && item.description} /> + + + + + + this.onCopy()}> + + + + + + + + dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> + + + - - - + + - - - - - - - { - tags.map(tag => { - return ; - }) - } + + + + + + + + + { + Object.keys(item.properties).map(k => { + return ; + }) + } + - - - -
- -
-
; + + +
+ +
+ + : null; } handleContextMenu = (event: React.MouseEvent) => { - const { uuid, ownerUuid, name, description, kind } = this.props.item; + const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item; const resource = { uuid, ownerUuid, name, description, kind, - menuKind: ContextMenuKind.COLLECTION + menuKind: isTrashed + ? ContextMenuKind.TRASHED_COLLECTION + : ContextMenuKind.COLLECTION }; this.props.dispatch(openContextMenu(event, resource)); } - handleDelete = (uuid: string) => () => { - this.props.dispatch(deleteCollectionTag(uuid)); + handleDelete = (key: string) => () => { + this.props.dispatch(deleteCollectionTag(key)); } onCopy = () => { this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Uuid has been copied", - hideDuration: 2000 + hideDuration: 2000, + kind: SnackbarKind.SUCCESS })); } } ) ); - -const renderTagLabel = (tag: TagResource) => { - const { properties } = tag; - return `${properties.key}: ${properties.value}`; -};