Skip to content

Commit bd270b0

Browse files
author
Kerry
authored
Device manager - add foundation for extended device info (matrix-org#9344)
* record device client inforamtion events on app start * matrix-client-information -> matrix_client_information * fix types * remove another unused export * add docs link * display device client information in device details * update snapshots * integration-ish test client information in metadata * tests * fix tests * export helper * DeviceClientInformation type * Device manager - select all devices (matrix-org#9330) * add device selection that does nothing * multi select and sign out of sessions * test multiple selection * fix type after rebase * select all sessions * rename type * use ExtendedDevice type everywhere * rename clientName to appName for less collision with UA parser * fix bad find and replace * rename ExtendedDeviceInfo to ExtendedDeviceAppInfo * rename DeviceType comp to DeviceTypeIcon * update tests for new required property deviceType * add stubbed user agent parsing
1 parent 1032334 commit bd270b0

34 files changed

+319
-187
lines changed

res/css/_components.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@import "./components/views/settings/devices/_DeviceExpandDetailsButton.pcss";
3535
@import "./components/views/settings/devices/_DeviceSecurityCard.pcss";
3636
@import "./components/views/settings/devices/_DeviceTile.pcss";
37-
@import "./components/views/settings/devices/_DeviceType.pcss";
37+
@import "./components/views/settings/devices/_DeviceTypeIcon.pcss";
3838
@import "./components/views/settings/devices/_FilteredDeviceList.pcss";
3939
@import "./components/views/settings/devices/_FilteredDeviceListHeader.pcss";
4040
@import "./components/views/settings/devices/_SecurityRecommendations.pcss";

res/css/components/views/settings/devices/_DeviceType.pcss renamed to res/css/components/views/settings/devices/_DeviceTypeIcon.pcss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_DeviceType {
17+
.mx_DeviceTypeIcon {
1818
flex: 0 0 auto;
1919
position: relative;
2020
margin-right: $spacing-8;
2121
/* creates space for verification icon to overlap */
2222
padding: 0 $spacing-8 $spacing-8 0;
2323
}
2424

25-
.mx_DeviceType_deviceIcon {
25+
.mx_DeviceTypeIcon_deviceIcon {
2626
--background-color: $system;
2727
--icon-color: $secondary-content;
2828

@@ -36,12 +36,12 @@ limitations under the License.
3636
background-color: var(--background-color);
3737
}
3838

39-
.mx_DeviceType_selected .mx_DeviceType_deviceIcon {
39+
.mx_DeviceTypeIcon_selected .mx_DeviceTypeIcon_deviceIcon {
4040
--background-color: $primary-content;
4141
--icon-color: $background;
4242
}
4343

44-
.mx_DeviceType_verificationIcon {
44+
.mx_DeviceTypeIcon_verificationIcon {
4545
position: absolute;
4646
bottom: 0;
4747
right: 0;

res/css/views/settings/_DevicesPanel.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ limitations under the License.
5858
min-height: 35px;
5959
padding: 0 $spacing-8;
6060

61-
.mx_DeviceType {
61+
.mx_DeviceTypeIcon {
6262
/* hide the new device type in legacy device list
6363
for backwards compat reasons */
6464
display: none;

src/components/views/settings/DevicesPanelEntry.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import VerificationRequestDialog from '../../views/dialogs/VerificationRequestDi
2929
import LogoutDialog from '../dialogs/LogoutDialog';
3030
import DeviceTile from './devices/DeviceTile';
3131
import SelectableDeviceTile from './devices/SelectableDeviceTile';
32+
import { DeviceType } from '../../../utils/device/parseUserAgent';
3233

3334
interface IProps {
3435
device: IMyDevice;
@@ -153,25 +154,26 @@ export default class DevicesPanelEntry extends React.Component<IProps, IState> {
153154
</AccessibleButton>
154155
</React.Fragment>;
155156

156-
const deviceWithVerification = {
157+
const extendedDevice = {
157158
...this.props.device,
158159
isVerified: this.props.verified,
160+
deviceType: DeviceType.Unknown,
159161
};
160162

161163
if (this.props.isOwnDevice) {
162164
return <div className={classNames("mx_DevicesPanel_device", "mx_DevicesPanel_myDevice")}>
163165
<div className="mx_DevicesPanel_deviceTrust">
164166
<span className={"mx_DevicesPanel_icon mx_E2EIcon " + iconClass} />
165167
</div>
166-
<DeviceTile device={deviceWithVerification}>
168+
<DeviceTile device={extendedDevice}>
167169
{ buttons }
168170
</DeviceTile>
169171
</div>;
170172
}
171173

172174
return (
173175
<div className="mx_DevicesPanel_device">
174-
<SelectableDeviceTile device={deviceWithVerification} onClick={this.onDeviceToggled} isSelected={this.props.selected}>
176+
<SelectableDeviceTile device={extendedDevice} onClick={this.onDeviceToggled} isSelected={this.props.selected}>
175177
{ buttons }
176178
</SelectableDeviceTile>
177179
</div>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import DeviceDetails from './DeviceDetails';
2424
import DeviceExpandDetailsButton from './DeviceExpandDetailsButton';
2525
import DeviceTile from './DeviceTile';
2626
import { DeviceVerificationStatusCard } from './DeviceVerificationStatusCard';
27-
import { DeviceWithVerification } from './types';
27+
import { ExtendedDevice } from './types';
2828

2929
interface Props {
30-
device?: DeviceWithVerification;
30+
device?: ExtendedDevice;
3131
isLoading: boolean;
3232
isSigningOut: boolean;
3333
localNotificationSettings?: LocalNotificationSettings | undefined;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import Field from '../../elements/Field';
2222
import Spinner from '../../elements/Spinner';
2323
import { Caption } from '../../typography/Caption';
2424
import Heading from '../../typography/Heading';
25-
import { DeviceWithVerification } from './types';
25+
import { ExtendedDevice } from './types';
2626

2727
interface Props {
28-
device: DeviceWithVerification;
28+
device: ExtendedDevice;
2929
saveDeviceName: (deviceName: string) => Promise<void>;
3030
}
3131

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ const DeviceDetails: React.FC<Props> = ({
7272
id: 'application',
7373
heading: _t('Application'),
7474
values: [
75-
{ label: _t('Name'), value: device.clientName },
76-
{ label: _t('Version'), value: device.clientVersion },
75+
{ label: _t('Name'), value: device.appName },
76+
{ label: _t('Version'), value: device.appVersion },
7777
{ label: _t('URL'), value: device.url },
7878
],
7979
},

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ import { _t } from "../../../../languageHandler";
2121
import { formatDate, formatRelativeTime } from "../../../../DateUtils";
2222
import Heading from "../../typography/Heading";
2323
import { INACTIVE_DEVICE_AGE_DAYS, isDeviceInactive } from "./filter";
24-
import { DeviceWithVerification } from "./types";
25-
import { DeviceType } from "./DeviceType";
24+
import { ExtendedDevice } from "./types";
25+
import { DeviceTypeIcon } from "./DeviceTypeIcon";
2626
export interface DeviceTileProps {
27-
device: DeviceWithVerification;
27+
device: ExtendedDevice;
2828
isSelected?: boolean;
2929
children?: React.ReactNode;
3030
onClick?: () => void;
3131
}
3232

33-
const DeviceTileName: React.FC<{ device: DeviceWithVerification }> = ({ device }) => {
33+
const DeviceTileName: React.FC<{ device: ExtendedDevice }> = ({ device }) => {
3434
return <Heading size='h4'>
3535
{ device.display_name || device.device_id }
3636
</Heading>;
@@ -48,7 +48,7 @@ const formatLastActivity = (timestamp: number, now = new Date().getTime()): stri
4848
return formatRelativeTime(new Date(timestamp));
4949
};
5050

51-
const getInactiveMetadata = (device: DeviceWithVerification): { id: string, value: React.ReactNode } | undefined => {
51+
const getInactiveMetadata = (device: ExtendedDevice): { id: string, value: React.ReactNode } | undefined => {
5252
const isInactive = isDeviceInactive(device);
5353

5454
if (!isInactive) {
@@ -89,7 +89,11 @@ const DeviceTile: React.FC<DeviceTileProps> = ({
8989
];
9090

9191
return <div className="mx_DeviceTile" data-testid={`device-tile-${device.device_id}`}>
92-
<DeviceType isVerified={device.isVerified} isSelected={isSelected} />
92+
<DeviceTypeIcon
93+
isVerified={device.isVerified}
94+
isSelected={isSelected}
95+
deviceType={device.deviceType}
96+
/>
9397
<div className="mx_DeviceTile_info" onClick={onClick}>
9498
<DeviceTileName device={device} />
9599
<div className="mx_DeviceTile_metadata">

src/components/views/settings/devices/DeviceType.tsx renamed to src/components/views/settings/devices/DeviceTypeIcon.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,39 @@ import { Icon as UnknownDeviceIcon } from '../../../../../res/img/element-icons/
2121
import { Icon as VerifiedIcon } from '../../../../../res/img/e2e/verified.svg';
2222
import { Icon as UnverifiedIcon } from '../../../../../res/img/e2e/warning.svg';
2323
import { _t } from '../../../../languageHandler';
24-
import { DeviceWithVerification } from './types';
24+
import { ExtendedDevice } from './types';
25+
import { DeviceType } from '../../../../utils/device/parseUserAgent';
2526

2627
interface Props {
27-
isVerified?: DeviceWithVerification['isVerified'];
28+
isVerified?: ExtendedDevice['isVerified'];
2829
isSelected?: boolean;
30+
deviceType?: DeviceType;
2931
}
3032

31-
export const DeviceType: React.FC<Props> = ({ isVerified, isSelected }) => (
32-
<div className={classNames('mx_DeviceType', {
33-
mx_DeviceType_selected: isSelected,
33+
export const DeviceTypeIcon: React.FC<Props> = ({
34+
isVerified,
35+
isSelected,
36+
deviceType,
37+
}) => (
38+
<div className={classNames('mx_DeviceTypeIcon', {
39+
mx_DeviceTypeIcon_selected: isSelected,
3440
})}
3541
>
3642
{ /* TODO(kerrya) all devices have an unknown type until PSG-650 */ }
3743
<UnknownDeviceIcon
38-
className='mx_DeviceType_deviceIcon'
44+
className='mx_DeviceTypeIcon_deviceIcon'
3945
role='img'
4046
aria-label={_t('Unknown device type')}
4147
/>
4248
{
4349
isVerified
4450
? <VerifiedIcon
45-
className={classNames('mx_DeviceType_verificationIcon', 'verified')}
51+
className={classNames('mx_DeviceTypeIcon_verificationIcon', 'verified')}
4652
role='img'
4753
aria-label={_t('Verified')}
4854
/>
4955
: <UnverifiedIcon
50-
className={classNames('mx_DeviceType_verificationIcon', 'unverified')}
56+
className={classNames('mx_DeviceTypeIcon_verificationIcon', 'unverified')}
5157
role='img'
5258
aria-label={_t('Unverified')}
5359
/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import AccessibleButton from '../../elements/AccessibleButton';
2121
import DeviceSecurityCard from './DeviceSecurityCard';
2222
import {
2323
DeviceSecurityVariation,
24-
DeviceWithVerification,
24+
ExtendedDevice,
2525
} from './types';
2626

2727
interface Props {
28-
device: DeviceWithVerification;
28+
device: ExtendedDevice;
2929
onVerifyDevice?: () => void;
3030
}
3131

0 commit comments

Comments
 (0)