mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-14 01:01:31 +01:00
[PM-15520] Move organizationPaymentStatus$ out of page setup flow and tweak it to avoid hanging when user is not an owner (#12224)
This commit is contained in:
parent
694f2c7da2
commit
2e53a645c9
@ -1,4 +1,6 @@
|
|||||||
<app-vault-banners [organizationsPaymentStatus]="organizationsPaymentStatus"></app-vault-banners>
|
<app-vault-banners
|
||||||
|
[organizationsPaymentStatus]="organizationsPaymentStatus$ | async"
|
||||||
|
></app-vault-banners>
|
||||||
|
|
||||||
<app-vault-header
|
<app-vault-header
|
||||||
[filter]="filter"
|
[filter]="filter"
|
||||||
|
@ -181,7 +181,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
protected canCreateCollections = false;
|
protected canCreateCollections = false;
|
||||||
protected currentSearchText$: Observable<string>;
|
protected currentSearchText$: Observable<string>;
|
||||||
private activeUserId: UserId;
|
private activeUserId: UserId;
|
||||||
protected organizationsPaymentStatus: FreeTrial[] = [];
|
|
||||||
private searchText$ = new Subject<string>();
|
private searchText$ = new Subject<string>();
|
||||||
private refresh$ = new BehaviorSubject<void>(null);
|
private refresh$ = new BehaviorSubject<void>(null);
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
@ -209,6 +208,37 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected organizationsPaymentStatus$: Observable<FreeTrial[]> = combineLatest([
|
||||||
|
this.organizationService.organizations$.pipe(
|
||||||
|
map((organizations) => organizations?.filter((org) => org.isOwner) ?? []),
|
||||||
|
),
|
||||||
|
this.hasSubscription$,
|
||||||
|
]).pipe(
|
||||||
|
switchMap(([ownerOrgs, hasSubscription]) => {
|
||||||
|
if (!ownerOrgs || ownerOrgs.length === 0 || !hasSubscription) {
|
||||||
|
return of([]);
|
||||||
|
}
|
||||||
|
return combineLatest(
|
||||||
|
ownerOrgs.map((org) =>
|
||||||
|
combineLatest([
|
||||||
|
this.organizationApiService.getSubscription(org.id),
|
||||||
|
this.organizationBillingService.getPaymentSource(org.id),
|
||||||
|
]).pipe(
|
||||||
|
map(([subscription, paymentSource]) => {
|
||||||
|
return this.trialFlowService.checkForOrgsWithUpcomingPaymentIssues(
|
||||||
|
org,
|
||||||
|
subscription,
|
||||||
|
paymentSource,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
map((results) => results.filter((result) => result.shownBanner)),
|
||||||
|
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -425,36 +455,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe();
|
this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe();
|
||||||
|
|
||||||
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 && hasSubscription)
|
|
||||||
.map((org) =>
|
|
||||||
combineLatest([
|
|
||||||
this.organizationApiService.getSubscription(org.id),
|
|
||||||
this.organizationBillingService.getPaymentSource(org.id),
|
|
||||||
]).pipe(
|
|
||||||
map(([subscription, paymentSource]) => {
|
|
||||||
return this.trialFlowService.checkForOrgsWithUpcomingPaymentIssues(
|
|
||||||
org,
|
|
||||||
subscription,
|
|
||||||
paymentSource,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
map((results) => results.filter((result) => result.shownBanner)),
|
|
||||||
);
|
|
||||||
|
|
||||||
firstSetup$
|
firstSetup$
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(() => this.refresh$),
|
switchMap(() => this.refresh$),
|
||||||
@ -468,7 +468,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
ciphers$,
|
ciphers$,
|
||||||
collections$,
|
collections$,
|
||||||
selectedCollection$,
|
selectedCollection$,
|
||||||
organizationsPaymentStatus$,
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
takeUntil(this.destroy$),
|
takeUntil(this.destroy$),
|
||||||
@ -482,7 +481,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
ciphers,
|
ciphers,
|
||||||
collections,
|
collections,
|
||||||
selectedCollection,
|
selectedCollection,
|
||||||
organizationsPaymentStatus,
|
|
||||||
]) => {
|
]) => {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.canAccessPremium = canAccessPremium;
|
this.canAccessPremium = canAccessPremium;
|
||||||
@ -498,7 +496,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.showBulkMove = filter.type !== "trash";
|
this.showBulkMove = filter.type !== "trash";
|
||||||
this.isEmpty = collections?.length === 0 && ciphers?.length === 0;
|
this.isEmpty = collections?.length === 0 && ciphers?.length === 0;
|
||||||
this.organizationsPaymentStatus = organizationsPaymentStatus;
|
|
||||||
this.performingInitialLoad = false;
|
this.performingInitialLoad = false;
|
||||||
this.refreshing = false;
|
this.refreshing = false;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user