From: Peter Amstutz Date: Tue, 29 Oct 2019 21:33:58 +0000 (-0400) Subject: 15766: Clicking on a property chip copies its text to clipboard X-Git-Tag: 2.0.0~31^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/2ef3823ee2205b76af73f3fa4440395bdb3aac5d 15766: Clicking on a property chip copies its text to clipboard Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 58dd9404..77d91558 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -24,6 +24,8 @@ import { formatFileSize } from "~/common/formatters"; import { getResourceData } from "~/store/resources-data/resources-data"; import { ResourceData } from "~/store/resources-data/resources-data-reducer"; import { openDetailsPanel } from '~/store/details-panel/details-panel-action'; +import * as CopyToClipboard from 'react-copy-to-clipboard'; +import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link'; @@ -130,9 +132,12 @@ export const CollectionPanel = withStyles(styles)( { Object.keys(item.properties).map(k => { - return ; + const label = `${k}: ${item.properties[k]}`; + return this.onCopy("Copied")}> + + ; }) } @@ -161,6 +166,13 @@ export const CollectionPanel = withStyles(styles)( this.props.dispatch(openContextMenu(event, resource)); } + onCopy = (message: string) => + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })) + handleDelete = (key: string) => () => { this.props.dispatch(deleteCollectionTag(key)); }