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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user