mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PM-8592] Deactivated state not showing (#9533)
* refactor vault state observables into a single variable to remove multiple subscriptions * add clarification comment * fix comment to be accurate
This commit is contained in:
@@ -11,7 +11,10 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
</popup-header>
|
</popup-header>
|
||||||
|
|
||||||
<div *ngIf="showEmptyState$ | async" class="tw-flex tw-flex-col tw-h-full tw-justify-center">
|
<div
|
||||||
|
*ngIf="vaultState === VaultStateEnum.Empty"
|
||||||
|
class="tw-flex tw-flex-col tw-h-full tw-justify-center"
|
||||||
|
>
|
||||||
<bit-no-items [icon]="vaultIcon">
|
<bit-no-items [icon]="vaultIcon">
|
||||||
<ng-container slot="title">{{ "yourVaultIsEmpty" | i18n }}</ng-container>
|
<ng-container slot="title">{{ "yourVaultIsEmpty" | i18n }}</ng-container>
|
||||||
<ng-container slot="description">{{ "autofillSuggestionsTip" | i18n }}</ng-container>
|
<ng-container slot="description">{{ "autofillSuggestionsTip" | i18n }}</ng-container>
|
||||||
@@ -21,13 +24,12 @@
|
|||||||
</bit-no-items>
|
</bit-no-items>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-container *ngIf="!(showEmptyState$ | async)">
|
<ng-container *ngIf="vaultState !== VaultStateEnum.Empty">
|
||||||
<app-vault-v2-search> </app-vault-v2-search>
|
<app-vault-v2-search> </app-vault-v2-search>
|
||||||
|
|
||||||
<app-vault-list-filters></app-vault-list-filters>
|
<app-vault-list-filters></app-vault-list-filters>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
*ngIf="(showNoResultsState$ | async) && !(showDeactivatedOrg$ | async)"
|
*ngIf="vaultState === VaultStateEnum.NoResults"
|
||||||
class="tw-flex tw-flex-col tw-justify-center tw-h-auto tw-pt-12"
|
class="tw-flex tw-flex-col tw-justify-center tw-h-auto tw-pt-12"
|
||||||
>
|
>
|
||||||
<bit-no-items [icon]="noResultsIcon">
|
<bit-no-items [icon]="noResultsIcon">
|
||||||
@@ -37,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
*ngIf="showDeactivatedOrg$ | async"
|
*ngIf="vaultState === VaultStateEnum.DeactivatedOrg"
|
||||||
class="tw-flex tw-flex-col tw-justify-center tw-h-auto tw-pt-12"
|
class="tw-flex tw-flex-col tw-justify-center tw-h-auto tw-pt-12"
|
||||||
>
|
>
|
||||||
<bit-no-items [icon]="deactivatedIcon">
|
<bit-no-items [icon]="deactivatedIcon">
|
||||||
@@ -46,7 +48,7 @@
|
|||||||
</bit-no-items>
|
</bit-no-items>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-container *ngIf="!(showNoResultsState$ | async) && !(showDeactivatedOrg$ | async)">
|
<ng-container *ngIf="vaultState === null">
|
||||||
<app-autofill-vault-list-items></app-autofill-vault-list-items>
|
<app-autofill-vault-list-items></app-autofill-vault-list-items>
|
||||||
<app-vault-list-items-container
|
<app-vault-list-items-container
|
||||||
[title]="'favorites' | i18n"
|
[title]="'favorites' | i18n"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||||
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { Router, RouterLink } from "@angular/router";
|
import { Router, RouterLink } from "@angular/router";
|
||||||
|
import { combineLatest } from "rxjs";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { ButtonModule, Icons, NoItemsModule } from "@bitwarden/components";
|
import { ButtonModule, Icons, NoItemsModule } from "@bitwarden/components";
|
||||||
@@ -14,6 +16,12 @@ import { AutofillVaultListItemsComponent, VaultListItemsContainerComponent } fro
|
|||||||
import { VaultListFiltersComponent } from "../vault-v2/vault-list-filters/vault-list-filters.component";
|
import { VaultListFiltersComponent } from "../vault-v2/vault-list-filters/vault-list-filters.component";
|
||||||
import { VaultV2SearchComponent } from "../vault-v2/vault-search/vault-v2-search.component";
|
import { VaultV2SearchComponent } from "../vault-v2/vault-search/vault-v2-search.component";
|
||||||
|
|
||||||
|
enum VaultState {
|
||||||
|
Empty,
|
||||||
|
NoResults,
|
||||||
|
DeactivatedOrg,
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-vault",
|
selector: "app-vault",
|
||||||
templateUrl: "vault-v2.component.html",
|
templateUrl: "vault-v2.component.html",
|
||||||
@@ -38,18 +46,42 @@ export class VaultV2Component implements OnInit, OnDestroy {
|
|||||||
protected favoriteCiphers$ = this.vaultPopupItemsService.favoriteCiphers$;
|
protected favoriteCiphers$ = this.vaultPopupItemsService.favoriteCiphers$;
|
||||||
protected remainingCiphers$ = this.vaultPopupItemsService.remainingCiphers$;
|
protected remainingCiphers$ = this.vaultPopupItemsService.remainingCiphers$;
|
||||||
|
|
||||||
protected showEmptyState$ = this.vaultPopupItemsService.emptyVault$;
|
/** Visual state of the vault */
|
||||||
protected showNoResultsState$ = this.vaultPopupItemsService.noFilteredResults$;
|
protected vaultState: VaultState | null = null;
|
||||||
protected showDeactivatedOrg$ = this.vaultPopupItemsService.showDeactivatedOrg$;
|
|
||||||
|
|
||||||
protected vaultIcon = Icons.Vault;
|
protected vaultIcon = Icons.Vault;
|
||||||
protected deactivatedIcon = Icons.DeactivatedOrg;
|
protected deactivatedIcon = Icons.DeactivatedOrg;
|
||||||
protected noResultsIcon = Icons.NoResults;
|
protected noResultsIcon = Icons.NoResults;
|
||||||
|
|
||||||
|
protected VaultStateEnum = VaultState;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private vaultPopupItemsService: VaultPopupItemsService,
|
private vaultPopupItemsService: VaultPopupItemsService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
) {}
|
) {
|
||||||
|
combineLatest([
|
||||||
|
this.vaultPopupItemsService.emptyVault$,
|
||||||
|
this.vaultPopupItemsService.noFilteredResults$,
|
||||||
|
this.vaultPopupItemsService.showDeactivatedOrg$,
|
||||||
|
])
|
||||||
|
.pipe(takeUntilDestroyed())
|
||||||
|
.subscribe(([emptyVault, noResults, deactivatedOrg]) => {
|
||||||
|
switch (true) {
|
||||||
|
case emptyVault:
|
||||||
|
this.vaultState = VaultState.Empty;
|
||||||
|
break;
|
||||||
|
case deactivatedOrg:
|
||||||
|
// The deactivated org state takes precedence over the no results state
|
||||||
|
this.vaultState = VaultState.DeactivatedOrg;
|
||||||
|
break;
|
||||||
|
case noResults:
|
||||||
|
this.vaultState = VaultState.NoResults;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.vaultState = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
ngOnInit(): void {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user