From 2ef3823ee2205b76af73f3fa4440395bdb3aac5d Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 29 Oct 2019 17:33:58 -0400 Subject: [PATCH] 15766: Clicking on a property chip copies its text to clipboard Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../collection-panel/collection-panel.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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)); } -- 2.30.2