Merge branch 'main' of https://github.com/bitwarden/clients into PM-2051-update-bulk-remove-dialog
This commit is contained in:
commit
209436445f
|
@ -75,6 +75,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges,
|
|||
|
||||
async ngOnInit() {
|
||||
await super.ngOnInit();
|
||||
await this.load();
|
||||
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
|
||||
this.ngZone.run(() => {
|
||||
switch (message.command) {
|
||||
|
|
|
@ -20,19 +20,4 @@
|
|||
<input bitInput type="email" formControlName="clientOwnerEmail" />
|
||||
</bit-form-field>
|
||||
</div>
|
||||
<div *ngIf="!isProvider && !acceptingSponsorship">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="businessOwned"
|
||||
formControlName="businessOwned"
|
||||
(change)="changedBusinessOwned.emit()"
|
||||
/>
|
||||
<bit-label for="businessOwned" class="tw-mb-3">{{ "accountOwnedBusiness" | i18n }}</bit-label>
|
||||
<div class="tw-mt-4" *ngIf="formGroup.controls['businessOwned'].value">
|
||||
<bit-form-field class="tw-w-1/2">
|
||||
<bit-label>{{ "businessName" | i18n }}</bit-label>
|
||||
<input bitInput type="text" formControlName="businessName" />
|
||||
</bit-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,15 +1,32 @@
|
|||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
|
||||
import { UntypedFormGroup } from "@angular/forms";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-org-info",
|
||||
templateUrl: "organization-information.component.html",
|
||||
})
|
||||
export class OrganizationInformationComponent {
|
||||
export class OrganizationInformationComponent implements OnInit {
|
||||
@Input() nameOnly = false;
|
||||
@Input() createOrganization = true;
|
||||
@Input() isProvider = false;
|
||||
@Input() acceptingSponsorship = false;
|
||||
@Input() formGroup: UntypedFormGroup;
|
||||
@Output() changedBusinessOwned = new EventEmitter<void>();
|
||||
|
||||
constructor(private accountService: AccountService) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
if (this.formGroup.controls.billingEmail.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const activeAccount = await firstValueFrom(this.accountService.activeAccount$);
|
||||
|
||||
if (activeAccount?.email) {
|
||||
this.formGroup.controls.billingEmail.setValue(activeAccount.email);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
<bit-label>{{ "billingEmail" | i18n }}</bit-label>
|
||||
<input bitInput id="billingEmail" formControlName="billingEmail" type="email" />
|
||||
</bit-form-field>
|
||||
<bit-form-field>
|
||||
<bit-label>{{ "businessName" | i18n }}</bit-label>
|
||||
<input bitInput id="businessName" formControlName="businessName" type="text" />
|
||||
</bit-form-field>
|
||||
</div>
|
||||
<div>
|
||||
<bit-avatar [text]="org.name" [id]="org.id" size="large"></bit-avatar>
|
||||
|
|
|
@ -65,10 +65,6 @@ export class AccountComponent {
|
|||
{ value: "", disabled: true },
|
||||
{ validators: [Validators.required, Validators.email, Validators.maxLength(256)] },
|
||||
),
|
||||
businessName: this.formBuilder.control(
|
||||
{ value: "", disabled: true },
|
||||
{ validators: [Validators.maxLength(50)] },
|
||||
),
|
||||
});
|
||||
|
||||
protected collectionManagementFormGroup = this.formBuilder.group({
|
||||
|
@ -124,7 +120,6 @@ export class AccountComponent {
|
|||
// Update disabled states - reactive forms prefers not using disabled attribute
|
||||
if (!this.selfHosted) {
|
||||
this.formGroup.get("orgName").enable();
|
||||
this.formGroup.get("businessName").enable();
|
||||
this.collectionManagementFormGroup.get("limitCollectionCreationDeletion").enable();
|
||||
this.collectionManagementFormGroup.get("allowAdminAccessToAllCollectionItems").enable();
|
||||
}
|
||||
|
@ -143,7 +138,6 @@ export class AccountComponent {
|
|||
this.formGroup.patchValue({
|
||||
orgName: this.org.name,
|
||||
billingEmail: this.org.billingEmail,
|
||||
businessName: this.org.businessName,
|
||||
});
|
||||
this.collectionManagementFormGroup.patchValue({
|
||||
limitCollectionCreationDeletion: this.org.limitCollectionCreationDeletion,
|
||||
|
@ -168,7 +162,6 @@ export class AccountComponent {
|
|||
|
||||
const request = new OrganizationUpdateRequest();
|
||||
request.name = this.formGroup.value.orgName;
|
||||
request.businessName = this.formGroup.value.businessName;
|
||||
request.billingEmail = this.formGroup.value.billingEmail;
|
||||
|
||||
// Backfill pub/priv key if necessary
|
||||
|
|
|
@ -120,7 +120,6 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||
additionalStorage: [0, [Validators.min(0), Validators.max(99)]],
|
||||
additionalSeats: [0, [Validators.min(0), Validators.max(100000)]],
|
||||
clientOwnerEmail: ["", [Validators.email]],
|
||||
businessName: [""],
|
||||
plan: [this.plan],
|
||||
product: [this.product],
|
||||
secretsManager: this.secretsManagerSubscription,
|
||||
|
@ -596,9 +595,6 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||
|
||||
private async updateOrganization(orgId: string) {
|
||||
const request = new OrganizationUpgradeRequest();
|
||||
request.businessName = this.formGroup.controls.businessOwned.value
|
||||
? this.formGroup.controls.businessName.value
|
||||
: null;
|
||||
request.additionalSeats = this.formGroup.controls.additionalSeats.value;
|
||||
request.additionalStorageGb = this.formGroup.controls.additionalStorage.value;
|
||||
request.premiumAccessAddon =
|
||||
|
@ -656,9 +652,6 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||
|
||||
request.paymentToken = tokenResult[0];
|
||||
request.paymentMethodType = tokenResult[1];
|
||||
request.businessName = this.formGroup.controls.businessOwned.value
|
||||
? this.formGroup.controls.businessName.value
|
||||
: null;
|
||||
request.additionalSeats = this.formGroup.controls.additionalSeats.value;
|
||||
request.additionalStorageGb = this.formGroup.controls.additionalStorage.value;
|
||||
request.premiumAccessAddon =
|
||||
|
|
|
@ -592,7 +592,7 @@ export class AddEditComponent implements OnInit, OnDestroy {
|
|||
this.writeableCollections.forEach((c) => ((c as any).checked = false));
|
||||
}
|
||||
if (this.cipher.organizationId != null) {
|
||||
this.collections = this.writeableCollections.filter(
|
||||
this.collections = this.writeableCollections?.filter(
|
||||
(c) => c.organizationId === this.cipher.organizationId,
|
||||
);
|
||||
const org = await this.organizationService.get(this.cipher.organizationId);
|
||||
|
|
|
@ -121,7 +121,11 @@ export abstract class OrganizationService {
|
|||
get$: (id: string) => Observable<Organization | undefined>;
|
||||
get: (id: string) => Promise<Organization>;
|
||||
getAll: (userId?: string) => Promise<Organization[]>;
|
||||
//
|
||||
|
||||
/**
|
||||
* Publishes state for all organizations for the given user id or the active user.
|
||||
*/
|
||||
getAll$: (userId?: UserId) => Observable<Organization[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,6 +73,10 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
|||
return this.organizations$.pipe(mapToSingleOrganization(id));
|
||||
}
|
||||
|
||||
getAll$(userId?: UserId): Observable<Organization[]> {
|
||||
return this.getOrganizationsFromState$(userId);
|
||||
}
|
||||
|
||||
async getAll(userId?: string): Promise<Organization[]> {
|
||||
return await firstValueFrom(this.getOrganizationsFromState$(userId as UserId));
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ describe("PolicyService", () => {
|
|||
organizationService = mock<OrganizationService>();
|
||||
|
||||
activeUserState = stateProvider.activeUser.getFake(POLICIES);
|
||||
organizationService.organizations$ = of([
|
||||
|
||||
const organizations$ = of([
|
||||
// User
|
||||
organization("org1", true, true, OrganizationUserStatusType.Confirmed, false),
|
||||
// Owner
|
||||
|
@ -54,6 +55,10 @@ describe("PolicyService", () => {
|
|||
organization("org6", true, true, OrganizationUserStatusType.Confirmed, true),
|
||||
]);
|
||||
|
||||
organizationService.organizations$ = organizations$;
|
||||
|
||||
organizationService.getAll$.mockReturnValue(organizations$);
|
||||
|
||||
policyService = new PolicyService(stateProvider, organizationService);
|
||||
});
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
|||
map((policies) => policies.filter((p) => p.type === policyType)),
|
||||
);
|
||||
|
||||
return combineLatest([filteredPolicies$, this.organizationService.organizations$]).pipe(
|
||||
return combineLatest([filteredPolicies$, this.organizationService.getAll$(userId)]).pipe(
|
||||
map(([policies, organizations]) => this.enforcedPolicyFilter(policies, organizations)),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue