mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 05:13:29 +00:00
[PM-21663] nudge service name refactor (#14789)
* update names of vault nudge service and their corresponding files, convert components using showNudge$ to instead target spotlight and badges directly with new observables. Core logic for dismiss remains the same
This commit is contained in:
@@ -4,14 +4,14 @@ import { CommonModule } from "@angular/common";
|
||||
import { Component, DestroyRef, OnInit } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import {
|
||||
FormBuilder,
|
||||
FormControl,
|
||||
FormGroup,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
FormBuilder,
|
||||
FormGroup,
|
||||
FormControl,
|
||||
} from "@angular/forms";
|
||||
import { RouterModule } from "@angular/router";
|
||||
import { Observable, filter, firstValueFrom, map, switchMap } from "rxjs";
|
||||
import { filter, firstValueFrom, Observable, switchMap } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { Account, AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
@@ -55,7 +55,7 @@ import {
|
||||
SelectModule,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
import { SpotlightComponent, VaultNudgesService, VaultNudgeType } from "@bitwarden/vault";
|
||||
import { NudgesService, NudgeType, SpotlightComponent } from "@bitwarden/vault";
|
||||
|
||||
import { AutofillBrowserSettingsService } from "../../../autofill/services/autofill-browser-settings.service";
|
||||
import { BrowserApi } from "../../../platform/browser/browser-api";
|
||||
@@ -108,9 +108,7 @@ export class AutofillComponent implements OnInit {
|
||||
protected showSpotlightNudge$: Observable<boolean> = this.accountService.activeAccount$.pipe(
|
||||
filter((account): account is Account => account !== null),
|
||||
switchMap((account) =>
|
||||
this.vaultNudgesService
|
||||
.showNudge$(VaultNudgeType.AutofillNudge, account.id)
|
||||
.pipe(map((nudgeStatus) => !nudgeStatus.hasSpotlightDismissed)),
|
||||
this.nudgesService.showNudgeSpotlight$(NudgeType.AutofillNudge, account.id),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -155,7 +153,7 @@ export class AutofillComponent implements OnInit {
|
||||
private configService: ConfigService,
|
||||
private formBuilder: FormBuilder,
|
||||
private destroyRef: DestroyRef,
|
||||
private vaultNudgesService: VaultNudgesService,
|
||||
private nudgesService: NudgesService,
|
||||
private accountService: AccountService,
|
||||
private autofillBrowserSettingsService: AutofillBrowserSettingsService,
|
||||
) {
|
||||
@@ -343,8 +341,8 @@ export class AutofillComponent implements OnInit {
|
||||
}
|
||||
|
||||
async dismissSpotlight() {
|
||||
await this.vaultNudgesService.dismissNudge(
|
||||
VaultNudgeType.AutofillNudge,
|
||||
await this.nudgesService.dismissNudge(
|
||||
NudgeType.AutofillNudge,
|
||||
await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { Icons } from "@bitwarden/components";
|
||||
import { VaultNudgesService } from "@bitwarden/vault";
|
||||
import { NudgesService } from "@bitwarden/vault";
|
||||
|
||||
import { NavButton } from "../platform/popup/layout/popup-tab-navigation.component";
|
||||
|
||||
@@ -18,7 +18,7 @@ import { NavButton } from "../platform/popup/layout/popup-tab-navigation.compone
|
||||
export class TabsV2Component {
|
||||
private hasActiveBadges$ = this.accountService.activeAccount$
|
||||
.pipe(getUserId)
|
||||
.pipe(switchMap((userId) => this.vaultNudgesService.hasActiveBadges$(userId)));
|
||||
.pipe(switchMap((userId) => this.nudgesService.hasActiveBadges$(userId)));
|
||||
protected navButtons$: Observable<NavButton[]> = combineLatest([
|
||||
this.configService.getFeatureFlag$(FeatureFlag.PM8851_BrowserOnboardingNudge),
|
||||
this.hasActiveBadges$,
|
||||
@@ -54,7 +54,7 @@ export class TabsV2Component {
|
||||
}),
|
||||
);
|
||||
constructor(
|
||||
private vaultNudgesService: VaultNudgesService,
|
||||
private nudgesService: NudgesService,
|
||||
private accountService: AccountService,
|
||||
private readonly configService: ConfigService,
|
||||
) {}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<a
|
||||
bit-item-content
|
||||
routerLink="/vault-settings"
|
||||
(click)="dismissBadge(VaultNudgeType.EmptyVaultNudge)"
|
||||
(click)="dismissBadge(NudgeType.EmptyVaultNudge)"
|
||||
>
|
||||
<i slot="start" class="bwi bwi-vault" aria-hidden="true"></i>
|
||||
<div class="tw-flex tw-items-center tw-justify-center">
|
||||
@@ -51,7 +51,7 @@
|
||||
Will make this dynamic when more nudges are added
|
||||
-->
|
||||
<span
|
||||
*ngIf="!(showVaultBadge$ | async)?.hasBadgeDismissed"
|
||||
*ngIf="showVaultBadge$ | async"
|
||||
bitBadge
|
||||
variant="notification"
|
||||
[attr.aria-label]="'nudgeBadgeAria' | i18n"
|
||||
@@ -82,7 +82,7 @@
|
||||
<div class="tw-flex tw-items-center tw-justify-center">
|
||||
<p class="tw-pr-2">{{ "downloadBitwardenOnAllDevices" | i18n }}</p>
|
||||
<span
|
||||
*ngIf="(downloadBitwardenNudgeStatus$ | async)?.hasBadgeDismissed === false"
|
||||
*ngIf="downloadBitwardenNudgeStatus$ | async"
|
||||
bitBadge
|
||||
variant="notification"
|
||||
[attr.aria-label]="'nudgeBadgeAria' | i18n"
|
||||
|
||||
@@ -17,7 +17,7 @@ import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
import { BadgeComponent, ItemModule } from "@bitwarden/components";
|
||||
import { NudgeStatus, VaultNudgesService, VaultNudgeType } from "@bitwarden/vault";
|
||||
import { NudgesService, NudgeType } from "@bitwarden/vault";
|
||||
|
||||
import { CurrentAccountComponent } from "../../../auth/popup/account-switching/current-account.component";
|
||||
import { AutofillBrowserSettingsService } from "../../../autofill/services/autofill-browser-settings.service";
|
||||
@@ -42,7 +42,7 @@ import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.co
|
||||
],
|
||||
})
|
||||
export class SettingsV2Component implements OnInit {
|
||||
VaultNudgeType = VaultNudgeType;
|
||||
NudgeType = NudgeType;
|
||||
activeUserId: UserId | null = null;
|
||||
protected isBrowserAutofillSettingOverridden = false;
|
||||
|
||||
@@ -51,15 +51,15 @@ export class SettingsV2Component implements OnInit {
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
);
|
||||
|
||||
downloadBitwardenNudgeStatus$: Observable<NudgeStatus> = this.authenticatedAccount$.pipe(
|
||||
downloadBitwardenNudgeStatus$: Observable<boolean> = this.authenticatedAccount$.pipe(
|
||||
switchMap((account) =>
|
||||
this.vaultNudgesService.showNudge$(VaultNudgeType.DownloadBitwarden, account.id),
|
||||
this.nudgesService.showNudgeBadge$(NudgeType.DownloadBitwarden, account.id),
|
||||
),
|
||||
);
|
||||
|
||||
showVaultBadge$: Observable<NudgeStatus> = this.authenticatedAccount$.pipe(
|
||||
showVaultBadge$: Observable<boolean> = this.authenticatedAccount$.pipe(
|
||||
switchMap((account) =>
|
||||
this.vaultNudgesService.showNudge$(VaultNudgeType.EmptyVaultNudge, account.id),
|
||||
this.nudgesService.showNudgeBadge$(NudgeType.EmptyVaultNudge, account.id),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -68,9 +68,9 @@ export class SettingsV2Component implements OnInit {
|
||||
this.authenticatedAccount$,
|
||||
]).pipe(
|
||||
switchMap(([defaultBrowserAutofillDisabled, account]) =>
|
||||
this.vaultNudgesService.showNudge$(VaultNudgeType.AutofillNudge, account.id).pipe(
|
||||
map((nudgeStatus) => {
|
||||
return !defaultBrowserAutofillDisabled && nudgeStatus.hasBadgeDismissed === false;
|
||||
this.nudgesService.showNudgeBadge$(NudgeType.AutofillNudge, account.id).pipe(
|
||||
map((badgeStatus) => {
|
||||
return !defaultBrowserAutofillDisabled && badgeStatus;
|
||||
}),
|
||||
),
|
||||
),
|
||||
@@ -81,7 +81,7 @@ export class SettingsV2Component implements OnInit {
|
||||
);
|
||||
|
||||
constructor(
|
||||
private readonly vaultNudgesService: VaultNudgesService,
|
||||
private readonly nudgesService: NudgesService,
|
||||
private readonly accountService: AccountService,
|
||||
private readonly autofillBrowserSettingsService: AutofillBrowserSettingsService,
|
||||
private readonly configService: ConfigService,
|
||||
@@ -94,10 +94,10 @@ export class SettingsV2Component implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
async dismissBadge(type: VaultNudgeType) {
|
||||
if (!(await firstValueFrom(this.showVaultBadge$)).hasBadgeDismissed) {
|
||||
async dismissBadge(type: NudgeType) {
|
||||
if (await firstValueFrom(this.showVaultBadge$)) {
|
||||
const account = await firstValueFrom(this.authenticatedAccount$);
|
||||
await this.vaultNudgesService.dismissNudge(type, account.id as UserId, true);
|
||||
await this.nudgesService.dismissNudge(type, account.id as UserId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
[subtitle]="'emptyVaultNudgeBody' | i18n"
|
||||
[buttonText]="'emptyVaultNudgeButton' | i18n"
|
||||
(onButtonClick)="navigateToImport()"
|
||||
(onDismiss)="dismissVaultNudgeSpotlight(VaultNudgeType.EmptyVaultNudge)"
|
||||
(onDismiss)="dismissVaultNudgeSpotlight(NudgeType.EmptyVaultNudge)"
|
||||
>
|
||||
</bit-spotlight>
|
||||
</ng-container>
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="tw-mb-4" *ngIf="showHasItemsVaultSpotlight$ | async">
|
||||
<bit-spotlight
|
||||
[title]="'hasItemsVaultNudgeTitle' | i18n"
|
||||
(onDismiss)="dismissVaultNudgeSpotlight(VaultNudgeType.HasVaultItems)"
|
||||
(onDismiss)="dismissVaultNudgeSpotlight(NudgeType.HasVaultItems)"
|
||||
>
|
||||
<ul class="tw-pl-4 tw-text-main" bitTypography="body2">
|
||||
<li>{{ "hasItemsVaultNudgeBodyOne" | i18n }}</li>
|
||||
|
||||
@@ -32,10 +32,10 @@ import {
|
||||
} from "@bitwarden/components";
|
||||
import {
|
||||
DecryptionFailureDialogComponent,
|
||||
NudgesService,
|
||||
NudgeType,
|
||||
SpotlightComponent,
|
||||
VaultIcons,
|
||||
VaultNudgesService,
|
||||
VaultNudgeType,
|
||||
} from "@bitwarden/vault";
|
||||
|
||||
import { CurrentAccountComponent } from "../../../../auth/popup/account-switching/current-account.component";
|
||||
@@ -96,18 +96,16 @@ enum VaultState {
|
||||
export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
@ViewChild(CdkVirtualScrollableElement) virtualScrollElement?: CdkVirtualScrollableElement;
|
||||
|
||||
VaultNudgeType = VaultNudgeType;
|
||||
NudgeType = NudgeType;
|
||||
cipherType = CipherType;
|
||||
private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId);
|
||||
showEmptyVaultSpotlight$: Observable<boolean> = this.activeUserId$.pipe(
|
||||
switchMap((userId) =>
|
||||
this.vaultNudgesService.showNudge$(VaultNudgeType.EmptyVaultNudge, userId),
|
||||
this.nudgesService.showNudgeSpotlight$(NudgeType.EmptyVaultNudge, userId),
|
||||
),
|
||||
map((nudgeStatus) => !nudgeStatus.hasSpotlightDismissed),
|
||||
);
|
||||
showHasItemsVaultSpotlight$: Observable<boolean> = this.activeUserId$.pipe(
|
||||
switchMap((userId) => this.vaultNudgesService.showNudge$(VaultNudgeType.HasVaultItems, userId)),
|
||||
map((nudgeStatus) => !nudgeStatus.hasSpotlightDismissed),
|
||||
switchMap((userId) => this.nudgesService.showNudgeSpotlight$(NudgeType.HasVaultItems, userId)),
|
||||
);
|
||||
|
||||
activeUserId: UserId | null = null;
|
||||
@@ -159,7 +157,7 @@ export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
private dialogService: DialogService,
|
||||
private vaultCopyButtonsService: VaultPopupCopyButtonsService,
|
||||
private introCarouselService: IntroCarouselService,
|
||||
private vaultNudgesService: VaultNudgesService,
|
||||
private nudgesService: NudgesService,
|
||||
private router: Router,
|
||||
private i18nService: I18nService,
|
||||
) {
|
||||
@@ -229,8 +227,8 @@ export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
async dismissVaultNudgeSpotlight(type: VaultNudgeType) {
|
||||
await this.vaultNudgesService.dismissNudge(type, this.activeUserId as UserId);
|
||||
async dismissVaultNudgeSpotlight(type: NudgeType) {
|
||||
await this.nudgesService.dismissNudge(type, this.activeUserId as UserId);
|
||||
}
|
||||
|
||||
protected readonly FeatureFlag = FeatureFlag;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { CardComponent, LinkModule, TypographyModule } from "@bitwarden/components";
|
||||
import { VaultNudgesService, VaultNudgeType } from "@bitwarden/vault";
|
||||
import { NudgesService, NudgeType } from "@bitwarden/vault";
|
||||
|
||||
import { CurrentAccountComponent } from "../../../auth/popup/account-switching/current-account.component";
|
||||
import { PopOutComponent } from "../../../platform/popup/components/pop-out.component";
|
||||
@@ -32,12 +32,12 @@ import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.co
|
||||
})
|
||||
export class DownloadBitwardenComponent implements OnInit {
|
||||
constructor(
|
||||
private vaultNudgeService: VaultNudgesService,
|
||||
private nudgesService: NudgesService,
|
||||
private accountService: AccountService,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
|
||||
await this.vaultNudgeService.dismissNudge(VaultNudgeType.DownloadBitwarden, userId);
|
||||
await this.nudgesService.dismissNudge(NudgeType.DownloadBitwarden, userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user