1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

[SM-385] feat: add org-switcher filter input (#4235)

This commit is contained in:
Will Martin
2022-12-20 11:23:53 -05:00
committed by GitHub
parent 1f0e184cff
commit b331f5b329
3 changed files with 16 additions and 3 deletions

View File

@@ -12,13 +12,22 @@ import type { Organization } from "@bitwarden/common/models/domain/organization"
export class OrgSwitcherComponent {
protected organizations$: Observable<Organization[]> =
this.organizationService.organizations$.pipe(
map((orgs) => orgs.sort((a, b) => a.name.localeCompare(b.name)))
map((orgs) => orgs.filter(this.filter).sort((a, b) => a.name.localeCompare(b.name)))
);
protected activeOrganization$: Observable<Organization> = combineLatest([
this.route.paramMap,
this.organizationService.organizations$,
this.organizations$,
]).pipe(map(([params, orgs]) => orgs.find((org) => org.id === params.get("organizationId"))));
/**
* Filter function for displayed organizations in the `org-switcher`
* @example
* const smFilter = (org: Organization) => org.canAccessSecretsManager
* // <org-switcher [filter]="smFilter">
*/
@Input()
filter: (org: Organization) => boolean = () => true;
/**
* Is `true` if the expanded content is visible
*/