mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[AC-2858] Remove code supporting payment method warning banners (#10615)
* Remove errant payment method warning banner implementation * Removing unused endpoint
This commit is contained in:
@@ -2,17 +2,7 @@ import { DOCUMENT } from "@angular/common";
|
||||
import { Component, Inject, NgZone, OnDestroy, OnInit } from "@angular/core";
|
||||
import { NavigationEnd, Router } from "@angular/router";
|
||||
import * as jq from "jquery";
|
||||
import {
|
||||
Subject,
|
||||
combineLatest,
|
||||
filter,
|
||||
firstValueFrom,
|
||||
map,
|
||||
switchMap,
|
||||
takeUntil,
|
||||
timeout,
|
||||
timer,
|
||||
} from "rxjs";
|
||||
import { Subject, filter, firstValueFrom, map, takeUntil, timeout } from "rxjs";
|
||||
|
||||
import { LogoutReason } from "@bitwarden/auth/common";
|
||||
import { EventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
|
||||
@@ -25,8 +15,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||
import { PaymentMethodWarningsServiceAbstraction as PaymentMethodWarningService } from "@bitwarden/common/billing/abstractions/payment-method-warnings-service.abstraction";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
@@ -58,7 +46,6 @@ import {
|
||||
|
||||
const BroadcasterSubscriptionId = "AppComponent";
|
||||
const IdleTimeout = 60000 * 10; // 10 minutes
|
||||
const PaymentMethodWarningsRefresh = 60000; // 1 Minute
|
||||
|
||||
@Component({
|
||||
selector: "app-root",
|
||||
@@ -69,7 +56,6 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
private idleTimer: number = null;
|
||||
private isIdle = false;
|
||||
private destroy$ = new Subject<void>();
|
||||
private paymentMethodWarningsRefresh$ = timer(0, PaymentMethodWarningsRefresh);
|
||||
|
||||
constructor(
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
@@ -98,7 +84,6 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
private dialogService: DialogService,
|
||||
private biometricStateService: BiometricStateService,
|
||||
private stateEventRunnerService: StateEventRunnerService,
|
||||
private paymentMethodWarningService: PaymentMethodWarningService,
|
||||
private organizationService: InternalOrganizationServiceAbstraction,
|
||||
private accountService: AccountService,
|
||||
) {}
|
||||
@@ -252,25 +237,6 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
new DisableSendPolicy(),
|
||||
new SendOptionsPolicy(),
|
||||
]);
|
||||
|
||||
combineLatest([
|
||||
this.configService.getFeatureFlag$(FeatureFlag.ShowPaymentMethodWarningBanners),
|
||||
this.paymentMethodWarningsRefresh$,
|
||||
])
|
||||
.pipe(
|
||||
filter(([showPaymentMethodWarningBanners]) => showPaymentMethodWarningBanners),
|
||||
switchMap(() => this.organizationService.memberOrganizations$),
|
||||
switchMap(
|
||||
async (organizations) =>
|
||||
await Promise.all(
|
||||
organizations.map((organization) =>
|
||||
this.paymentMethodWarningService.update(organization.id),
|
||||
),
|
||||
),
|
||||
),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -328,7 +294,6 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
this.folderService.clear(userId),
|
||||
this.collectionService.clear(userId),
|
||||
this.biometricStateService.logout(userId),
|
||||
this.paymentMethodWarningService.clear(),
|
||||
]);
|
||||
|
||||
await this.stateEventRunnerService.handleEvent("logout", userId);
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
|
||||
import { Component, Inject, ViewChild } from "@angular/core";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PaymentMethodWarningsServiceAbstraction as PaymentMethodWarningService } from "@bitwarden/common/billing/abstractions/payment-method-warnings-service.abstraction";
|
||||
import { PaymentMethodType } from "@bitwarden/common/billing/enums";
|
||||
import { PaymentRequest } from "@bitwarden/common/billing/models/request/payment.request";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { DialogService, ToastService } from "@bitwarden/components";
|
||||
@@ -46,7 +43,6 @@ export class AdjustPaymentDialogComponent {
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||
private paymentMethodWarningService: PaymentMethodWarningService,
|
||||
private configService: ConfigService,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
@@ -78,12 +74,6 @@ export class AdjustPaymentDialogComponent {
|
||||
}
|
||||
});
|
||||
await response;
|
||||
const showPaymentMethodWarningBanners = await firstValueFrom(
|
||||
this.configService.getFeatureFlag$(FeatureFlag.ShowPaymentMethodWarningBanners),
|
||||
);
|
||||
if (this.organizationId && showPaymentMethodWarningBanners) {
|
||||
await this.paymentMethodWarningService.removeSubscriptionRisk(this.organizationId);
|
||||
}
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
title: null,
|
||||
|
||||
@@ -3,4 +3,3 @@ export * from "./payment-method.component";
|
||||
export * from "./payment.component";
|
||||
export * from "./sm-subscribe.component";
|
||||
export * from "./tax-info.component";
|
||||
export * from "./payment-method-warnings/payment-method-warnings.module";
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<ng-container *ngFor="let warning of warnings$ | async">
|
||||
<bit-banner
|
||||
class="-tw-m-6 tw-flex tw-flex-col tw-pb-6"
|
||||
bannerType="warning"
|
||||
(onClose)="closeWarning(warning.organizationId)"
|
||||
>
|
||||
{{ "maintainYourSubscription" | i18n: warning.organizationName }}
|
||||
<a
|
||||
bitLink
|
||||
linkType="contrast"
|
||||
[routerLink]="['/organizations', warning.organizationId, 'billing', 'payment-method']"
|
||||
>{{ "addAPaymentMethod" | i18n }}</a
|
||||
>.
|
||||
</bit-banner>
|
||||
</ng-container>
|
||||
@@ -1,33 +0,0 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { map, Observable } from "rxjs";
|
||||
|
||||
import { PaymentMethodWarningsServiceAbstraction as PaymentMethodWarningService } from "@bitwarden/common/billing/abstractions/payment-method-warnings-service.abstraction";
|
||||
|
||||
type Warning = {
|
||||
organizationId: string;
|
||||
organizationName: string;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: "app-payment-method-warnings",
|
||||
templateUrl: "payment-method-warnings.component.html",
|
||||
})
|
||||
export class PaymentMethodWarningsComponent {
|
||||
constructor(private paymentMethodWarningService: PaymentMethodWarningService) {}
|
||||
|
||||
protected warnings$: Observable<Warning[]> =
|
||||
this.paymentMethodWarningService.paymentMethodWarnings$.pipe(
|
||||
map((warnings) =>
|
||||
Object.entries(warnings ?? [])
|
||||
.filter(([_, warning]) => warning.risksSubscriptionFailure && !warning.acknowledged)
|
||||
.map(([organizationId, { organizationName }]) => ({
|
||||
organizationId,
|
||||
organizationName,
|
||||
})),
|
||||
),
|
||||
);
|
||||
|
||||
protected async closeWarning(organizationId: string): Promise<void> {
|
||||
await this.paymentMethodWarningService.acknowledge(organizationId);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { BannerModule } from "@bitwarden/components";
|
||||
|
||||
import { SharedModule } from "../../../shared";
|
||||
|
||||
import { PaymentMethodWarningsComponent } from "./payment-method-warnings.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [BannerModule, SharedModule],
|
||||
declarations: [PaymentMethodWarningsComponent],
|
||||
exports: [PaymentMethodWarningsComponent],
|
||||
})
|
||||
export class PaymentMethodWarningsModule {}
|
||||
@@ -1,9 +1,4 @@
|
||||
<bit-layout>
|
||||
<ng-content select="app-side-nav, [slot=side-nav]" slot="side-nav"></ng-content>
|
||||
|
||||
<app-payment-method-warnings
|
||||
*ngIf="showPaymentMethodWarningBanners$ | async"
|
||||
></app-payment-method-warnings>
|
||||
|
||||
<ng-content></ng-content>
|
||||
</bit-layout>
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { LayoutComponent } from "@bitwarden/components";
|
||||
|
||||
import { PaymentMethodWarningsModule } from "../billing/shared";
|
||||
|
||||
import { ProductSwitcherModule } from "./product-switcher/product-switcher.module";
|
||||
import { ToggleWidthComponent } from "./toggle-width.component";
|
||||
|
||||
@@ -14,18 +10,8 @@ import { ToggleWidthComponent } from "./toggle-width.component";
|
||||
selector: "app-layout",
|
||||
templateUrl: "web-layout.component.html",
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
LayoutComponent,
|
||||
ProductSwitcherModule,
|
||||
ToggleWidthComponent,
|
||||
PaymentMethodWarningsModule,
|
||||
],
|
||||
imports: [CommonModule, LayoutComponent, ProductSwitcherModule, ToggleWidthComponent],
|
||||
})
|
||||
export class WebLayoutComponent {
|
||||
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.ShowPaymentMethodWarningBanners,
|
||||
);
|
||||
|
||||
constructor(private configService: ConfigService) {}
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ import { VerifyEmailTokenComponent } from "../auth/verify-email-token.component"
|
||||
import { VerifyRecoverDeleteComponent } from "../auth/verify-recover-delete.component";
|
||||
import { SponsoredFamiliesComponent } from "../billing/settings/sponsored-families.component";
|
||||
import { SponsoringOrgRowComponent } from "../billing/settings/sponsoring-org-row.component";
|
||||
import { PaymentMethodWarningsModule } from "../billing/shared";
|
||||
import { DynamicAvatarComponent } from "../components/dynamic-avatar.component";
|
||||
import { SelectableAvatarComponent } from "../components/selectable-avatar.component";
|
||||
import { FrontendLayoutComponent } from "../layouts/frontend-layout.component";
|
||||
@@ -113,7 +112,6 @@ import { SharedModule } from "./shared.module";
|
||||
HeaderModule,
|
||||
OrganizationLayoutComponent,
|
||||
UserLayoutComponent,
|
||||
PaymentMethodWarningsModule,
|
||||
VerifyRecoverDeleteOrgComponent,
|
||||
VaultTimeoutInputComponent,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user