From 01f2643b609fb69c949c46ceabd5bb400fb042eb Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 17 Aug 2022 11:02:50 +0200 Subject: [PATCH 1/6] add unknown device icon --- res/img/element-icons/settings/unknown-device.svg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 res/img/element-icons/settings/unknown-device.svg diff --git a/res/img/element-icons/settings/unknown-device.svg b/res/img/element-icons/settings/unknown-device.svg new file mode 100644 index 00000000000..c02c2eadf50 --- /dev/null +++ b/res/img/element-icons/settings/unknown-device.svg @@ -0,0 +1,3 @@ + + + From 822be8f2849c036e0e4ce31f1031e8a8c89febc5 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 17 Aug 2022 11:54:17 +0200 Subject: [PATCH 2/6] add device type and verification icon component --- res/css/_components.pcss | 1 + .../views/settings/devices/_DeviceType.pcss | 66 +++++++++++++++++++ res/css/views/settings/_DevicesPanel.pcss | 6 ++ .../views/settings/devices/DeviceTile.tsx | 2 + .../views/settings/devices/DeviceType.tsx | 55 ++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 res/css/components/views/settings/devices/_DeviceType.pcss create mode 100644 src/components/views/settings/devices/DeviceType.tsx diff --git a/res/css/_components.pcss b/res/css/_components.pcss index 3f23e6de572..e7f94c3ad79 100644 --- a/res/css/_components.pcss +++ b/res/css/_components.pcss @@ -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"; diff --git a/res/css/components/views/settings/devices/_DeviceType.pcss b/res/css/components/views/settings/devices/_DeviceType.pcss new file mode 100644 index 00000000000..b57982e73af --- /dev/null +++ b/res/css/components/views/settings/devices/_DeviceType.pcss @@ -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; + } +} \ No newline at end of file diff --git a/res/css/views/settings/_DevicesPanel.pcss b/res/css/views/settings/_DevicesPanel.pcss index 8581225cee8..23a737c9779 100644 --- a/res/css/views/settings/_DevicesPanel.pcss +++ b/res/css/views/settings/_DevicesPanel.pcss @@ -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 { diff --git a/src/components/views/settings/devices/DeviceTile.tsx b/src/components/views/settings/devices/DeviceTile.tsx index c791d2cd259..73ee17b2f4a 100644 --- a/src/components/views/settings/devices/DeviceTile.tsx +++ b/src/components/views/settings/devices/DeviceTile.tsx @@ -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 = ({ device, children, onClick }) => ]; return
+
diff --git a/src/components/views/settings/devices/DeviceType.tsx b/src/components/views/settings/devices/DeviceType.tsx new file mode 100644 index 00000000000..24fdbfc78a3 --- /dev/null +++ b/src/components/views/settings/devices/DeviceType.tsx @@ -0,0 +1,55 @@ +/* +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'; + +interface Props { + isVerified?: boolean; + isSelected?: boolean; +} + +export const DeviceType: React.FC = ({ isVerified, isSelected }) => ( +
+ { /* TODO(kerrya) all devices have an unknown type until PSG-650 */ } + + { + isVerified + ? + : + } +
); + From 17aefa397d03895c9a0a684a9197097f7bf95c18 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Wed, 17 Aug 2022 11:54:22 +0200 Subject: [PATCH 3/6] test --- src/i18n/strings/en_EN.json | 1 + .../__snapshots__/DevicesPanel-test.tsx.snap | 42 ++++++++++++++ .../settings/devices/DeviceType-test.tsx | 44 ++++++++++++++ .../CurrentDeviceSection-test.tsx.snap | 28 +++++++++ .../__snapshots__/DeviceTile-test.tsx.snap | 56 ++++++++++++++++++ .../__snapshots__/DeviceType-test.tsx.snap | 58 +++++++++++++++++++ .../SelectableDeviceTile-test.tsx.snap | 14 +++++ .../SessionManagerTab-test.tsx.snap | 42 ++++++++++++++ 8 files changed, 285 insertions(+) create mode 100644 test/components/views/settings/devices/DeviceType-test.tsx create mode 100644 test/components/views/settings/devices/__snapshots__/DeviceType-test.tsx.snap diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b417c0e6833..b3f3a5529a8 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1705,6 +1705,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", diff --git a/test/components/views/settings/__snapshots__/DevicesPanel-test.tsx.snap b/test/components/views/settings/__snapshots__/DevicesPanel-test.tsx.snap index b0a056b10f9..f0c569a82f1 100644 --- a/test/components/views/settings/__snapshots__/DevicesPanel-test.tsx.snap +++ b/test/components/views/settings/__snapshots__/DevicesPanel-test.tsx.snap @@ -111,6 +111,20 @@ exports[` renders device panel with devices 1`] = ` class="mx_DeviceTile" data-testid="device-tile-device_1" > +
+