1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 13:53:34 +00:00

[PM-14861]Vault items fail to load (#11974)

* Resolve the vault items fail to load

* Remove the hasSubscription

* Replace with hasSubscription from metadata

* Resolve the failing popup
This commit is contained in:
cyprain-okeke
2024-11-13 13:28:40 +01:00
committed by GitHub
parent 84b2b02f12
commit 24ca942cd6
3 changed files with 31 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ import {
from, from,
lastValueFrom, lastValueFrom,
Observable, Observable,
of,
Subject, Subject,
} from "rxjs"; } from "rxjs";
import { import {
@@ -184,12 +185,17 @@ export class VaultComponent implements OnInit, OnDestroy {
private refresh$ = new BehaviorSubject<void>(null); private refresh$ = new BehaviorSubject<void>(null);
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();
private extensionRefreshEnabled: boolean; private extensionRefreshEnabled: boolean;
private hasSubscription$ = new BehaviorSubject<boolean>(false);
private vaultItemDialogRef?: DialogRef<VaultItemDialogResult> | undefined; private vaultItemDialogRef?: DialogRef<VaultItemDialogResult> | undefined;
private readonly unpaidSubscriptionDialog$ = this.organizationService.organizations$.pipe( private readonly unpaidSubscriptionDialog$ = this.organizationService.organizations$.pipe(
filter((organizations) => organizations.length === 1), filter((organizations) => organizations.length === 1),
switchMap(([organization]) => map(([organization]) => organization),
switchMap((organization) =>
from(this.billingApiService.getOrganizationBillingMetadata(organization.id)).pipe( from(this.billingApiService.getOrganizationBillingMetadata(organization.id)).pipe(
tap((organizationMetaData) => {
this.hasSubscription$.next(organizationMetaData.hasSubscription);
}),
switchMap((organizationMetaData) => switchMap((organizationMetaData) =>
from( from(
this.trialFlowService.handleUnpaidSubscriptionDialog( this.trialFlowService.handleUnpaidSubscriptionDialog(
@@ -417,11 +423,17 @@ export class VaultComponent implements OnInit, OnDestroy {
this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe(); this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe();
const organizationsPaymentStatus$ = this.organizationService.organizations$.pipe( const organizationsPaymentStatus$ = combineLatest([
switchMap((allOrganizations) => { this.organizationService.organizations$,
this.hasSubscription$,
]).pipe(
switchMap(([allOrganizations, hasSubscription]) => {
if (!allOrganizations || allOrganizations.length === 0 || !hasSubscription) {
return of([]);
}
return combineLatest( return combineLatest(
allOrganizations allOrganizations
.filter((org) => org.isOwner) .filter((org) => org.isOwner && hasSubscription)
.map((org) => .map((org) =>
combineLatest([ combineLatest([
this.organizationApiService.getSubscription(org.id), this.organizationApiService.getSubscription(org.id),

View File

@@ -178,6 +178,7 @@ export class VaultComponent implements OnInit, OnDestroy {
protected selectedCollection: TreeNode<CollectionAdminView> | undefined; protected selectedCollection: TreeNode<CollectionAdminView> | undefined;
protected isEmpty: boolean; protected isEmpty: boolean;
protected showCollectionAccessRestricted: boolean; protected showCollectionAccessRestricted: boolean;
private hasSubscription$ = new BehaviorSubject<boolean>(false);
protected currentSearchText$: Observable<string>; protected currentSearchText$: Observable<string>;
protected freeTrial$: Observable<FreeTrial>; protected freeTrial$: Observable<FreeTrial>;
/** /**
@@ -197,10 +198,15 @@ export class VaultComponent implements OnInit, OnDestroy {
protected addAccessStatus$ = new BehaviorSubject<AddAccessStatusType>(0); protected addAccessStatus$ = new BehaviorSubject<AddAccessStatusType>(0);
private extensionRefreshEnabled: boolean; private extensionRefreshEnabled: boolean;
private vaultItemDialogRef?: DialogRef<VaultItemDialogResult> | undefined; private vaultItemDialogRef?: DialogRef<VaultItemDialogResult> | undefined;
private readonly unpaidSubscriptionDialog$ = this.organizationService.organizations$.pipe( private readonly unpaidSubscriptionDialog$ = this.organizationService.organizations$.pipe(
filter((organizations) => organizations.length === 1), filter((organizations) => organizations.length === 1),
switchMap(([organization]) => map(([organization]) => organization),
switchMap((organization) =>
from(this.billingApiService.getOrganizationBillingMetadata(organization.id)).pipe( from(this.billingApiService.getOrganizationBillingMetadata(organization.id)).pipe(
tap((organizationMetaData) => {
this.hasSubscription$.next(organizationMetaData.hasSubscription);
}),
switchMap((organizationMetaData) => switchMap((organizationMetaData) =>
from( from(
this.trialFlowService.handleUnpaidSubscriptionDialog( this.trialFlowService.handleUnpaidSubscriptionDialog(
@@ -580,9 +586,12 @@ export class VaultComponent implements OnInit, OnDestroy {
this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe(); this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe();
this.freeTrial$ = organization$.pipe( this.freeTrial$ = combineLatest([
filter((org) => org.isOwner), organization$,
switchMap((org) => this.hasSubscription$.pipe(filter((hasSubscription) => hasSubscription !== null)),
]).pipe(
filter(([org, hasSubscription]) => org.isOwner && hasSubscription),
switchMap(([org]) =>
combineLatest([ combineLatest([
of(org), of(org),
this.organizationApiService.getSubscription(org.id), this.organizationApiService.getSubscription(org.id),

View File

@@ -5,6 +5,7 @@ export class OrganizationBillingMetadataResponse extends BaseResponse {
isManaged: boolean; isManaged: boolean;
isOnSecretsManagerStandalone: boolean; isOnSecretsManagerStandalone: boolean;
isSubscriptionUnpaid: boolean; isSubscriptionUnpaid: boolean;
hasSubscription: boolean;
constructor(response: any) { constructor(response: any) {
super(response); super(response);
@@ -12,5 +13,6 @@ export class OrganizationBillingMetadataResponse extends BaseResponse {
this.isManaged = this.getResponseProperty("IsManaged"); this.isManaged = this.getResponseProperty("IsManaged");
this.isOnSecretsManagerStandalone = this.getResponseProperty("IsOnSecretsManagerStandalone"); this.isOnSecretsManagerStandalone = this.getResponseProperty("IsOnSecretsManagerStandalone");
this.isSubscriptionUnpaid = this.getResponseProperty("IsSubscriptionUnpaid"); this.isSubscriptionUnpaid = this.getResponseProperty("IsSubscriptionUnpaid");
this.hasSubscription = this.getResponseProperty("HasSubscription");
} }
} }