fix(bug): Only show account recovery promo if the user has Sync-able devices

This commit is contained in:
Vijay Budhram 2024-09-17 12:00:33 -04:00
Родитель 7f17f191ad
Коммит 71a35a0c06
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9778545895B2532B
3 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -68,4 +68,22 @@ describe('NotificationPromoBanner component', () => {
);
expect(key).toBe('true');
});
it('can set not visible', () => {
const notificationProps = {
headerImage: keyImage,
ctaText: 'Create',
headerValue: 'Dont lose your data if you forget your password',
headerDescription:
'Create an Account Recovery Key to restore your sync browsing data if you ever forget your password.',
route: '/settings/account_recovery',
dismissKey: 'account-recovery-dismissed',
metricsKey: 'create_recovery_key',
isVisible: false,
};
renderWithLocalizationProvider(
<NotificationPromoBanner {...notificationProps} />
);
expect(screen.queryByText('Create')).not.toBeInTheDocument();
});
});

Просмотреть файл

@ -92,7 +92,7 @@ const NotificationPromoBanner = ({
</div>
<Link
className="cta-neutral cta-base cta-base-p text-base tablet:text-sm tablet:self-center transition-standard -mt-1 mobileLandscape:mt-0"
className="cta-neutral cta-base cta-base-p text-base tablet:mr-8 tablet:text-sm tablet:self-center transition-standard -mt-1 mobileLandscape:mt-0"
to={`${route}${location.search}`}
data-glean-id={`account_banner_${metricsKey}_submit`}
>

Просмотреть файл

@ -55,6 +55,13 @@ export const PageSettings = (_: RouteComponentProps) => {
}
}, [attachedClients, subscriptions, productPromoGleanEventSent]);
// The estimated Sync devices is optionally returned by the auth-server,
// if it is not present, we default to 0.
let estimatedSyncDeviceCount = 0;
if (recoveryKey.estimatedSyncDeviceCount) {
estimatedSyncDeviceCount = recoveryKey.estimatedSyncDeviceCount;
}
const accountRecoveryNotificationProps = {
headerImage: keyImage,
ctaText: ftlMsgResolver.getMsg(
@ -72,7 +79,7 @@ export const PageSettings = (_: RouteComponentProps) => {
route: '/settings/account_recovery',
dismissKey: 'account-recovery-dismissed',
metricsKey: 'create_recovery_key',
isVisible: !recoveryKey.exists,
isVisible: estimatedSyncDeviceCount > 0 && !recoveryKey.exists,
};
// Scroll to effect