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 { ContextMenuKind } from 'views-components/context-menu/menu-item-sort';
10 import { filterCollectionFilesBySelection } from "store/collection-panel/collection-panel-files/collection-panel-files-state";
11 import { sanitizeToken } from "./helpers";
13 const mapStateToProps = (state: RootState) => {
14 const { resource } = state.contextMenu;
15 const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
17 ContextMenuKind.COLLECTION_FILE_ITEM,
18 ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
19 ContextMenuKind.COLLECTION_DIRECTORY_ITEM,
20 ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM ].indexOf(resource.menuKind as ContextMenuKind) > -1) {
21 const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
24 href: sanitizeToken(file.url, true),
30 const files = filterCollectionFilesBySelection(state.collectionPanelFiles, true);
32 href: files.map(file => file.url),
40 export const DownloadCollectionFileAction = connect(mapStateToProps)(DownloadAction);