mirror of
https://github.com/bitwarden/browser
synced 2025-12-31 23:53:37 +00:00
* [PM-12389] Cleanup attachment dialog UI bugs * [PM-12389] Add formReady event to CipherForm * [PM-12389] Use ngOnChanges for CipherView component initialization * [PM-12389] Cleanup web specific services and components * [PM-12389] Introduce combined Vault Item Dialog component * [PM-12389] Use the new VaultItemDialog in the Individual Vault * [PM-12389] Deprecate the AddEditV2 and View dialogs in Web * [PM-12389] Fix failing test * [PM-12389] Fix broken imports after move * [PM-12389] Remove messages.json addition that is taken care of in another PR
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import { DialogRef } from "@angular/cdk/dialog";
|
|
import { Injectable } from "@angular/core";
|
|
import { Router } from "@angular/router";
|
|
|
|
import { OrganizationId } from "@bitwarden/common/types/guid";
|
|
import { PremiumUpgradePromptService } from "@bitwarden/common/vault/abstractions/premium-upgrade-prompt.service";
|
|
import { DialogService } from "@bitwarden/components";
|
|
|
|
import { VaultItemDialogResult } from "../components/vault-item-dialog/vault-item-dialog.component";
|
|
|
|
/**
|
|
* This service is used to prompt the user to upgrade to premium.
|
|
*/
|
|
@Injectable()
|
|
export class WebVaultPremiumUpgradePromptService implements PremiumUpgradePromptService {
|
|
constructor(
|
|
private dialogService: DialogService,
|
|
private router: Router,
|
|
private dialog: DialogRef<VaultItemDialogResult>,
|
|
) {}
|
|
|
|
/**
|
|
* Prompts the user to upgrade to premium.
|
|
* @param organizationId The ID of the organization to upgrade.
|
|
*/
|
|
async promptForPremium(organizationId?: OrganizationId) {
|
|
let upgradeConfirmed;
|
|
if (organizationId) {
|
|
upgradeConfirmed = await this.dialogService.openSimpleDialog({
|
|
title: { key: "upgradeOrganization" },
|
|
content: { key: "upgradeOrganizationDesc" },
|
|
acceptButtonText: { key: "upgradeOrganization" },
|
|
type: "info",
|
|
});
|
|
if (upgradeConfirmed) {
|
|
await this.router.navigate(["organizations", organizationId, "billing", "subscription"]);
|
|
}
|
|
} else {
|
|
upgradeConfirmed = await this.dialogService.openSimpleDialog({
|
|
title: { key: "premiumRequired" },
|
|
content: { key: "premiumRequiredDesc" },
|
|
acceptButtonText: { key: "upgrade" },
|
|
type: "success",
|
|
});
|
|
if (upgradeConfirmed) {
|
|
await this.router.navigate(["settings/subscription/premium"]);
|
|
}
|
|
}
|
|
|
|
if (upgradeConfirmed) {
|
|
this.dialog.close(VaultItemDialogResult.PremiumUpgrade);
|
|
}
|
|
}
|
|
}
|