X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/8d374520f28b507e8934d57be46374044fb93e2f..852a6a393297d03ca5259ddb6aa7aedff4a000ea:/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 216ec669..a26b9fe3 100644 --- a/src/views-components/collection-panel-files/collection-panel-files.ts +++ b/src/views-components/collection-panel-files/collection-panel-files.ts @@ -8,41 +8,17 @@ import { CollectionPanelFilesProps } from "components/collection-panel-files/collection-panel-files"; import { RootState } from "store/store"; -import { TreeItemStatus } from "components/tree/tree"; -import { VirtualTreeItem as TreeItem } from "components/tree/virtual-tree"; -import { - CollectionPanelDirectory, - CollectionPanelFile, - CollectionPanelFilesState -} 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 { ContextMenuKind } from "../context-menu/context-menu"; -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 => { - if (prevState !== state.collectionPanelFiles) { - prevState = state.collectionPanelFiles; - prevTree = [].concat.apply( - [], getNodeChildrenIds('')(state.collectionPanelFiles) - .map(collectionItemToList(0)(state.collectionPanelFiles))); - } - return { - items: prevTree, - currentItemUuid: state.detailsPanel.resourceUuid - }; - }; -}; +const mapStateToProps = (state: RootState): Pick => ({ + currentItemUuid: state.detailsPanel.resourceUuid +}); const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ onUploadDataClick: (targetLocation?: string) => { @@ -84,43 +60,4 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick (tree: Tree) => - (id: string): TreeItem[] => { - const node: TreeNode = getNode(id)(tree) || initTreeNode({ - id: '', - parent: '', - value: { - ...createCollectionDirectory({ name: 'Invalid file' }), - selected: false, - collapsed: true - } - }); - - const treeItem = { - active: false, - data: { - name: node.value.name, - size: node.value.type === CollectionFileType.FILE ? node.value.size : undefined, - type: node.value.type, - url: node.value.url, - }, - id: node.id, - items: [], // Not used in this case as we're converting a tree to a list. - itemCount: node.children.length, - open: node.value.type === CollectionFileType.DIRECTORY ? !node.value.collapsed : false, - selected: node.value.selected, - status: TreeItemStatus.LOADED, - level, - }; - - const treeItemChilds = treeItem.open - ? [].concat.apply([], node.children.map(collectionItemToList(level+1)(tree))) - : []; - - return [ - treeItem, - ...treeItemChilds, - ]; - }; +export const CollectionPanelFiles = connect(mapStateToProps, mapDispatchToProps)(Component);