X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6de571a660401585bc96dd92fd2563e9b64c58c6..2f83fcd45b4b23db2bb5bb4afbe1e863ebd77ec6:/services/workbench2/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx?ds=sidebyside

diff --git a/services/workbench2/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx b/services/workbench2/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx
new file mode 100644
index 0000000000..50ed20fd7f
--- /dev/null
+++ b/services/workbench2/src/views-components/context-menu/actions/copy-to-clipboard-action.tsx
@@ -0,0 +1,33 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from "react";
+import copy from 'copy-to-clipboard';
+import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
+import { Link } from "components/icon/icon";
+import { getCollectionItemClipboardUrl } from "./helpers";
+
+export const CopyToClipboardAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
+    const copyToClipboard = () => {
+        if (props.href) {
+            const clipboardUrl = getCollectionItemClipboardUrl(props.href, true, true);
+            copy(clipboardUrl);
+        }
+
+        if (props.onClick) {
+            props.onClick();
+        }
+    };
+
+    return props.href
+        ? <ListItem button onClick={copyToClipboard}>
+            <ListItemIcon>
+                <Link />
+            </ListItemIcon>
+            <ListItemText>
+                Copy to clipboard
+            </ListItemText>
+        </ListItem>
+        : null;
+};
