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

Commit caac059

Browse files
author
Kerry
authored
Device manager - add tooltip to device details toggle (#9594)
* add hide/show tooltip to dm details toggle * use named export, update tests
1 parent acdcda7 commit caac059

11 files changed

+29
-23
lines changed

cypress/e2e/settings/device-management.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe("Device manager", () => {
8787
const sessionName = `Alice's device`;
8888
// open the first session
8989
cy.get('.mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem').first().within(() => {
90-
cy.get('[aria-label="Toggle device details"]').click();
90+
cy.get('[aria-label="Show details"]').click();
9191

9292
cy.contains('Session details').should('exist');
9393

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Spinner from '../../elements/Spinner';
2222
import SettingsSubsection from '../shared/SettingsSubsection';
2323
import { SettingsSubsectionHeading } from '../shared/SettingsSubsectionHeading';
2424
import DeviceDetails from './DeviceDetails';
25-
import DeviceExpandDetailsButton from './DeviceExpandDetailsButton';
25+
import { DeviceExpandDetailsButton } from './DeviceExpandDetailsButton';
2626
import DeviceTile from './DeviceTile';
2727
import { DeviceVerificationStatusCard } from './DeviceVerificationStatusCard';
2828
import { ExtendedDevice } from './types';

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ import React from 'react';
1919

2020
import { Icon as CaretIcon } from '../../../../../res/img/feather-customised/dropdown-arrow.svg';
2121
import { _t } from '../../../../languageHandler';
22-
import AccessibleButton from '../../elements/AccessibleButton';
22+
import AccessibleTooltipButton from '../../elements/AccessibleTooltipButton';
2323

24-
interface Props {
24+
interface Props extends React.ComponentProps<typeof AccessibleTooltipButton> {
2525
isExpanded: boolean;
2626
onClick: () => void;
2727
}
2828

29-
const DeviceExpandDetailsButton: React.FC<Props> = ({ isExpanded, onClick, ...rest }) => {
30-
return <AccessibleButton
29+
export const DeviceExpandDetailsButton: React.FC<Props> = ({ isExpanded, onClick, ...rest }) => {
30+
const label = isExpanded ? _t('Hide details') : _t('Show details');
31+
return <AccessibleTooltipButton
3132
{...rest}
32-
aria-label={_t('Toggle device details')}
33+
aria-label={label}
34+
title={label}
3335
kind='icon'
3436
className={classNames('mx_DeviceExpandDetailsButton', {
3537
mx_DeviceExpandDetailsButton_expanded: isExpanded,
3638
})}
3739
onClick={onClick}
3840
>
3941
<CaretIcon className='mx_DeviceExpandDetailsButton_icon' />
40-
</AccessibleButton>;
42+
</AccessibleTooltipButton>;
4143
};
42-
43-
export default DeviceExpandDetailsButton;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { _t } from '../../../../languageHandler';
2323
import AccessibleButton from '../../elements/AccessibleButton';
2424
import { FilterDropdown, FilterDropdownOption } from '../../elements/FilterDropdown';
2525
import DeviceDetails from './DeviceDetails';
26-
import DeviceExpandDetailsButton from './DeviceExpandDetailsButton';
26+
import { DeviceExpandDetailsButton } from './DeviceExpandDetailsButton';
2727
import DeviceSecurityCard from './DeviceSecurityCard';
2828
import {
2929
filterDevicesBySecurityRecommendation,

src/i18n/strings/en_EN.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,8 @@
17781778
"Push notifications": "Push notifications",
17791779
"Receive push notifications on this session.": "Receive push notifications on this session.",
17801780
"Sign out of this session": "Sign out of this session",
1781-
"Toggle device details": "Toggle device details",
1781+
"Hide details": "Hide details",
1782+
"Show details": "Show details",
17821783
"Verified sessions": "Verified sessions",
17831784
"Verified sessions are anywhere you are using this account after entering your passphrase or confirming your identity with another verified session.": "Verified sessions are anywhere you are using this account after entering your passphrase or confirming your identity with another verified session.",
17841785
"This means that you have all the keys needed to unlock your encrypted messages and confirm to other users that you trust this session.": "This means that you have all the keys needed to unlock your encrypted messages and confirm to other users that you trust this session.",

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ limitations under the License.
1717
import React from 'react';
1818
import { fireEvent, render } from '@testing-library/react';
1919

20-
import DeviceExpandDetailsButton from '../../../../../src/components/views/settings/devices/DeviceExpandDetailsButton';
20+
import {
21+
DeviceExpandDetailsButton,
22+
} from '../../../../../src/components/views/settings/devices/DeviceExpandDetailsButton';
2123

2224
describe('<DeviceExpandDetailsButton />', () => {
2325
const defaultProps = {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe('<FilteredDeviceList />', () => {
221221

222222
act(() => {
223223
const tile = getByTestId(`device-tile-${hundredDaysOld.device_id}`);
224-
const toggle = tile.querySelector('[aria-label="Toggle device details"]');
224+
const toggle = tile.querySelector('[aria-label="Show details"]');
225225
fireEvent.click(toggle as Element);
226226
});
227227

test/components/views/settings/devices/__snapshots__/CurrentDeviceSection-test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
237237
class="mx_DeviceTile_actions"
238238
>
239239
<div
240-
aria-label="Toggle device details"
240+
aria-label="Show details"
241241
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
242242
data-testid="current-session-toggle-details"
243243
role="button"
@@ -380,7 +380,7 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
380380
class="mx_DeviceTile_actions"
381381
>
382382
<div
383-
aria-label="Toggle device details"
383+
aria-label="Show details"
384384
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
385385
data-testid="current-session-toggle-details"
386386
role="button"

test/components/views/settings/devices/__snapshots__/DeviceExpandDetailsButton-test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`<DeviceExpandDetailsButton /> renders when expanded 1`] = `
44
{
55
"container": <div>
66
<div
7-
aria-label="Toggle device details"
7+
aria-label="Hide details"
88
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_DeviceExpandDetailsButton_expanded mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
99
role="button"
1010
tabindex="0"
@@ -21,7 +21,7 @@ exports[`<DeviceExpandDetailsButton /> renders when not expanded 1`] = `
2121
{
2222
"container": <div>
2323
<div
24-
aria-label="Toggle device details"
24+
aria-label="Show details"
2525
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
2626
role="button"
2727
tabindex="0"

test/components/views/settings/tabs/user/SessionManagerTab-test.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ describe('<SessionManagerTab />', () => {
108108
const toggleDeviceDetails = (
109109
getByTestId: ReturnType<typeof render>['getByTestId'],
110110
deviceId: ExtendedDevice['device_id'],
111+
isOpen?: boolean,
111112
): void => {
112113
// open device detail
113114
const tile = getByTestId(`device-tile-${deviceId}`);
114-
const toggle = tile.querySelector('[aria-label="Toggle device details"]') as Element;
115+
const label = isOpen ? 'Hide details' : 'Show details';
116+
const toggle = tile.querySelector(`[aria-label="${label}"]`) as Element;
115117
fireEvent.click(toggle);
116118
};
117119

@@ -449,7 +451,8 @@ describe('<SessionManagerTab />', () => {
449451
expect(getByTestId(`device-detail-${alicesOlderMobileDevice.device_id}`)).toBeTruthy();
450452
expect(getByTestId(`device-detail-${alicesMobileDevice.device_id}`)).toBeTruthy();
451453

452-
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
454+
// toggle closed
455+
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id, true);
453456

454457
// alicesMobileDevice was toggled off
455458
expect(queryByTestId(`device-detail-${alicesMobileDevice.device_id}`)).toBeFalsy();

test/components/views/settings/tabs/user/__snapshots__/SessionManagerTab-test.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ exports[`<SessionManagerTab /> current session section renders current session s
9494
class="mx_DeviceTile_actions"
9595
>
9696
<div
97-
aria-label="Toggle device details"
97+
aria-label="Show details"
9898
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
9999
data-testid="current-session-toggle-details"
100100
role="button"
@@ -223,7 +223,7 @@ exports[`<SessionManagerTab /> current session section renders current session s
223223
class="mx_DeviceTile_actions"
224224
>
225225
<div
226-
aria-label="Toggle device details"
226+
aria-label="Show details"
227227
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
228228
data-testid="current-session-toggle-details"
229229
role="button"
@@ -397,7 +397,7 @@ exports[`<SessionManagerTab /> sets device verification status correctly 1`] = `
397397
class="mx_DeviceTile_actions"
398398
>
399399
<div
400-
aria-label="Toggle device details"
400+
aria-label="Show details"
401401
class="mx_AccessibleButton mx_DeviceExpandDetailsButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_icon"
402402
data-testid="current-session-toggle-details"
403403
role="button"

0 commit comments

Comments
 (0)