1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-14 10:26:19 +01: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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 8 deletions

View File

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

View File

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

View File

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