X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/540750a7749cb71ea0a8fde4b7a3689eeaa1c3dd..f9dde5c781766b8be71d43d0f031c201a0edcfbb:/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 7621d95a..41a685f3 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -16,16 +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 { deleteCollectionTag, navigateToProcess } from '~/store/collection-panel/collection-panel-action'; import { snackbarActions } from '~/store/snackbar/snackbar-actions'; import { getResource } from '~/store/resources/resources'; -import { loadCollection } from '../../store/collection-panel/collection-panel-action'; -import { contextMenuActions } from '~/store/context-menu/context-menu-actions'; +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: { @@ -51,108 +52,118 @@ 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={ - - - - } - title={item && item.name} - subheader={item && item.description} /> - - - - - - this.onCopy()}> - - - - - - - + const { classes, item, data, dispatch } = this.props; + return item + ? <> + + } + action={ + + + + + + } + 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) => { - event.preventDefault(); - const { uuid, name, description } = this.props.item; + const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item; const resource = { uuid, + ownerUuid, name, description, - kind: ContextMenuKind.COLLECTION + kind, + menuKind: isTrashed + ? ContextMenuKind.TRASHED_COLLECTION + : ContextMenuKind.COLLECTION }; - this.props.dispatch( - contextMenuActions.OPEN_CONTEXT_MENU({ - position: { x: event.clientX, y: event.clientY }, - resource - }) - ); + this.props.dispatch(openContextMenu(event, resource)); } - handleDelete = (uuid: string) => () => { - this.props.dispatch(deleteCollectionTag(uuid)); + handleDelete = (key: string) => () => { + this.props.dispatch(deleteCollectionTag(key)); } onCopy = () => { @@ -161,19 +172,6 @@ export const CollectionPanel = withStyles(styles)( hideDuration: 2000 })); } - - componentDidMount() { - const { match, item } = this.props; - if (!item && match.params.id) { - this.props.dispatch(loadCollection(match.params.id)); - } - } - } ) ); - -const renderTagLabel = (tag: TagResource) => { - const { properties } = tag; - return `${properties.key}: ${properties.value}`; -};