1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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 import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
11 export const openInNewTabAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => {
12 const url = getNavUrl(resource.uuid, getState().auth);
15 window.open(`${window.location.origin}${url}`, "_blank", "noopener");
16 } else if (url.length) {
17 window.open(url, "_blank", "noopener");
21 export const copyToClipboardAction = (resources: Array<any>) => (dispatch: Dispatch, getState: () => RootState) => {
22 // Copy to clipboard omits token to avoid accidental sharing
24 let url = getNavUrl(resources[0].uuid, getState().auth, false);
27 if (url[0] === "/") wasCopied = copy(`${window.location.origin}${url}`);
28 else if (url.length) {
29 wasCopied = copy(url);
34 snackbarActions.OPEN_SNACKBAR({
37 kind: SnackbarKind.SUCCESS,