mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
[SM-385] feat: add org-switcher filter input (#4235)
This commit is contained in:
parent
1f0e184cff
commit
b331f5b329
@ -2,7 +2,7 @@
|
||||
<bit-icon [icon]="logo" class="tw-w-full tw-text-alt2"></bit-icon>
|
||||
</a>
|
||||
|
||||
<org-switcher></org-switcher>
|
||||
<org-switcher [filter]="orgFilter"></org-switcher>
|
||||
<bit-nav-item icon="bwi-collection" text="Projects" route="projects"></bit-nav-item>
|
||||
<bit-nav-item icon="bwi-key" text="Secrets" route="secrets"></bit-nav-item>
|
||||
<bit-nav-item icon="bwi-wrench" text="Service Accounts" route="service-accounts"></bit-nav-item>
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
import { Organization } from "@bitwarden/common/models/domain/organization";
|
||||
|
||||
import { SecretsManagerLogo } from "./secrets-manager-logo";
|
||||
|
||||
@Component({
|
||||
@ -8,4 +10,6 @@ import { SecretsManagerLogo } from "./secrets-manager-logo";
|
||||
})
|
||||
export class NavigationComponent {
|
||||
protected readonly logo = SecretsManagerLogo;
|
||||
|
||||
protected orgFilter = (org: Organization) => org.canAccessSecretsManager;
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user