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 { ResourceKind } from 'models/resource';
7 import { getClipboardUrl } from 'views-components/context-menu/actions/helpers';
9 const getUrl = (resource: any) => {
10 let url: string | null = null;
11 const { uuid, kind } = resource;
13 if (kind === ResourceKind.COLLECTION) {
14 url = `/collections/${uuid}`;
16 if (kind === ResourceKind.PROJECT) {
17 url = `/projects/${uuid}`;
23 export const openInNewTabAction = (resource: any) => () => {
24 const url = getUrl(resource);
27 window.open(`${window.location.origin}${url}`, '_blank');
31 export const copyToClipboardAction = (resource: any) => () => {
32 const url = getUrl(resource);
35 copy(getClipboardUrl(url, false));