projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
17119: The "+ New" button should be disabled when viewing a filter
[arvados.git]
/
src
/
models
/
collection-file.ts
diff --git
a/src/models/collection-file.ts
b/src/models/collection-file.ts
index d74ada6008b982fe40daca7e601fbfbb99f1ea57..3951d272ee8f3d046c96036be440fef8187f9e91 100644
(file)
--- a/
src/models/collection-file.ts
+++ b/
src/models/collection-file.ts
@@
-2,7
+2,8
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// SPDX-License-Identifier: AGPL-3.0
-import { Tree, createTree, setNode } from './tree';
+import { Tree, createTree, setNode, TreeNodeStatus } from './tree';
+import { head, split, pipe, join } from 'lodash/fp';
export type CollectionFilesTree = Tree<CollectionDirectory | CollectionFile>;
export type CollectionFilesTree = Tree<CollectionDirectory | CollectionFile>;
@@
-59,7
+60,21
@@
export const createCollectionFilesTree = (data: Array<CollectionDirectory | Coll
.reduce((tree, item) => setNode({
children: [],
id: item.id,
.reduce((tree, item) => setNode({
children: [],
id: item.id,
- parent: item.path,
- value: item
+ parent: getParentId(item),
+ value: item,
+ active: false,
+ selected: false,
+ expanded: false,
+ status: TreeNodeStatus.INITIAL
})(tree), createTree<CollectionDirectory | CollectionFile>());
})(tree), createTree<CollectionDirectory | CollectionFile>());
-};
\ 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