mirror of
https://github.com/bitwarden/browser
synced 2025-12-24 04:04:24 +00:00
* [AC-1423] Update organization subscription cloud page (#5614) * [AC-1423] Add ProgressModule to shared.module.ts * [AC-1423] Update cloud subscription page styles - Remove bootstrap styles - Use CL components where applicable - Use CL typography directives - Update heading levels to prepare for new SM sections * [AC-1423] Add usePasswordManager boolean to organization domain * [AC-1423] Introduce BitwardenProductType enum * [AC-1423] Update Organization subscription line items - Add product type prefix - Indent addon services like additional storage and service accounts - Show line items for free plans * [AC-1420] Add Secrets Manager subscribe component (#5617) * [AC-1418] Add secrets manager manage subscription component (#5661) * add additional properties (#5743) * Allow autoscale limits to be removed, update naming (#5781) * [AC-1488] Store Organization.SmServiceAccounts as total not additional (#5784) * Allow autoscale limits to be removed, update naming * Display additional service accounts only * [AC-1531] Fix SM subscribe component not showing in free org billing tab (#5848) --------- Co-authored-by: Shane Melton <smelton@bitwarden.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com> Co-authored-by: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Co-authored-by: Rui Tome <rtome@bitwarden.com>
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
|
|
|
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
|
import { OrganizationSubscriptionUpdateRequest } from "@bitwarden/common/billing/models/request/organization-subscription-update.request";
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
|
|
@Component({
|
|
selector: "app-adjust-subscription",
|
|
templateUrl: "adjust-subscription.component.html",
|
|
})
|
|
export class AdjustSubscription {
|
|
@Input() organizationId: string;
|
|
@Input() maxAutoscaleSeats: number;
|
|
@Input() currentSeatCount: number;
|
|
@Input() seatPrice = 0;
|
|
@Input() interval = "year";
|
|
@Output() onAdjusted = new EventEmitter();
|
|
|
|
formPromise: Promise<void>;
|
|
limitSubscription: boolean;
|
|
newSeatCount: number;
|
|
newMaxSeats: number;
|
|
|
|
constructor(
|
|
private i18nService: I18nService,
|
|
private platformUtilsService: PlatformUtilsService,
|
|
private logService: LogService,
|
|
private organizationApiService: OrganizationApiServiceAbstraction
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
this.limitSubscription = this.maxAutoscaleSeats != null;
|
|
this.newSeatCount = this.currentSeatCount;
|
|
this.newMaxSeats = this.maxAutoscaleSeats;
|
|
}
|
|
|
|
async submit() {
|
|
try {
|
|
const seatAdjustment = this.newSeatCount - this.currentSeatCount;
|
|
const request = new OrganizationSubscriptionUpdateRequest(seatAdjustment, this.newMaxSeats);
|
|
this.formPromise = this.organizationApiService.updatePasswordManagerSeats(
|
|
this.organizationId,
|
|
request
|
|
);
|
|
|
|
await this.formPromise;
|
|
|
|
this.platformUtilsService.showToast(
|
|
"success",
|
|
null,
|
|
this.i18nService.t("subscriptionUpdated")
|
|
);
|
|
} catch (e) {
|
|
this.logService.error(e);
|
|
}
|
|
this.onAdjusted.emit();
|
|
}
|
|
|
|
limitSubscriptionChanged() {
|
|
if (!this.limitSubscription) {
|
|
this.newMaxSeats = null;
|
|
}
|
|
}
|
|
|
|
get adjustedSeatTotal(): number {
|
|
return this.newSeatCount * this.seatPrice;
|
|
}
|
|
|
|
get maxSeatTotal(): number {
|
|
return this.newMaxSeats * this.seatPrice;
|
|
}
|
|
}
|