X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ba27bdf218da8894df4ffa6174c67c1fb3e70c81..9be874f7744b5ceb53f4be20d1748db34859468a:/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 294bd6d5..e5983b6b 100644 --- a/src/views-components/collection-panel-files/collection-panel-files.ts +++ b/src/views-components/collection-panel-files/collection-panel-files.ts @@ -18,29 +18,31 @@ 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 { ContextMenuKind } from "../context-menu/context-menu"; -import { getNode, getNodeChildrenIds, Tree } from "~/models/tree"; -import { CollectionFileType } from "~/models/collection-file"; +import { getNode, getNodeChildrenIds, Tree, TreeNode, initTreeNode } from "~/models/tree"; +import { CollectionFileType, createCollectionDirectory } from "~/models/collection-file"; import { openContextMenu, openCollectionFilesContextMenu } from '~/store/context-menu/context-menu-actions'; import { openUploadCollectionFilesDialog } from '~/store/collections/collection-upload-actions'; import { ResourceKind } from "~/models/resource"; +import { openDetailsPanel } from '~/store/details-panel/details-panel-action'; const memoizedMapStateToProps = () => { let prevState: CollectionPanelFilesState; let prevTree: Array>; - return (state: RootState): Pick => { + return (state: RootState): Pick => { if (prevState !== state.collectionPanelFiles) { prevState = state.collectionPanelFiles; prevTree = getNodeChildrenIds('')(state.collectionPanelFiles) .map(collectionItemToTreeItem(state.collectionPanelFiles)); } return { - items: prevTree + items: prevTree, + currentItemUuid: state.detailsPanel.resourceUuid }; }; }; -const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ +const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ onUploadDataClick: () => { dispatch(openUploadCollectionFilesDialog()); }, @@ -56,6 +58,9 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick { dispatch(openCollectionFilesContextMenu(event)); }, + onFileClick: (id) => { + dispatch(openDetailsPanel(id)); + }, }); @@ -63,23 +68,22 @@ export const CollectionPanelFiles = connect(memoizedMapStateToProps(), mapDispat const collectionItemToTreeItem = (tree: Tree) => (id: string): TreeItem => { - const node = getNode(id)(tree) || { + const node: TreeNode = getNode(id)(tree) || initTreeNode({ id: '', - children: [], parent: '', value: { - name: 'Invalid node', - type: CollectionFileType.DIRECTORY, + ...createCollectionDirectory({ name: 'Invalid file' }), selected: false, collapsed: true } - }; + }); return { active: false, data: { name: node.value.name, size: node.value.type === CollectionFileType.FILE ? node.value.size : undefined, - type: node.value.type + type: node.value.type, + url: node.value.url, }, id: node.id, items: getNodeChildrenIds(node.id)(tree)