REMOVE: "Remove",
};
-const { MOVE_TO, TOGGLE_TRASH_ACTION, COPY_TO_CLIPBOARD, REMOVE, MAKE_A_COPY } = contextMenuActionConsts;
+const { MOVE_TO, TOGGLE_TRASH_ACTION, REMOVE, MAKE_A_COPY } = contextMenuActionConsts;
//these sets govern what actions are on the ms toolbar for each resource kind
-const projectMSActionsFilter = new Set([COPY_TO_CLIPBOARD, MOVE_TO, TOGGLE_TRASH_ACTION]);
+const projectMSActionsFilter = new Set([MOVE_TO, TOGGLE_TRASH_ACTION]);
const processResourceMSActionsFilter = new Set([MOVE_TO, REMOVE]);
const collectionMSActionsFilter = new Set([MAKE_A_COPY, MOVE_TO, TOGGLE_TRASH_ACTION]);
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;
- for (const resource of [...resources]) {
- let url = getNavUrl(resource.uuid, getState().auth, false);
- if (url[0] === "/") url = `${window.location.origin}${url}`;
- output += output.length ? `,${url}` : url;
+ if (url[0] === "/") wasCopied = copy(`${window.location.origin}${url}`);
+ else if (url.length) {
+ wasCopied = copy(url);
}
- if (output.length) {
- const wasCopied = copy(output);
- if (wasCopied)
- dispatch(
- snackbarActions.OPEN_SNACKBAR({
- message: "Copied",
- hideDuration: 2000,
- kind: SnackbarKind.SUCCESS,
- })
- );
- }
+ if (wasCopied)
+ dispatch(
+ snackbarActions.OPEN_SNACKBAR({
+ message: "Copied",
+ hideDuration: 2000,
+ kind: SnackbarKind.SUCCESS,
+ })
+ );
};