X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/72c12f527787181e4abb09fc968f07e795179c3c..f53d651573ef8c358cbdf38c7a56c6aed8178b61:/src/views-components/collection-panel-files/collection-panel-files.ts diff --git a/src/views-components/collection-panel-files/collection-panel-files.ts b/src/views-components/collection-panel-files/collection-panel-files.ts index 0009fc0d..ccb18c8f 100644 --- a/src/views-components/collection-panel-files/collection-panel-files.ts +++ b/src/views-components/collection-panel-files/collection-panel-files.ts @@ -3,17 +3,18 @@ // SPDX-License-Identifier: AGPL-3.0 import { connect } from "react-redux"; -import { CollectionPanelFiles as Component, CollectionPanelFilesProps } from "../../components/collection-panel-files/collection-panel-files"; -import { RootState } from "../../store/store"; -import { TreeItemStatus, TreeItem } from "../../components/tree/tree"; -import { CollectionPanelFilesState, CollectionPanelDirectory, CollectionPanelFile } from "../../store/collection-panel/collection-panel-files/collection-panel-files-state"; -import { FileTreeData } from "../../components/file-tree/file-tree-data"; +import { CollectionPanelFiles as Component, CollectionPanelFilesProps } from "~/components/collection-panel-files/collection-panel-files"; +import { RootState } from "~/store/store"; +import { TreeItemStatus, TreeItem } from "~/components/tree/tree"; +import { CollectionPanelFilesState, CollectionPanelDirectory, CollectionPanelFile } from "~/store/collection-panel/collection-panel-files/collection-panel-files-state"; +import { FileTreeData } from "~/components/file-tree/file-tree-data"; import { Dispatch } from "redux"; -import { collectionPanelFilesAction } from "../../store/collection-panel/collection-panel-files/collection-panel-files-actions"; -import { contextMenuActions } from "../../store/context-menu/context-menu-actions"; +import { collectionPanelFilesAction } from "~/store/collection-panel/collection-panel-files/collection-panel-files-actions"; import { ContextMenuKind } from "../context-menu/context-menu"; -import { Tree, getNodeChildren, getNode } from "../../models/tree"; -import { CollectionFileType } from "../../models/collection-file"; +import { Tree, getNodeChildrenIds, getNode } from "~/models/tree"; +import { CollectionFileType } from "~/models/collection-file"; +import { openContextMenu } from '~/store/context-menu/context-menu-actions'; +import { openUploadCollectionFilesDialog } from '~/store/collections/collection-upload-actions'; const memoizedMapStateToProps = () => { let prevState: CollectionPanelFilesState; @@ -22,7 +23,7 @@ const memoizedMapStateToProps = () => { return (state: RootState): Pick => { if (prevState !== state.collectionPanelFiles) { prevState = state.collectionPanelFiles; - prevTree = getNodeChildren('')(state.collectionPanelFiles) + prevTree = getNodeChildrenIds('')(state.collectionPanelFiles) .map(collectionItemToTreeItem(state.collectionPanelFiles)); } return { @@ -32,7 +33,9 @@ const memoizedMapStateToProps = () => { }; const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ - onUploadDataClick: () => { return; }, + onUploadDataClick: () => { + dispatch(openUploadCollectionFilesDialog()); + }, onCollapseToggle: (id) => { dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_COLLAPSE({ id })); }, @@ -40,17 +43,11 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick { - event.preventDefault(); - dispatch(contextMenuActions.OPEN_CONTEXT_MENU({ - position: { x: event.clientX, y: event.clientY }, - resource: { kind: ContextMenuKind.COLLECTION_FILES_ITEM, name: item.data.name, uuid: item.id } - })); + dispatch(openContextMenu(event, { kind: ContextMenuKind.COLLECTION_FILES_ITEM, name: item.data.name, uuid: item.id })); + }, + onOptionsMenuOpen: (event) => { + dispatch(openContextMenu(event, { kind: ContextMenuKind.COLLECTION_FILES, name: '', uuid: '' })); }, - onOptionsMenuOpen: (event) => - dispatch(contextMenuActions.OPEN_CONTEXT_MENU({ - position: { x: event.clientX, y: event.clientY }, - resource: { kind: ContextMenuKind.COLLECTION_FILES, name: '', uuid: '' } - })) }); @@ -77,7 +74,7 @@ const collectionItemToTreeItem = (tree: Tree