X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/01e4b29eb65a760650476a8f5f059413130921f4..14b107de3fe4c29f4a37f1958bad99e2b82d2b24:/src/views-components/context-menu/actions/download-collection-file-action.tsx?ds=sidebyside

diff --git a/src/views-components/context-menu/actions/download-collection-file-action.tsx b/src/views-components/context-menu/actions/download-collection-file-action.tsx
index 460e620a..3b1f7702 100644
--- a/src/views-components/context-menu/actions/download-collection-file-action.tsx
+++ b/src/views-components/context-menu/actions/download-collection-file-action.tsx
@@ -6,18 +6,33 @@ import { connect } from "react-redux";
 import { RootState } from "../../../store/store";
 import { DownloadAction } from "./download-action";
 import { getNodeValue } from "../../../models/tree";
-import { CollectionFileType } from "../../../models/collection-file";
+import { ContextMenuKind } from '../context-menu';
+import { filterCollectionFilesBySelection } from "store/collection-panel/collection-panel-files/collection-panel-files-state";
+import { sanitizeToken } from "./helpers";
 
 const mapStateToProps = (state: RootState) => {
     const { resource } = state.contextMenu;
-    if (resource) {
+    const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
+    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: sanitizeToken(file.url, true),
+                kind: 'file',
+                currentCollectionUuid
             };
         }
+    } else {
+        const files = filterCollectionFilesBySelection(state.collectionPanelFiles, true);
+        return {
+            href: files.map(file => file.url),
+            kind: 'files',
+            currentCollectionUuid
+        };
     }
     return {};
 };
