mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-29 12:55:21 +01:00
update icons for folder & collection filters (#9508)
This commit is contained in:
parent
6eb94078f6
commit
d0c1325f0c
@ -169,6 +169,13 @@ describe("VaultPopupListFiltersService", () => {
|
|||||||
expect(collections.map((c) => c.label)).toEqual(["Test collection 2"]);
|
expect(collections.map((c) => c.label)).toEqual(["Test collection 2"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sets collection icon", (done) => {
|
||||||
|
service.collections$.subscribe((collections) => {
|
||||||
|
expect(collections.every(({ icon }) => icon === "bwi-collection")).toBeTruthy();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("folders$", () => {
|
describe("folders$", () => {
|
||||||
@ -210,6 +217,22 @@ describe("VaultPopupListFiltersService", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sets folder icon", (done) => {
|
||||||
|
service.filterForm.patchValue({
|
||||||
|
organization: { id: MY_VAULT_ID } as Organization,
|
||||||
|
});
|
||||||
|
|
||||||
|
folderViews$.next([
|
||||||
|
{ id: "1234", name: "Folder 1" },
|
||||||
|
{ id: "2345", name: "Folder 2" },
|
||||||
|
]);
|
||||||
|
|
||||||
|
service.folders$.subscribe((folders) => {
|
||||||
|
expect(folders.every(({ icon }) => icon === "bwi-folder")).toBeTruthy();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("returns folders that have ciphers within the selected organization", (done) => {
|
it("returns folders that have ciphers within the selected organization", (done) => {
|
||||||
service.folders$.pipe(skipWhile((folders) => folders.length === 2)).subscribe((folders) => {
|
service.folders$.pipe(skipWhile((folders) => folders.length === 2)).subscribe((folders) => {
|
||||||
expect(folders.map((f) => f.label)).toEqual(["Folder 1"]);
|
expect(folders.map((f) => f.label)).toEqual(["Folder 1"]);
|
||||||
|
@ -206,7 +206,7 @@ export class VaultPopupListFiltersService {
|
|||||||
/**
|
/**
|
||||||
* Folder array structured to be directly passed to `ChipSelectComponent`
|
* Folder array structured to be directly passed to `ChipSelectComponent`
|
||||||
*/
|
*/
|
||||||
folders$: Observable<ChipSelectOption<string>[]> = combineLatest([
|
folders$: Observable<ChipSelectOption<FolderView>[]> = combineLatest([
|
||||||
this.filters$.pipe(
|
this.filters$.pipe(
|
||||||
distinctUntilChanged(
|
distinctUntilChanged(
|
||||||
(previousFilter, currentFilter) =>
|
(previousFilter, currentFilter) =>
|
||||||
@ -258,13 +258,15 @@ export class VaultPopupListFiltersService {
|
|||||||
nestedList: nestedFolders,
|
nestedList: nestedFolders,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
map((folders) => folders.nestedList.map(this.convertToChipSelectOption.bind(this))),
|
map((folders) =>
|
||||||
|
folders.nestedList.map((f) => this.convertToChipSelectOption(f, "bwi-folder")),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection array structured to be directly passed to `ChipSelectComponent`
|
* Collection array structured to be directly passed to `ChipSelectComponent`
|
||||||
*/
|
*/
|
||||||
collections$: Observable<ChipSelectOption<string>[]> = combineLatest([
|
collections$: Observable<ChipSelectOption<CollectionView>[]> = combineLatest([
|
||||||
this.filters$.pipe(
|
this.filters$.pipe(
|
||||||
distinctUntilChanged(
|
distinctUntilChanged(
|
||||||
(previousFilter, currentFilter) =>
|
(previousFilter, currentFilter) =>
|
||||||
@ -292,7 +294,9 @@ export class VaultPopupListFiltersService {
|
|||||||
nestedList: nestedCollections,
|
nestedList: nestedCollections,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
map((collections) => collections.nestedList.map(this.convertToChipSelectOption.bind(this))),
|
map((collections) =>
|
||||||
|
collections.nestedList.map((c) => this.convertToChipSelectOption(c, "bwi-collection")),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,13 +304,14 @@ export class VaultPopupListFiltersService {
|
|||||||
*/
|
*/
|
||||||
private convertToChipSelectOption<T extends ITreeNodeObject>(
|
private convertToChipSelectOption<T extends ITreeNodeObject>(
|
||||||
item: TreeNode<T>,
|
item: TreeNode<T>,
|
||||||
|
icon: string,
|
||||||
): ChipSelectOption<T> {
|
): ChipSelectOption<T> {
|
||||||
return {
|
return {
|
||||||
value: item.node,
|
value: item.node,
|
||||||
label: item.node.name,
|
label: item.node.name,
|
||||||
icon: "bwi-folder", // Organization & Folder icons are the same
|
icon,
|
||||||
children: item.children
|
children: item.children
|
||||||
? item.children.map(this.convertToChipSelectOption.bind(this))
|
? item.children.map((i) => this.convertToChipSelectOption(i, icon))
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user