diff --git a/apps/web/src/app/organizations/vault/vault.component.html b/apps/web/src/app/organizations/vault/vault.component.html
index 9445a254f2c..8c9d1d3c84d 100644
--- a/apps/web/src/app/organizations/vault/vault.component.html
+++ b/apps/web/src/app/organizations/vault/vault.component.html
@@ -16,6 +16,17 @@
+
0">
+
+
+ {{ collection.node.name | i18n }}
+ {{ collection.node.name }}
+
+
{{ "vaultItems" | i18n }}
diff --git a/apps/web/src/app/vault/vault.component.ts b/apps/web/src/app/vault/vault.component.ts
index 2f407ecf9c6..ee6753d3487 100644
--- a/apps/web/src/app/vault/vault.component.ts
+++ b/apps/web/src/app/vault/vault.component.ts
@@ -37,7 +37,11 @@ import { ShareComponent } from "./share.component";
import { VaultFilterComponent } from "./vault-filter/components/vault-filter.component";
import { VaultFilterService } from "./vault-filter/services/abstractions/vault-filter.service";
import { VaultFilter } from "./vault-filter/shared/models/vault-filter.model";
-import { FolderFilter, OrganizationFilter } from "./vault-filter/shared/models/vault-filter.type";
+import {
+ CollectionFilter,
+ FolderFilter,
+ OrganizationFilter,
+} from "./vault-filter/shared/models/vault-filter.type";
import { VaultItemsComponent } from "./vault-items.component";
const BroadcasterSubscriptionId = "VaultComponent";
@@ -380,6 +384,29 @@ export class VaultComponent implements OnInit, OnDestroy {
await this.modalService.openViewRef(UpdateKeyComponent, this.updateKeyModalRef);
}
+ get breadcrumbs(): TreeNode[] {
+ if (!this.activeFilter.selectedCollectionNode) {
+ return [];
+ }
+
+ const collections = [this.activeFilter.selectedCollectionNode];
+ while (collections[collections.length - 1].parent != undefined) {
+ collections.push(collections[collections.length - 1].parent);
+ }
+
+ return collections
+ .map((c) => c)
+ .slice(1) // 1 for self
+ .reverse();
+ }
+
+ protected applyCollectionFilter(collection: TreeNode) {
+ const filter = this.activeFilter;
+ filter.resetFilter();
+ filter.selectedCollectionNode = collection;
+ this.applyVaultFilter(filter);
+ }
+
private go(queryParams: any = null) {
if (queryParams == null) {
queryParams = {
diff --git a/libs/common/src/misc/serviceUtils.spec.ts b/libs/common/src/misc/serviceUtils.spec.ts
index 592171507b7..7cfa318f8c3 100644
--- a/libs/common/src/misc/serviceUtils.spec.ts
+++ b/libs/common/src/misc/serviceUtils.spec.ts
@@ -1,56 +1,27 @@
-import { TreeNode } from "../models/domain/tree-node";
+import { ITreeNodeObject, TreeNode } from "../models/domain/tree-node";
import { ServiceUtils } from "./serviceUtils";
+type FakeObject = { id: string; name: string };
+
describe("serviceUtils", () => {
- type fakeObject = { id: string; name: string };
- let nodeTree: TreeNode[];
+ let nodeTree: TreeNode[];
beforeEach(() => {
nodeTree = [
- {
- parent: null,
- node: { id: "1", name: "1" },
- children: [
- {
- parent: { id: "1", name: "1" },
- node: { id: "1.1", name: "1.1" },
- children: [
- {
- parent: { id: "1.1", name: "1.1" },
- node: { id: "1.1.1", name: "1.1.1" },
- children: [],
- },
- ],
- },
- {
- parent: { id: "1", name: "1" },
- node: { id: "1.2", name: "1.2" },
- children: [],
- },
- ],
- },
- {
- parent: null,
- node: { id: "2", name: "2" },
- children: [
- {
- parent: { id: "2", name: "2" },
- node: { id: "2.1", name: "2.1" },
- children: [],
- },
- ],
- },
- {
- parent: null,
- node: { id: "3", name: "3" },
- children: [],
- },
+ createTreeNode({ id: "1", name: "1" }, [
+ createTreeNode({ id: "1.1", name: "1.1" }, [
+ createTreeNode({ id: "1.1.1", name: "1.1.1" }),
+ ]),
+ createTreeNode({ id: "1.2", name: "1.2" }),
+ ])(null),
+ createTreeNode({ id: "2", name: "2" }, [createTreeNode({ id: "2.1", name: "2.1" })])(null),
+ createTreeNode({ id: "3", name: "3" }, [])(null),
];
});
describe("nestedTraverse", () => {
it("should traverse a tree and add a node at the correct position given a valid path", () => {
- const nodeToBeAdded: fakeObject = { id: "1.2.1", name: "1.2.1" };
+ const nodeToBeAdded: FakeObject = { id: "1.2.1", name: "1.2.1" };
const path = ["1", "1.2", "1.2.1"];
ServiceUtils.nestedTraverse(nodeTree, 0, path, nodeToBeAdded, null, "/");
@@ -58,7 +29,7 @@ describe("serviceUtils", () => {
});
it("should combine the path for missing nodes and use as the added node name given an invalid path", () => {
- const nodeToBeAdded: fakeObject = { id: "blank", name: "blank" };
+ const nodeToBeAdded: FakeObject = { id: "blank", name: "blank" };
const path = ["3", "3.1", "3.1.1"];
ServiceUtils.nestedTraverse(nodeTree, 0, path, nodeToBeAdded, null, "/");
@@ -82,3 +53,20 @@ describe("serviceUtils", () => {
});
});
});
+
+type TreeNodeFactory = (
+ obj: T,
+ children?: TreeNodeFactoryWithoutParent[]
+) => TreeNodeFactoryWithoutParent;
+
+type TreeNodeFactoryWithoutParent = (
+ parent?: TreeNode
+) => TreeNode;
+
+const createTreeNode: TreeNodeFactory =
+ (obj, children = []) =>
+ (parent) => {
+ const node = new TreeNode(obj, parent, obj.name, obj.id);
+ node.children = children.map((childFunc) => childFunc(node));
+ return node;
+ };
diff --git a/libs/common/src/misc/serviceUtils.ts b/libs/common/src/misc/serviceUtils.ts
index 8934e842195..ac85cf0853a 100644
--- a/libs/common/src/misc/serviceUtils.ts
+++ b/libs/common/src/misc/serviceUtils.ts
@@ -15,7 +15,7 @@ export class ServiceUtils {
partIndex: number,
parts: string[],
obj: ITreeNodeObject,
- parent: ITreeNodeObject,
+ parent: TreeNode | undefined,
delimiter: string
) {
if (parts.length <= partIndex) {
@@ -40,7 +40,7 @@ export class ServiceUtils {
partIndex + 1,
parts,
obj,
- nodeTree[i].node,
+ nodeTree[i],
delimiter
);
return;
diff --git a/libs/common/src/models/domain/tree-node.ts b/libs/common/src/models/domain/tree-node.ts
index ea36eeafacf..7af1d9e6ab4 100644
--- a/libs/common/src/models/domain/tree-node.ts
+++ b/libs/common/src/models/domain/tree-node.ts
@@ -1,9 +1,9 @@
export class TreeNode {
- parent: T;
node: T;
+ parent: TreeNode;
children: TreeNode[] = [];
- constructor(node: T, parent: T, name?: string, id?: string) {
+ constructor(node: T, parent: TreeNode, name?: string, id?: string) {
this.parent = parent;
this.node = node;
if (name) {