X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dd89200ad6fdbfa337fdbab5f54def8712c6746c..88ce683068f65862b3b5e753e55989902be5f1a9:/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 5baa6d1875..748151c6c3 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'; @@ -19,8 +19,12 @@ 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' | 'value'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { @@ -40,8 +44,12 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ color: theme.palette.grey["500"], cursor: 'pointer' }, + label: { + fontSize: '0.875rem' + }, value: { - textTransform: 'none' + textTransform: 'none', + fontSize: '0.875rem' } }); @@ -50,88 +58,103 @@ interface CollectionPanelDataProps { 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, + tags: state.collectionPanel.tags + }; + })( class extends React.Component { - render() { - const { classes, item, tags, onContextMenu } = this.props; + const { classes, item, tags } = this.props; return
- - } - action={ - onContextMenu(event, item)}> - - - } - title={item && item.name } - subheader={item && item.description} /> - - - - - - - + + } + action={ + + + + } + title={item && item.name} + subheader={item && item.description} /> + + + + + + this.onCopy()}> + + + - - - - + + + - - + + + - - - - - - - { - tags.map(tag => { - return ; - }) - } - + + + + + + + { + tags.map(tag => { + return ; + }) + } - - -
- -
-
; + + + +
+ +
+ ; + } + + 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)); } handleDelete = (uuid: string) => () => { this.props.dispatch(deleteCollectionTag(uuid)); } - componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) { - if (!item || match.params.id !== item.uuid) { - onItemRouteChange(match.params.id); - } + onCopy = () => { + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message: "Uuid has been copied", + hideDuration: 2000 + })); } - } ) );