21128: single-multi works again Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox...
[arvados.git] / src / views-components / context-menu / actions / copy-to-clipboard-action.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from "react";
6 import copy from 'copy-to-clipboard';
7 import { ListItemIcon, ListItemText, ListItem } from "@material-ui/core";
8 import { Link } from "components/icon/icon";
9 import { getCollectionItemClipboardUrl } from "./helpers";
10
11 export const CopyToClipboardAction = (props: { href?: any, download?: any, onClick?: () => void, kind?: string, currentCollectionUuid?: string; }) => {
12     const copyToClipboard = () => {
13         if (props.href) {
14             const clipboardUrl = getCollectionItemClipboardUrl(props.href, true, true);
15             copy(clipboardUrl);
16         }
17
18         if (props.onClick) {
19             props.onClick();
20         }
21     };
22
23     return props.href
24         ? <ListItem button onClick={copyToClipboard}>
25             <ListItemIcon>
26                 <Link />
27             </ListItemIcon>
28             <ListItemText>
29                 Copy to clipboard
30             </ListItemText>
31         </ListItem>
32         : null;
33 };