X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/761e9780888a343e0655563acea23577eeb5d29a..7eb16e136a720bdfda5a4d4782d9cce1d00f5ded:/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 94aec140..a363bc03 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,25 +3,11 @@ // SPDX-License-Identifier: AGPL-3.0 import copy from 'copy-to-clipboard'; -import { ResourceKind } from 'models/resource'; +import { getResourceUrl } from 'routes/routes'; import { getClipboardUrl } from 'views-components/context-menu/actions/helpers'; -const getUrl = (resource: any) => { - let url: string | null = null; - const { uuid, kind } = resource; - - if (kind === ResourceKind.COLLECTION) { - url = `/collections/${uuid}`; - } - if (kind === ResourceKind.PROJECT) { - url = `/projects/${uuid}`; - } - - return url; -}; - export const openInNewTabAction = (resource: any) => () => { - const url = getUrl(resource); + const url = getResourceUrl(resource.uuid); if (url) { window.open(`${window.location.origin}${url}`, '_blank'); @@ -29,9 +15,9 @@ export const openInNewTabAction = (resource: any) => () => { }; export const copyToClipboardAction = (resource: any) => () => { - const url = getUrl(resource); + const url = getResourceUrl(resource.uuid); if (url) { copy(getClipboardUrl(url, false)); } -}; \ No newline at end of file +};