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

Commit 825a0af

Browse files
Kerryturt2live
andauthored
Device manager - device type and verification icons on device tile (PSG-637) (#9197)
* add unknown device icon * add device type and verification icon component * test * stylelint * fix securitycard spacing Co-authored-by: Travis Ralston <[email protected]>
1 parent 5aae974 commit 825a0af

File tree

18 files changed

+480
-27
lines changed

18 files changed

+480
-27
lines changed

res/css/_components.pcss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
@import "./components/views/settings/devices/_DeviceExpandDetailsButton.pcss";
3232
@import "./components/views/settings/devices/_DeviceSecurityCard.pcss";
3333
@import "./components/views/settings/devices/_DeviceTile.pcss";
34+
@import "./components/views/settings/devices/_DeviceType.pcss";
3435
@import "./components/views/settings/devices/_FilteredDeviceList.pcss";
3536
@import "./components/views/settings/devices/_SecurityRecommendations.pcss";
3637
@import "./components/views/settings/devices/_SelectableDeviceTile.pcss";

res/css/components/views/settings/devices/_DeviceSecurityCard.pcss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ limitations under the License.
6868
font-size: $font-12px;
6969
color: $secondary-content;
7070
}
71+
72+
.mx_DeviceSecurityCard_actions {
73+
margin-top: $spacing-16;
74+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_DeviceType {
18+
flex: 0 0 auto;
19+
position: relative;
20+
margin-right: $spacing-8;
21+
/* creates space for verification icon to overlap */
22+
padding: 0 $spacing-8 $spacing-8 0;
23+
}
24+
25+
.mx_DeviceType_deviceIcon {
26+
--background-color: $system;
27+
--icon-color: $secondary-content;
28+
29+
height: 40px;
30+
width: 40px;
31+
box-sizing: border-box;
32+
33+
border: $spacing-8 solid var(--background-color);
34+
border-radius: 50%;
35+
color: var(--icon-color);
36+
background-color: var(--background-color);
37+
}
38+
39+
.mx_DeviceType_selected .mx_DeviceType_deviceIcon {
40+
--background-color: $primary-content;
41+
--icon-color: $background;
42+
}
43+
44+
.mx_DeviceType_verificationIcon {
45+
position: absolute;
46+
bottom: 0;
47+
right: 0;
48+
height: 24px;
49+
width: 24px;
50+
box-sizing: border-box;
51+
padding: $spacing-4;
52+
53+
border: 1px solid $system;
54+
border-radius: 50%;
55+
background-color: $background;
56+
57+
color: var(--v-icon-color);
58+
59+
&.verified {
60+
--v-icon-color: $e2e-verified-color;
61+
}
62+
63+
&.unverified {
64+
--v-icon-color: $e2e-warning-color;
65+
}
66+
}

res/css/views/settings/_DevicesPanel.pcss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ limitations under the License.
5757
margin-block: 10px;
5858
min-height: 35px;
5959
padding: 0 $spacing-8;
60+
61+
.mx_DeviceType {
62+
/* hide the new device type in legacy device list
63+
for backwards compat reasons */
64+
display: none;
65+
}
6066
}
6167

6268
.mx_DevicesPanel_icon {
Lines changed: 3 additions & 0 deletions
Loading

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ const DeviceSecurityCard: React.FC<Props> = ({ variation, heading, description,
4747
<div className='mx_DeviceSecurityCard_content'>
4848
<p className='mx_DeviceSecurityCard_heading'>{ heading }</p>
4949
<p className='mx_DeviceSecurityCard_description'>{ description }</p>
50-
{ children }
50+
{ !!children && <div className='mx_DeviceSecurityCard_actions'>
51+
{ children }
52+
</div> }
5153
</div>
5254
</div>;
5355
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Alignment } from "../../elements/Tooltip";
2424
import Heading from "../../typography/Heading";
2525
import { INACTIVE_DEVICE_AGE_DAYS, isDeviceInactive } from "./filter";
2626
import { DeviceWithVerification } from "./types";
27+
import { DeviceType } from "./DeviceType";
2728
export interface DeviceTileProps {
2829
device: DeviceWithVerification;
2930
children?: React.ReactNode;
@@ -93,6 +94,7 @@ const DeviceTile: React.FC<DeviceTileProps> = ({ device, children, onClick }) =>
9394
];
9495

9596
return <div className="mx_DeviceTile" data-testid={`device-tile-${device.device_id}`}>
97+
<DeviceType isVerified={device.isVerified} />
9698
<div className="mx_DeviceTile_info" onClick={onClick}>
9799
<DeviceTileName device={device} />
98100
<div className="mx_DeviceTile_metadata">
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import classNames from 'classnames';
19+
20+
import { Icon as UnknownDeviceIcon } from '../../../../../res/img/element-icons/settings/unknown-device.svg';
21+
import { Icon as VerifiedIcon } from '../../../../../res/img/e2e/verified.svg';
22+
import { Icon as UnverifiedIcon } from '../../../../../res/img/e2e/warning.svg';
23+
import { _t } from '../../../../languageHandler';
24+
import { DeviceWithVerification } from './types';
25+
26+
interface Props {
27+
isVerified?: DeviceWithVerification['isVerified'];
28+
isSelected?: boolean;
29+
}
30+
31+
export const DeviceType: React.FC<Props> = ({ isVerified, isSelected }) => (
32+
<div className={classNames('mx_DeviceType', {
33+
mx_DeviceType_selected: isSelected,
34+
})}
35+
>
36+
{ /* TODO(kerrya) all devices have an unknown type until PSG-650 */ }
37+
<UnknownDeviceIcon
38+
className='mx_DeviceType_deviceIcon'
39+
role='img'
40+
aria-label={_t('Unknown device type')}
41+
/>
42+
{
43+
isVerified
44+
? <VerifiedIcon
45+
className={classNames('mx_DeviceType_verificationIcon', 'verified')}
46+
role='img'
47+
aria-label={_t('Verified')}
48+
/>
49+
: <UnverifiedIcon
50+
className={classNames('mx_DeviceType_verificationIcon', 'unverified')}
51+
role='img'
52+
aria-label={_t('Unverified')}
53+
/>
54+
}
55+
</div>);
56+

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,7 @@
17121712
"Inactive for %(inactiveAgeDays)s+ days": "Inactive for %(inactiveAgeDays)s+ days",
17131713
"Verified": "Verified",
17141714
"Unverified": "Unverified",
1715+
"Unknown device type": "Unknown device type",
17151716
"Verified session": "Verified session",
17161717
"This session is ready for secure messaging.": "This session is ready for secure messaging.",
17171718
"Unverified session": "Unverified session",

test/components/views/settings/__snapshots__/DevicesPanel-test.tsx.snap

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
111111
class="mx_DeviceTile"
112112
data-testid="device-tile-device_1"
113113
>
114+
<div
115+
class="mx_DeviceType"
116+
>
117+
<div
118+
aria-label="Unknown device type"
119+
class="mx_DeviceType_deviceIcon"
120+
role="img"
121+
/>
122+
<div
123+
aria-label="Unverified"
124+
class="mx_DeviceType_verificationIcon unverified"
125+
role="img"
126+
/>
127+
</div>
114128
<div
115129
class="mx_DeviceTile_info"
116130
>
@@ -215,6 +229,20 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
215229
class="mx_DeviceTile"
216230
data-testid="device-tile-device_2"
217231
>
232+
<div
233+
class="mx_DeviceType"
234+
>
235+
<div
236+
aria-label="Unknown device type"
237+
class="mx_DeviceType_deviceIcon"
238+
role="img"
239+
/>
240+
<div
241+
aria-label="Unverified"
242+
class="mx_DeviceType_verificationIcon unverified"
243+
role="img"
244+
/>
245+
</div>
218246
<div
219247
class="mx_DeviceTile_info"
220248
>
@@ -278,6 +306,20 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
278306
class="mx_DeviceTile"
279307
data-testid="device-tile-device_3"
280308
>
309+
<div
310+
class="mx_DeviceType"
311+
>
312+
<div
313+
aria-label="Unknown device type"
314+
class="mx_DeviceType_deviceIcon"
315+
role="img"
316+
/>
317+
<div
318+
aria-label="Unverified"
319+
class="mx_DeviceType_verificationIcon unverified"
320+
role="img"
321+
/>
322+
</div>
281323
<div
282324
class="mx_DeviceTile_info"
283325
>

0 commit comments

Comments
 (0)