Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 85f9230

Browse files
author
Kerry
authored
Device manager - hide unverified security recommendation when only current session is unverified (PSG-639) (#9228)
* scroll to filtered list from security recommendations * test sessionmanager scroll to * stable snapshot * fix strict errors * prtidy * dont show security rec section when only curent session is unverified
1 parent 219f4fa commit 85f9230

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/components/views/settings/devices/SecurityRecommendations.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,26 @@ import {
2929

3030
interface Props {
3131
devices: DevicesDictionary;
32+
currentDeviceId: DeviceWithVerification['device_id'];
3233
goToFilteredList: (filter: DeviceSecurityVariation) => void;
3334
}
3435

3536
const SecurityRecommendations: React.FC<Props> = ({
3637
devices,
38+
currentDeviceId,
3739
goToFilteredList,
3840
}) => {
3941
const devicesArray = Object.values<DeviceWithVerification>(devices);
4042

4143
const unverifiedDevicesCount = filterDevicesBySecurityRecommendation(
4244
devicesArray,
4345
[DeviceSecurityVariation.Unverified],
44-
).length;
46+
)
47+
// filter out the current device
48+
// as unverfied warning and actions
49+
// will be shown in current session section
50+
.filter((device) => device.device_id !== currentDeviceId)
51+
.length;
4552
const inactiveDevicesCount = filterDevicesBySecurityRecommendation(
4653
devicesArray,
4754
[DeviceSecurityVariation.Inactive],

src/components/views/settings/tabs/user/SessionManagerTab.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ const SessionManagerTab: React.FC = () => {
6262
}, [scrollIntoViewTimeoutRef]);
6363

6464
return <SettingsTab heading={_t('Sessions')}>
65-
<SecurityRecommendations devices={devices} goToFilteredList={onGoToFilteredList} />
65+
<SecurityRecommendations
66+
devices={devices}
67+
goToFilteredList={onGoToFilteredList}
68+
currentDeviceId={currentDeviceId}
69+
/>
6670
<CurrentDeviceSection
6771
device={currentDevice}
6872
isLoading={isLoading}

test/components/views/settings/devices/SecurityRecommendations-test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('<SecurityRecommendations />', () => {
3434
const defaultProps = {
3535
devices: {},
3636
goToFilteredList: jest.fn(),
37+
currentDeviceId: 'abc123',
3738
};
3839
const getComponent = (props = {}) =>
3940
(<SecurityRecommendations {...defaultProps} {...props} />);
@@ -53,6 +54,16 @@ describe('<SecurityRecommendations />', () => {
5354
expect(container).toMatchSnapshot();
5455
});
5556

57+
it('does not render unverified devices section when only the current device is unverified', () => {
58+
const devices = {
59+
[unverifiedNoMetadata.device_id]: unverifiedNoMetadata,
60+
[verifiedNoMetadata.device_id]: verifiedNoMetadata,
61+
};
62+
const { container } = render(getComponent({ devices, currentDeviceId: unverifiedNoMetadata.device_id }));
63+
// nothing to render
64+
expect(container.firstChild).toBeFalsy();
65+
});
66+
5667
it('renders inactive devices section when user has inactive devices', () => {
5768
const devices = {
5869
[verifiedNoMetadata.device_id]: verifiedNoMetadata,

0 commit comments

Comments
 (0)