19079: Add search results context menu with clipboard and new tab options
[arvados-workbench2.git] / src / store / open-in-new-tab / open-in-new-tab.actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import copy from 'copy-to-clipboard';
6 import { getResourceUrl } from 'routes/routes';
7 import { getClipboardUrl } from 'views-components/context-menu/actions/helpers';
8
9 export const openInNewTabAction = (resource: any) => () => {
10     const url = getResourceUrl(resource.uuid);
11
12     if (url) {
13         window.open(`${window.location.origin}${url}`, '_blank');
14     }
15 };
16
17 export const copyToClipboardAction = (resource: any) => () => {
18     const url = getResourceUrl(resource.uuid);
19
20     if (url) {
21         copy(getClipboardUrl(url, false));
22     }
23 };