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

Device manager - device type icon #9355

Merged
merged 41 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a37682e
record device client inforamtion events on app start
Sep 23, 2022
94b027b
matrix-client-information -> matrix_client_information
Sep 26, 2022
593465a
fix types
Sep 26, 2022
3f616af
Merge branch 'develop' into psg-633/save-device-client-info
Sep 26, 2022
c858656
remove another unused export
Sep 26, 2022
950f61c
add docs link
Sep 27, 2022
fb95964
Merge branch 'develop' into psg-633/save-device-client-info
Sep 27, 2022
258d364
display device client information in device details
Sep 23, 2022
a3cf263
update snapshots
Sep 23, 2022
d316ec6
integration-ish test client information in metadata
Sep 23, 2022
f24e983
tests
Sep 23, 2022
e79934f
fix tests
Sep 26, 2022
9e86e9e
export helper
Sep 26, 2022
ad81d2c
DeviceClientInformation type
Sep 26, 2022
b97ff34
Merge branch 'develop' into psg-682/display-client-info
Sep 30, 2022
d1e3b73
Merge branch 'develop' into psg-682/display-client-info
Oct 4, 2022
0e273d9
Device manager - select all devices (#9330)
Oct 4, 2022
ae76c77
rename type
Oct 4, 2022
295c6d7
use ExtendedDevice type everywhere
Oct 4, 2022
b733f61
rename clientName to appName for less collision with UA parser
Oct 4, 2022
605019c
fix bad find and replace
Oct 4, 2022
0bec4bd
Merge branch 'psg-632/device-man-type-shuffle' into psg-632/device-ma…
Oct 4, 2022
b8c3ea1
rename ExtendedDeviceInfo to ExtendedDeviceAppInfo
Oct 4, 2022
a01c3ca
Merge branch 'psg-632/device-man-type-shuffle' into psg-632/device-ma…
Oct 4, 2022
2569c0c
rename DeviceType comp to DeviceTypeIcon
Oct 4, 2022
82dbfb6
update tests for new required property deviceType
Oct 4, 2022
b10c197
add stubbed user agent parsing
Oct 4, 2022
680fb21
Merge branch 'develop' into psg-682/display-client-info
Oct 4, 2022
eef014a
Merge branch 'psg-682/display-client-info' into psg-632/device-man-pa…
Oct 4, 2022
6766985
Merge branch 'develop' into psg-632/device-man-parse-ua
Oct 4, 2022
6ab22d3
Merge branch 'develop' into psg-632/device-man-parse-ua
Oct 5, 2022
906dfbd
add icons
Oct 5, 2022
cd28260
Merge branch 'develop' into psg-650/device-man-type-icon
Oct 5, 2022
b65688c
set device type icon
Oct 5, 2022
9f46bec
device type icon tets
Oct 5, 2022
1e00fda
update snapshots for device type icon changes
Oct 5, 2022
f979e6c
desktop icon viewbox
Oct 5, 2022
904ddde
i18n
Oct 5, 2022
6d55a4b
Merge branch 'develop' into psg-650/device-man-type-icon
Oct 5, 2022
aec9c1d
Merge branch 'develop' into psg-650/device-man-type-icon
Oct 6, 2022
d592daa
Merge branch 'develop' into psg-650/device-man-type-icon
Oct 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ limitations under the License.
padding: 0 $spacing-8 $spacing-8 0;
}

.mx_DeviceTypeIcon_deviceIcon {
.mx_DeviceTypeIcon_deviceIconWrapper {
--background-color: $system;
--icon-color: $secondary-content;

Expand All @@ -36,11 +36,16 @@ limitations under the License.
background-color: var(--background-color);
}

.mx_DeviceTypeIcon_selected .mx_DeviceTypeIcon_deviceIcon {
.mx_DeviceTypeIcon_selected .mx_DeviceTypeIcon_deviceIconWrapper {
--background-color: $primary-content;
--icon-color: $background;
}

.mx_DeviceTypeIcon_deviceIcon {
height: 24px;
width: 24px;
}

.mx_DeviceTypeIcon_verificationIcon {
position: absolute;
bottom: 0;
Expand Down
3 changes: 3 additions & 0 deletions res/img/element-icons/settings/desktop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions res/img/element-icons/settings/mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions res/img/element-icons/settings/web.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 44 additions & 23 deletions src/components/views/settings/devices/DeviceTypeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import React from 'react';
import classNames from 'classnames';

import { Icon as UnknownDeviceIcon } from '../../../../../res/img/element-icons/settings/unknown-device.svg';
import { Icon as DesktopIcon } from '../../../../../res/img/element-icons/settings/desktop.svg';
import { Icon as WebIcon } from '../../../../../res/img/element-icons/settings/web.svg';
import { Icon as MobileIcon } from '../../../../../res/img/element-icons/settings/mobile.svg';
import { Icon as VerifiedIcon } from '../../../../../res/img/e2e/verified.svg';
import { Icon as UnverifiedIcon } from '../../../../../res/img/e2e/warning.svg';
import { _t } from '../../../../languageHandler';
Expand All @@ -30,33 +33,51 @@ interface Props {
deviceType?: DeviceType;
}

const deviceTypeIcon: Record<DeviceType, React.FC<React.SVGProps<SVGSVGElement>>> = {
[DeviceType.Desktop]: DesktopIcon,
[DeviceType.Mobile]: MobileIcon,
[DeviceType.Web]: WebIcon,
[DeviceType.Unknown]: UnknownDeviceIcon,
};
const deviceTypeLabel: Record<DeviceType, string> = {
[DeviceType.Desktop]: _t('Desktop session'),
[DeviceType.Mobile]: _t('Mobile session'),
[DeviceType.Web]: _t('Web session'),
[DeviceType.Unknown]: _t('Unknown session type'),
};

export const DeviceTypeIcon: React.FC<Props> = ({
isVerified,
isSelected,
deviceType,
}) => (
<div className={classNames('mx_DeviceTypeIcon', {
mx_DeviceTypeIcon_selected: isSelected,
})}
>
{ /* TODO(kerrya) all devices have an unknown type until PSG-650 */ }
<UnknownDeviceIcon
className='mx_DeviceTypeIcon_deviceIcon'
role='img'
aria-label={_t('Unknown device type')}
/>
{
isVerified
? <VerifiedIcon
className={classNames('mx_DeviceTypeIcon_verificationIcon', 'verified')}
role='img'
aria-label={_t('Verified')}
/>
: <UnverifiedIcon
className={classNames('mx_DeviceTypeIcon_verificationIcon', 'unverified')}
}) => {
const Icon = deviceTypeIcon[deviceType] || deviceTypeIcon[DeviceType.Unknown];
const label = deviceTypeLabel[deviceType] || deviceTypeLabel[DeviceType.Unknown];
return (
<div className={classNames('mx_DeviceTypeIcon', {
mx_DeviceTypeIcon_selected: isSelected,
})}
>
<div className='mx_DeviceTypeIcon_deviceIconWrapper'>
<Icon
className='mx_DeviceTypeIcon_deviceIcon'
role='img'
aria-label={_t('Unverified')}
aria-label={label}
/>
}
</div>);
</div>
{
isVerified
? <VerifiedIcon
className={classNames('mx_DeviceTypeIcon_verificationIcon', 'verified')}
role='img'
aria-label={_t('Verified')}
/>
: <UnverifiedIcon
className={classNames('mx_DeviceTypeIcon_verificationIcon', 'unverified')}
role='img'
aria-label={_t('Unverified')}
/>
}
</div>);
};

5 changes: 4 additions & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,10 @@
"Inactive for %(inactiveAgeDays)s+ days": "Inactive for %(inactiveAgeDays)s+ days",
"Verified": "Verified",
"Unverified": "Unverified",
"Unknown device type": "Unknown device type",
"Desktop session": "Desktop session",
"Mobile session": "Mobile session",
"Web session": "Web session",
"Unknown session type": "Unknown session type",
"Verified session": "Verified session",
"This session is ready for secure messaging.": "This session is ready for secure messaging.",
"Unverified session": "Unverified session",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down Expand Up @@ -238,10 +242,14 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down Expand Up @@ -320,10 +328,14 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down
30 changes: 30 additions & 0 deletions test/components/views/settings/devices/DeviceTypeIcon-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { render } from '@testing-library/react';
import React from 'react';

import { DeviceTypeIcon } from '../../../../../src/components/views/settings/devices/DeviceTypeIcon';
import { DeviceType } from '../../../../../src/utils/device/parseUserAgent';

describe('<DeviceTypeIcon />', () => {
const defaultProps = {
Expand All @@ -41,4 +42,33 @@ describe('<DeviceTypeIcon />', () => {
const { container } = render(getComponent({ isSelected: true }));
expect(container).toMatchSnapshot();
});

it('renders an unknown device icon when no device type given', () => {
const { getByLabelText } = render(getComponent());
expect(getByLabelText('Unknown session type')).toBeTruthy();
});

it('renders a desktop device type', () => {
const deviceType = DeviceType.Desktop;
const { getByLabelText } = render(getComponent({ deviceType }));
expect(getByLabelText('Desktop session')).toBeTruthy();
});

it('renders a web device type', () => {
const deviceType = DeviceType.Web;
const { getByLabelText } = render(getComponent({ deviceType }));
expect(getByLabelText('Web session')).toBeTruthy();
});

it('renders a mobile device type', () => {
const deviceType = DeviceType.Mobile;
const { getByLabelText } = render(getComponent({ deviceType }));
expect(getByLabelText('Mobile session')).toBeTruthy();
});

it('renders an unknown device type', () => {
const deviceType = DeviceType.Unknown;
const { getByLabelText } = render(getComponent({ deviceType }));
expect(getByLabelText('Unknown session type')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down Expand Up @@ -270,10 +274,14 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ exports[`<DeviceTile /> renders a device with no metadata 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down Expand Up @@ -61,10 +65,14 @@ exports[`<DeviceTile /> renders a verified device with no metadata 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down Expand Up @@ -112,10 +120,14 @@ exports[`<DeviceTile /> renders display name with a tooltip 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down Expand Up @@ -163,10 +175,14 @@ exports[`<DeviceTile /> separates metadata with a dot 1`] = `
class="mx_DeviceTypeIcon"
>
<div
aria-label="Unknown device type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
class="mx_DeviceTypeIcon_deviceIconWrapper"
>
<div
aria-label="Unknown session type"
class="mx_DeviceTypeIcon_deviceIcon"
role="img"
/>
</div>
<div
aria-label="Unverified"
class="mx_DeviceTypeIcon_verificationIcon unverified"
Expand Down
Loading