X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ec9331a8435c9844efe3ba018f6c0d0c3f96d573..347b8e60a87c5c4f847fba0f644c7e0446098355:/src/models/collection-file.ts diff --git a/src/models/collection-file.ts b/src/models/collection-file.ts index 37e18cfc..97afcac6 100644 --- a/src/models/collection-file.ts +++ b/src/models/collection-file.ts @@ -3,6 +3,7 @@ // SPDX-License-Identifier: AGPL-3.0 import { Tree, createTree, setNode, TreeNodeStatus } from './tree'; +import { head, split, pipe, join } from 'lodash/fp'; export type CollectionFilesTree = Tree; @@ -59,7 +60,7 @@ export const createCollectionFilesTree = (data: Array setNode({ children: [], id: item.id, - parent: item.path, + parent: getParentId(item), value: item, active: false, selected: false, @@ -67,4 +68,14 @@ export const createCollectionFilesTree = (data: Array()); -}; \ No newline at end of file +}; + +const getParentId = (item: CollectionDirectory | CollectionFile) => + item.path + ? join('', [getCollectionId(item.id), item.path]) + : item.path; + +const getCollectionId = pipe( + split('/'), + head, +); \ No newline at end of file