Skip to content

Commit 72f7d8b

Browse files
Revert "group collection in getNestedCollectionTree" (#16731)
This reverts commit 1578f44.
1 parent a3696ea commit 72f7d8b

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

apps/web/src/app/admin-console/organizations/collections/utils/collection-utils.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
CollectionView,
66
NestingDelimiter,
77
} from "@bitwarden/admin-console/common";
8-
import { OrganizationId } from "@bitwarden/common/types/guid";
98
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
109
import { ServiceUtils } from "@bitwarden/common/vault/service-utils";
1110

@@ -27,23 +26,15 @@ export function getNestedCollectionTree(
2726
.sort((a, b) => a.name.localeCompare(b.name))
2827
.map(cloneCollection);
2928

30-
const all: TreeNode<CollectionView | CollectionAdminView>[] = [];
31-
const groupedByOrg = new Map<OrganizationId, CollectionView[]>();
32-
clonedCollections.map((c) => {
33-
const key = c.organizationId;
34-
(groupedByOrg.get(key) ?? groupedByOrg.set(key, []).get(key)!).push(c);
29+
const nodes: TreeNode<CollectionView | CollectionAdminView>[] = [];
30+
clonedCollections.forEach((collection) => {
31+
const parts =
32+
collection.name != null
33+
? collection.name.replace(/^\/+|\/+$/g, "").split(NestingDelimiter)
34+
: [];
35+
ServiceUtils.nestedTraverse(nodes, 0, parts, collection, null, NestingDelimiter);
3536
});
36-
37-
for (const group of groupedByOrg.values()) {
38-
const nodes: TreeNode<CollectionView>[] = [];
39-
for (const c of group) {
40-
const collectionCopy = Object.assign(new CollectionView({ ...c, name: c.name }), c);
41-
const parts = c.name ? c.name.replace(/^\/+|\/+$/g, "").split(NestingDelimiter) : [];
42-
ServiceUtils.nestedTraverse(nodes, 0, parts, collectionCopy, undefined, NestingDelimiter);
43-
}
44-
all.push(...nodes);
45-
}
46-
return all;
37+
return nodes;
4738
}
4839

4940
export function cloneCollection(collection: CollectionView): CollectionView;

0 commit comments

Comments
 (0)