1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { connect } from "react-redux";
6 import { RootState } from "../../../store/store";
7 import { DownloadAction } from "./download-action";
8 import { getNodeValue } from "../../../models/tree";
9 import { CollectionFileType } from "../../../models/collection-file";
10 import { ContextMenuKind } from '../context-menu';
11 import { filterCollectionFilesBySelection } from "~/store/collection-panel/collection-panel-files/collection-panel-files-state";
13 const mapStateToProps = (state: RootState) => {
14 const { resource } = state.contextMenu;
15 const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
16 if (resource && resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM) {
17 const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
21 download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
27 const files = filterCollectionFilesBySelection(state.collectionPanelFiles, true);
29 href: files.map(file => file.url),
30 download: files.map(file => file.name),
38 export const DownloadCollectionFileAction = connect(mapStateToProps)(DownloadAction);