15768: collection copy dialog mostly works Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[arvados.git] / src / views-components / context-menu / actions / collection-copy-to-clipboard-action.tsx
index 4ecdef7019b1ad2c48284c9661a5fdb56fbb8236..c92f7bc88b861e28713c7d3ef5c70ad60601e075 100644 (file)
@@ -4,28 +4,29 @@
 
 import { connect } from "react-redux";
 import { RootState } from "../../../store/store";
-import { getNodeValue } from "~/models/tree";
-import { CollectionFileType } from "~/models/collection-file";
-import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
+import { getNodeValue } from "models/tree";
+import { ContextMenuKind } from 'views-components/context-menu/context-menu';
 import { CopyToClipboardAction } from "./copy-to-clipboard-action";
 
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
     const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
-    if (resource && resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM) {
+    const { keepWebServiceUrl } = state.auth.config;
+    if (resource && [
+        ContextMenuKind.COLLECTION_FILE_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
+        ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
+        ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
         const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
         if (file) {
             return {
-                href: file.url,
-                download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
+                href: file.url.replace(keepWebServiceUrl, ''),
                 kind: 'file',
                 currentCollectionUuid
             };
         }
-    } else {
-        return ;
     }
-    return ;
+    return {};
 };
 
 export const CollectionCopyToClipboardAction = connect(mapStateToProps)(CopyToClipboardAction);