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 <travisr@matrix.org>
This commit is contained in:
Kerry 2022-08-29 12:48:00 +02:00 committed by GitHub
parent 5aae974e93
commit 825a0af4a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 480 additions and 27 deletions

View file

@ -31,6 +31,7 @@
@import "./components/views/settings/devices/_DeviceExpandDetailsButton.pcss";
@import "./components/views/settings/devices/_DeviceSecurityCard.pcss";
@import "./components/views/settings/devices/_DeviceTile.pcss";
@import "./components/views/settings/devices/_DeviceType.pcss";
@import "./components/views/settings/devices/_FilteredDeviceList.pcss";
@import "./components/views/settings/devices/_SecurityRecommendations.pcss";
@import "./components/views/settings/devices/_SelectableDeviceTile.pcss";

View file

@ -68,3 +68,7 @@ limitations under the License.
font-size: $font-12px;
color: $secondary-content;
}
.mx_DeviceSecurityCard_actions {
margin-top: $spacing-16;
}

View file

@ -0,0 +1,66 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.mx_DeviceType {
flex: 0 0 auto;
position: relative;
margin-right: $spacing-8;
/* creates space for verification icon to overlap */
padding: 0 $spacing-8 $spacing-8 0;
}
.mx_DeviceType_deviceIcon {
--background-color: $system;
--icon-color: $secondary-content;
height: 40px;
width: 40px;
box-sizing: border-box;
border: $spacing-8 solid var(--background-color);
border-radius: 50%;
color: var(--icon-color);
background-color: var(--background-color);
}
.mx_DeviceType_selected .mx_DeviceType_deviceIcon {
--background-color: $primary-content;
--icon-color: $background;
}
.mx_DeviceType_verificationIcon {
position: absolute;
bottom: 0;
right: 0;
height: 24px;
width: 24px;
box-sizing: border-box;
padding: $spacing-4;
border: 1px solid $system;
border-radius: 50%;
background-color: $background;
color: var(--v-icon-color);
&.verified {
--v-icon-color: $e2e-verified-color;
}
&.unverified {
--v-icon-color: $e2e-warning-color;
}
}

View file

@ -57,6 +57,12 @@ limitations under the License.
margin-block: 10px;
min-height: 35px;
padding: 0 $spacing-8;
.mx_DeviceType {
/* hide the new device type in legacy device list
for backwards compat reasons */
display: none;
}
}
.mx_DevicesPanel_icon {

View file

@ -0,0 +1,3 @@
<svg width="22" height="23" viewBox="0 0 22 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 22.5C17.0751 22.5 22 17.5751 22 11.5C22 5.42487 17.0751 0.5 11 0.5C4.92487 0.5 0 5.42487 0 11.5C0 17.5751 4.92487 22.5 11 22.5ZM11.0002 18.2605C11.7596 18.2605 12.3752 17.6449 12.3752 16.8855C12.3752 16.1261 11.7596 15.5105 11.0002 15.5105C10.2408 15.5105 9.6252 16.1261 9.6252 16.8855C9.6252 17.6449 10.2408 18.2605 11.0002 18.2605ZM9.0899 9.42801C9.0899 8.3697 9.94859 7.51827 10.9996 7.51827C12.0476 7.51827 12.9093 8.38001 12.9093 9.42801C12.9093 9.91336 12.7018 10.0866 11.8839 10.6516C11.5215 10.902 11.0246 11.2498 10.6376 11.7599C10.2233 12.306 9.96838 12.9869 9.96838 13.8528H12.0309C12.0309 13.4287 12.1436 13.1873 12.2807 13.0065C12.4452 12.7897 12.6834 12.6061 13.0563 12.3485C13.0955 12.3215 13.1368 12.2933 13.18 12.264C13.8559 11.8042 14.9718 11.0452 14.9718 9.42801C14.9718 7.24094 13.1867 5.45577 10.9996 5.45577C8.8156 5.45577 7.0274 7.22452 7.0274 9.42801H9.0899Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -47,7 +47,9 @@ const DeviceSecurityCard: React.FC<Props> = ({ variation, heading, description,
<div className='mx_DeviceSecurityCard_content'>
<p className='mx_DeviceSecurityCard_heading'>{ heading }</p>
<p className='mx_DeviceSecurityCard_description'>{ description }</p>
{ !!children && <div className='mx_DeviceSecurityCard_actions'>
{ children }
</div> }
</div>
</div>;
};

View file

@ -24,6 +24,7 @@ import { Alignment } from "../../elements/Tooltip";
import Heading from "../../typography/Heading";
import { INACTIVE_DEVICE_AGE_DAYS, isDeviceInactive } from "./filter";
import { DeviceWithVerification } from "./types";
import { DeviceType } from "./DeviceType";
export interface DeviceTileProps {
device: DeviceWithVerification;
children?: React.ReactNode;
@ -93,6 +94,7 @@ const DeviceTile: React.FC<DeviceTileProps> = ({ device, children, onClick }) =>
];
return <div className="mx_DeviceTile" data-testid={`device-tile-${device.device_id}`}>
<DeviceType isVerified={device.isVerified} />
<div className="mx_DeviceTile_info" onClick={onClick}>
<DeviceTileName device={device} />
<div className="mx_DeviceTile_metadata">

View file

@ -0,0 +1,56 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import classNames from 'classnames';
import { Icon as UnknownDeviceIcon } from '../../../../../res/img/element-icons/settings/unknown-device.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';
import { DeviceWithVerification } from './types';
interface Props {
isVerified?: DeviceWithVerification['isVerified'];
isSelected?: boolean;
}
export const DeviceType: React.FC<Props> = ({ isVerified, isSelected }) => (
<div className={classNames('mx_DeviceType', {
mx_DeviceType_selected: isSelected,
})}
>
{ /* TODO(kerrya) all devices have an unknown type until PSG-650 */ }
<UnknownDeviceIcon
className='mx_DeviceType_deviceIcon'
role='img'
aria-label={_t('Unknown device type')}
/>
{
isVerified
? <VerifiedIcon
className={classNames('mx_DeviceType_verificationIcon', 'verified')}
role='img'
aria-label={_t('Verified')}
/>
: <UnverifiedIcon
className={classNames('mx_DeviceType_verificationIcon', 'unverified')}
role='img'
aria-label={_t('Unverified')}
/>
}
</div>);

View file

@ -1712,6 +1712,7 @@
"Inactive for %(inactiveAgeDays)s+ days": "Inactive for %(inactiveAgeDays)s+ days",
"Verified": "Verified",
"Unverified": "Unverified",
"Unknown device type": "Unknown device type",
"Verified session": "Verified session",
"This session is ready for secure messaging.": "This session is ready for secure messaging.",
"Unverified session": "Unverified session",

View file

@ -111,6 +111,20 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-device_1"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -215,6 +229,20 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-device_2"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -278,6 +306,20 @@ exports[`<DevicesPanel /> renders device panel with devices 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-device_3"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>

View file

@ -0,0 +1,44 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { render } from '@testing-library/react';
import React from 'react';
import { DeviceType } from '../../../../../src/components/views/settings/devices/DeviceType';
describe('<DeviceType />', () => {
const defaultProps = {
isVerified: false,
isSelected: false,
};
const getComponent = (props = {}) =>
<DeviceType {...defaultProps} {...props} />;
it('renders an unverified device', () => {
const { container } = render(getComponent());
expect(container).toMatchSnapshot();
});
it('renders a verified device', () => {
const { container } = render(getComponent({ isVerified: true }));
expect(container).toMatchSnapshot();
});
it('renders correctly when selected', () => {
const { container } = render(getComponent({ isSelected: true }));
expect(container).toMatchSnapshot();
});
});

View file

@ -141,6 +141,20 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
class="mx_DeviceTile"
data-testid="device-tile-alices_device"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -227,6 +241,20 @@ exports[`<CurrentDeviceSection /> renders device and correct security card when
class="mx_DeviceTile"
data-testid="device-tile-alices_device"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>

View file

@ -57,10 +57,14 @@ exports[`<DeviceSecurityCard /> renders with children 1`] = `
>
nice
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div>
hey
</div>
</div>
</div>
</div>
</div>
`;

View file

@ -6,6 +6,20 @@ exports[`<DeviceTile /> renders a device with no metadata 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-123"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -39,6 +53,20 @@ exports[`<DeviceTile /> renders a verified device with no metadata 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-123"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -72,6 +100,20 @@ exports[`<DeviceTile /> renders display name with a tooltip 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-123"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -109,6 +151,20 @@ exports[`<DeviceTile /> separates metadata with a dot 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-123"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>

View file

@ -0,0 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<DeviceType /> renders a verified device 1`] = `
<div>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Verified"
class="mx_DeviceType_verificationIcon verified"
role="img"
/>
</div>
</div>
`;
exports[`<DeviceType /> renders an unverified device 1`] = `
<div>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
</div>
`;
exports[`<DeviceType /> renders correctly when selected 1`] = `
<div>
<div
class="mx_DeviceType mx_DeviceType_selected"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
</div>
`;

View file

@ -43,6 +43,9 @@ exports[`<SecurityRecommendations /> renders both cards when user has both unver
>
Verify your sessions for enhanced secure messaging or sign out from those you don't recognize or use anymore.
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
@ -52,6 +55,7 @@ exports[`<SecurityRecommendations /> renders both cards when user has both unver
</div>
</div>
</div>
</div>
<div
class="mx_SecurityRecommendations_spacing"
/>
@ -79,6 +83,9 @@ exports[`<SecurityRecommendations /> renders both cards when user has both unver
>
Consider signing out from old sessions (90 days or older) you don't use anymore
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
@ -90,6 +97,7 @@ exports[`<SecurityRecommendations /> renders both cards when user has both unver
</div>
</div>
</div>
</div>
</div>
`;
@ -136,6 +144,9 @@ exports[`<SecurityRecommendations /> renders inactive devices section when user
>
Verify your sessions for enhanced secure messaging or sign out from those you don't recognize or use anymore.
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
@ -145,6 +156,7 @@ exports[`<SecurityRecommendations /> renders inactive devices section when user
</div>
</div>
</div>
</div>
<div
class="mx_SecurityRecommendations_spacing"
/>
@ -172,6 +184,9 @@ exports[`<SecurityRecommendations /> renders inactive devices section when user
>
Consider signing out from old sessions (90 days or older) you don't use anymore
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
@ -183,6 +198,7 @@ exports[`<SecurityRecommendations /> renders inactive devices section when user
</div>
</div>
</div>
</div>
</div>
`;
@ -229,6 +245,9 @@ exports[`<SecurityRecommendations /> renders unverified devices section when use
>
Verify your sessions for enhanced secure messaging or sign out from those you don't recognize or use anymore.
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
@ -238,6 +257,7 @@ exports[`<SecurityRecommendations /> renders unverified devices section when use
</div>
</div>
</div>
</div>
<div
class="mx_SecurityRecommendations_spacing"
/>
@ -265,6 +285,9 @@ exports[`<SecurityRecommendations /> renders unverified devices section when use
>
Consider signing out from old sessions (90 days or older) you don't use anymore
</p>
<div
class="mx_DeviceSecurityCard_actions"
>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
@ -276,5 +299,6 @@ exports[`<SecurityRecommendations /> renders unverified devices section when use
</div>
</div>
</div>
</div>
</div>
`;

View file

@ -36,6 +36,20 @@ exports[`<SelectableDeviceTile /> renders unselected device tile with checkbox 1
class="mx_DeviceTile"
data-testid="device-tile-my-device"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>

View file

@ -17,6 +17,20 @@ exports[`<SessionManagerTab /> renders current session section with a verified s
class="mx_DeviceTile"
data-testid="device-tile-alices_device"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Verified"
class="mx_DeviceType_verificationIcon verified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -101,6 +115,20 @@ exports[`<SessionManagerTab /> renders current session section with an unverifie
class="mx_DeviceTile"
data-testid="device-tile-alices_device"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Unverified"
class="mx_DeviceType_verificationIcon unverified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>
@ -173,6 +201,20 @@ exports[`<SessionManagerTab /> sets device verification status correctly 1`] = `
class="mx_DeviceTile"
data-testid="device-tile-alices_device"
>
<div
class="mx_DeviceType"
>
<div
aria-label="Unknown device type"
class="mx_DeviceType_deviceIcon"
role="img"
/>
<div
aria-label="Verified"
class="mx_DeviceType_verificationIcon verified"
role="img"
/>
</div>
<div
class="mx_DeviceTile_info"
>