1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

[AC-1913] Update OrganizationLayoutComponent to use PolicyService to check if the user has the SingleOrg policy and use the value to hide the 'New Org' button (#8349)

This commit is contained in:
Rui Tomé 2024-04-03 15:51:21 +01:00 committed by GitHub
parent 2977616be4
commit ff3ff89e20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -3,7 +3,7 @@
<a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'adminConsole' | i18n"> <a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'adminConsole' | i18n">
<bit-icon [icon]="logo"></bit-icon> <bit-icon [icon]="logo"></bit-icon>
</a> </a>
<org-switcher [filter]="orgFilter"></org-switcher> <org-switcher [filter]="orgFilter" [hideNewButton]="hideNewOrgButton$ | async"></org-switcher>
<bit-nav-item <bit-nav-item
icon="bwi-collection" icon="bwi-collection"

View File

@ -15,6 +15,8 @@ import {
getOrganizationById, getOrganizationById,
OrganizationService, OrganizationService,
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { PolicyType } from "@bitwarden/common/admin-console/enums";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
@ -48,6 +50,7 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
organization$: Observable<Organization>; organization$: Observable<Organization>;
showPaymentAndHistory$: Observable<boolean>; showPaymentAndHistory$: Observable<boolean>;
hideNewOrgButton$: Observable<boolean>;
private _destroy = new Subject<void>(); private _destroy = new Subject<void>();
@ -61,6 +64,7 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
private organizationService: OrganizationService, private organizationService: OrganizationService,
private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService,
private configService: ConfigService, private configService: ConfigService,
private policyService: PolicyService,
) {} ) {}
async ngOnInit() { async ngOnInit() {
@ -85,6 +89,8 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
org?.canEditPaymentMethods, org?.canEditPaymentMethods,
), ),
); );
this.hideNewOrgButton$ = this.policyService.policyAppliesToActiveUser$(PolicyType.SingleOrg);
} }
ngOnDestroy() { ngOnDestroy() {

View File

@ -46,7 +46,6 @@ export class OrgSwitcherComponent {
/** /**
* Visibility of the New Organization button * Visibility of the New Organization button
* (Temporary; will be removed when ability to create organizations is added to SM.)
*/ */
@Input() @Input()
hideNewButton = false; hideNewButton = false;