19079: Don't use collection specific url processing for search result clipboard actions
[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 { Dispatch } from 'redux';
7 import { getNavUrl } from 'routes/routes';
8 import { RootState } from 'store/store';
9
10 export const openInNewTabAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => {
11     const url = getNavUrl(resource.uuid, getState().auth);
12
13     if (url[0] === '/') {
14         window.open(`${window.location.origin}${url}`, '_blank');
15     } else if (url.length) {
16         window.open(url, '_blank');
17     }
18 };
19
20 export const copyToClipboardAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => {
21     // Copy to clipboard omits token to avoid accidental sharing
22     const url = getNavUrl(resource.uuid, getState().auth, false);
23
24     if (url) {
25         copy(url);
26     }
27 };