19079: Add search results context menu with clipboard and new tab options
[arvados-workbench2.git] / src / store / open-in-new-tab / open-in-new-tab.actions.ts
index c6462ea139f1ed7d53a463c37164d39ff3cc3c00..a363bc03c5c6b7b79527dcc87dcf9f86813cba53 100644 (file)
@@ -2,26 +2,12 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as copy from 'copy-to-clipboard';
-import { ResourceKind } from '~/models/resource';
-import { getClipboardUrl } from '~/views-components/context-menu/actions/helpers';
-
-const getUrl = (resource: any) => {
-    let url = null;
-    const { uuid, kind } = resource;
-
-    if (kind === ResourceKind.COLLECTION) {
-        url = `/collections/${uuid}`;
-    }
-    if (kind === ResourceKind.PROJECT) {
-        url = `/projects/${uuid}`;
-    }
-
-    return url;
-};
+import copy from 'copy-to-clipboard';
+import { getResourceUrl } from 'routes/routes';
+import { getClipboardUrl } from 'views-components/context-menu/actions/helpers';
 
 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
+};