Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / src / store / open-in-new-tab / open-in-new-tab.actions.ts
index 6a1ec643a619c6b473c750b4575ad7856c502fa8..83055e32fcbd3750e50b648c4166f6d618b469de 100644 (file)
@@ -21,23 +21,20 @@ export const openInNewTabAction = (resource: any) => (dispatch: Dispatch, getSta
 export const copyToClipboardAction = (resources: Array<any>) => (dispatch: Dispatch, getState: () => RootState) => {
     // Copy to clipboard omits token to avoid accidental sharing
 
-    let output = "";
+    let url = getNavUrl(resources[0].uuid, getState().auth, false);
+    let wasCopied;
 
-    resources.forEach(resource => {
-        let url = getNavUrl(resource.uuid, getState().auth, false);
-        if (url[0] === "/") url = `${window.location.origin}${url}`;
-        output += output.length ? `, ${url}` : url;
-    });
-
-    if (output.length) {
-        const wasCopied = copy(output);
-        if (wasCopied)
-            dispatch(
-                snackbarActions.OPEN_SNACKBAR({
-                    message: "Copied",
-                    hideDuration: 2000,
-                    kind: SnackbarKind.SUCCESS,
-                })
-            );
+    if (url[0] === "/") wasCopied = copy(`${window.location.origin}${url}`);
+    else if (url.length) {
+        wasCopied = copy(url);
     }
+
+    if (wasCopied)
+        dispatch(
+            snackbarActions.OPEN_SNACKBAR({
+                message: "Copied",
+                hideDuration: 2000,
+                kind: SnackbarKind.SUCCESS,
+            })
+        );
 };