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 { FileViewerAction } from '~/views-components/context-menu/actions/file-viewer-action';
8 import { getNodeValue } from "~/models/tree";
9 import { CollectionFileType } from "~/models/collection-file";
10 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
12 const mapStateToProps = (state: RootState) => {
13 const { resource } = state.contextMenu;
14 const currentCollectionUuid = state.collectionPanel.item ? state.collectionPanel.item.uuid : '';
15 if (resource && resource.menuKind === ContextMenuKind.COLLECTION_FILES_ITEM) {
16 const file = getNodeValue(resource.uuid)(state.collectionPanelFiles);
20 download: file.type === CollectionFileType.DIRECTORY ? undefined : file.name,
31 export const CollectionFileViewerAction = connect(mapStateToProps)(FileViewerAction);