mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-23722] Add missing account security badge (#15603)
* add account security nudge logic to settings v2 and badge check in nudges service
This commit is contained in:
@@ -10,7 +10,16 @@
|
|||||||
<bit-item>
|
<bit-item>
|
||||||
<a bit-item-content routerLink="/account-security">
|
<a bit-item-content routerLink="/account-security">
|
||||||
<i slot="start" class="bwi bwi-lock" aria-hidden="true"></i>
|
<i slot="start" class="bwi bwi-lock" aria-hidden="true"></i>
|
||||||
{{ "accountSecurity" | i18n }}
|
<div class="tw-flex tw-items-center tw-justify-center">
|
||||||
|
<p class="tw-pr-2">{{ "accountSecurity" | i18n }}</p>
|
||||||
|
<span
|
||||||
|
*ngIf="showAcctSecurityNudge$ | async"
|
||||||
|
bitBadge
|
||||||
|
variant="notification"
|
||||||
|
[attr.aria-label]="'nudgeBadgeAria' | i18n"
|
||||||
|
>1</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
<i slot="end" class="bwi bwi-angle-right" aria-hidden="true"></i>
|
<i slot="end" class="bwi bwi-angle-right" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
</bit-item>
|
</bit-item>
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ export class SettingsV2Component implements OnInit {
|
|||||||
shareReplay({ bufferSize: 1, refCount: true }),
|
shareReplay({ bufferSize: 1, refCount: true }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected showAcctSecurityNudge$: Observable<boolean> = this.authenticatedAccount$.pipe(
|
||||||
|
switchMap((account) =>
|
||||||
|
this.nudgesService.showNudgeBadge$(NudgeType.AccountSecurity, account.id),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
showDownloadBitwardenNudge$: Observable<boolean> = this.authenticatedAccount$.pipe(
|
showDownloadBitwardenNudge$: Observable<boolean> = this.authenticatedAccount$.pipe(
|
||||||
switchMap((account) =>
|
switchMap((account) =>
|
||||||
this.nudgesService.showNudgeBadge$(NudgeType.DownloadBitwarden, account.id),
|
this.nudgesService.showNudgeBadge$(NudgeType.DownloadBitwarden, account.id),
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { PinServiceAbstraction } from "@bitwarden/auth/common";
|
|||||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/key-management/vault-timeout";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { BiometricStateService } from "@bitwarden/key-management";
|
import { BiometricStateService } from "@bitwarden/key-management";
|
||||||
@@ -24,7 +23,6 @@ export class AccountSecurityNudgeService extends DefaultSingleNudgeService {
|
|||||||
private vaultProfileService = inject(VaultProfileService);
|
private vaultProfileService = inject(VaultProfileService);
|
||||||
private logService = inject(LogService);
|
private logService = inject(LogService);
|
||||||
private pinService = inject(PinServiceAbstraction);
|
private pinService = inject(PinServiceAbstraction);
|
||||||
private vaultTimeoutSettingsService = inject(VaultTimeoutSettingsService);
|
|
||||||
private biometricStateService = inject(BiometricStateService);
|
private biometricStateService = inject(BiometricStateService);
|
||||||
private policyService = inject(PolicyService);
|
private policyService = inject(PolicyService);
|
||||||
private organizationService = inject(OrganizationService);
|
private organizationService = inject(OrganizationService);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
HasItemsNudgeService,
|
HasItemsNudgeService,
|
||||||
EmptyVaultNudgeService,
|
EmptyVaultNudgeService,
|
||||||
NewAccountNudgeService,
|
NewAccountNudgeService,
|
||||||
|
AccountSecurityNudgeService,
|
||||||
VaultSettingsImportNudgeService,
|
VaultSettingsImportNudgeService,
|
||||||
} from "./custom-nudges-services";
|
} from "./custom-nudges-services";
|
||||||
import { DefaultSingleNudgeService } from "./default-single-nudge.service";
|
import { DefaultSingleNudgeService } from "./default-single-nudge.service";
|
||||||
@@ -37,7 +38,11 @@ describe("Vault Nudges Service", () => {
|
|||||||
getFeatureFlag: jest.fn().mockReturnValue(true),
|
getFeatureFlag: jest.fn().mockReturnValue(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
const nudgeServices = [EmptyVaultNudgeService, NewAccountNudgeService];
|
const nudgeServices = [
|
||||||
|
EmptyVaultNudgeService,
|
||||||
|
NewAccountNudgeService,
|
||||||
|
AccountSecurityNudgeService,
|
||||||
|
];
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
fakeStateProvider = new FakeStateProvider(mockAccountServiceWith("user-id" as UserId));
|
fakeStateProvider = new FakeStateProvider(mockAccountServiceWith("user-id" as UserId));
|
||||||
@@ -68,6 +73,10 @@ describe("Vault Nudges Service", () => {
|
|||||||
provide: EmptyVaultNudgeService,
|
provide: EmptyVaultNudgeService,
|
||||||
useValue: mock<EmptyVaultNudgeService>(),
|
useValue: mock<EmptyVaultNudgeService>(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: AccountSecurityNudgeService,
|
||||||
|
useValue: mock<AccountSecurityNudgeService>(),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: VaultSettingsImportNudgeService,
|
provide: VaultSettingsImportNudgeService,
|
||||||
useValue: mock<VaultSettingsImportNudgeService>(),
|
useValue: mock<VaultSettingsImportNudgeService>(),
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ export class NudgesService {
|
|||||||
hasActiveBadges$(userId: UserId): Observable<boolean> {
|
hasActiveBadges$(userId: UserId): Observable<boolean> {
|
||||||
// Add more nudge types here if they have the settings badge feature
|
// Add more nudge types here if they have the settings badge feature
|
||||||
const nudgeTypes = [
|
const nudgeTypes = [
|
||||||
|
NudgeType.AccountSecurity,
|
||||||
NudgeType.EmptyVaultNudge,
|
NudgeType.EmptyVaultNudge,
|
||||||
NudgeType.DownloadBitwarden,
|
NudgeType.DownloadBitwarden,
|
||||||
NudgeType.AutofillNudge,
|
NudgeType.AutofillNudge,
|
||||||
|
|||||||
Reference in New Issue
Block a user