1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { connect } from "react-redux";
7 CollectionPanelFiles as Component,
8 CollectionPanelFilesProps
9 } from "components/collection-panel-files/collection-panel-files";
10 import { Dispatch } from "redux";
11 import { collectionPanelFilesAction } from "store/collection-panel/collection-panel-files/collection-panel-files-actions";
12 import { ContextMenuKind } from 'views-components/context-menu/menu-item-sort';
13 import { openContextMenu, openCollectionFilesContextMenu } from 'store/context-menu/context-menu-actions';
14 import { openUploadCollectionFilesDialog } from 'store/collections/collection-upload-actions';
15 import { ResourceKind } from "models/resource";
16 import { openDetailsPanel } from 'store/details-panel/details-panel-action';
18 const mapDispatchToProps = (dispatch: Dispatch): Pick<CollectionPanelFilesProps, 'onSearchChange' | 'onFileClick' | 'onUploadDataClick' | 'onCollapseToggle' | 'onSelectionToggle' | 'onItemMenuOpen' | 'onOptionsMenuOpen'> => ({
19 onUploadDataClick: (targetLocation?: string) => {
20 dispatch<any>(openUploadCollectionFilesDialog(targetLocation));
22 onCollapseToggle: (id) => {
23 dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_COLLAPSE({ id }));
25 onSelectionToggle: (event, item) => {
26 dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_SELECTION({ id: item.id }));
28 onItemMenuOpen: (event, item, isWritable) => {
29 const isDirectory = item.data.type === 'directory';
30 dispatch<any>(openContextMenu(
35 ? ContextMenuKind.COLLECTION_DIRECTORY_ITEM
36 : ContextMenuKind.COLLECTION_FILE_ITEM
38 ? ContextMenuKind.READONLY_COLLECTION_DIRECTORY_ITEM
39 : ContextMenuKind.READONLY_COLLECTION_FILE_ITEM,
40 kind: ResourceKind.COLLECTION,
47 onSearchChange: (searchValue: string) => {
48 dispatch(collectionPanelFilesAction.ON_SEARCH_CHANGE(searchValue));
50 onOptionsMenuOpen: (event, isWritable) => {
51 dispatch<any>(openCollectionFilesContextMenu(event, isWritable));
53 onFileClick: (id) => {
54 dispatch<any>(openDetailsPanel(id));
58 export const ProcessOutputCollectionFiles = connect(null, mapDispatchToProps)(Component);