X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/33608c44bf33ab330ad1267ab8d56c08634673b5..44cbbc08d7a5b559a542bbf6491a05467de1c15c:/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 f476c9397c..0b264b6bab 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -5,7 +5,7 @@ import * as React from 'react'; import { StyleRulesCallback, WithStyles, withStyles, Card, - CardHeader, IconButton, CardContent, Grid, Chip + CardHeader, IconButton, CardContent, Grid, Chip, Tooltip } from '@material-ui/core'; import { connect, DispatchProp } from "react-redux"; import { RouteComponentProps } from 'react-router'; @@ -16,9 +16,12 @@ 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 { getResource } from '~/store/resources/resources'; +import { openContextMenu } from '~/store/context-menu/context-menu-actions'; +import { ContextMenuKind } from '~/views-components/context-menu/context-menu'; type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value'; @@ -51,99 +54,106 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ 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 collection = getResource(props.match.params.id)(state.resources); + return { + item: collection + }; + })( class extends React.Component { - render() { - const { classes, item, tags, onContextMenu } = this.props; + const { classes, item } = this.props; return
- - } - action={ + + } + action={ + onContextMenu(event, item)}> + onClick={this.handleContextMenu}> - } - title={item && item.name } - subheader={item && item.description} /> - - - - - + + } + title={item && item.name} + subheader={item && item.description} /> + + + + + + this.onCopy()}> - - - - - + + + + + - - + + + - - - - - - - { - tags.map(tag => { - return ; - }) - } - + + + + + + + { + Object.keys(item.properties).map( key => { + return ; + }) + } - - -
- -
-
; + + + +
+ +
+ ; } - handleDelete = (uuid: string) => () => { - this.props.dispatch(deleteCollectionTag(uuid)); + handleContextMenu = (event: React.MouseEvent) => { + const { uuid, ownerUuid, name, description, kind } = this.props.item; + const resource = { + uuid, + ownerUuid, + name, + description, + kind, + menuKind: ContextMenuKind.COLLECTION + }; + this.props.dispatch(openContextMenu(event, resource)); } - componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) { - if (!item || match.params.id !== item.uuid) { - onItemRouteChange(match.params.id); - } + handleDelete = (key: string) => () => { + this.props.dispatch(deleteCollectionTag(key)); } + onCopy = () => { + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message: "Uuid has been copied", + hideDuration: 2000 + })); + } } ) ); - -const renderTagLabel = (tag: TagResource) => { - const { properties } = tag; - return `${properties.key}: ${properties.value}`; -};