X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/6aa9f73fef64bbca1e3b71eb526946d69d014246..cd015a3c1aa2511da7c0063125a24065d37799bb:/src/store/open-in-new-tab/open-in-new-tab.actions.ts diff --git a/src/store/open-in-new-tab/open-in-new-tab.actions.ts b/src/store/open-in-new-tab/open-in-new-tab.actions.ts index a363bc03..c465aae8 100644 --- a/src/store/open-in-new-tab/open-in-new-tab.actions.ts +++ b/src/store/open-in-new-tab/open-in-new-tab.actions.ts @@ -3,21 +3,25 @@ // SPDX-License-Identifier: AGPL-3.0 import copy from 'copy-to-clipboard'; -import { getResourceUrl } from 'routes/routes'; -import { getClipboardUrl } from 'views-components/context-menu/actions/helpers'; +import { Dispatch } from 'redux'; +import { getNavUrl } from 'routes/routes'; +import { RootState } from 'store/store'; -export const openInNewTabAction = (resource: any) => () => { - const url = getResourceUrl(resource.uuid); +export const openInNewTabAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => { + const url = getNavUrl(resource.uuid, getState().auth); - if (url) { + if (url[0] === '/') { window.open(`${window.location.origin}${url}`, '_blank'); + } else if (url.length) { + window.open(url, '_blank'); } }; -export const copyToClipboardAction = (resource: any) => () => { - const url = getResourceUrl(resource.uuid); +export const copyToClipboardAction = (resource: any) => (dispatch: Dispatch, getState: () => RootState) => { + // Copy to clipboard omits token to avoid accidental sharing + const url = getNavUrl(resource.uuid, getState().auth, false); if (url) { - copy(getClipboardUrl(url, false)); + copy(url); } };