This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 829
Device manager - device type and verification icons on device tile (PSG-637) #9197
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
01f2643
add unknown device icon
822be8f
add device type and verification icon component
17aefa3
test
08a1572
stylelint
9f32612
Merge branch 'develop' into psg-637/device-icon
80d84b7
fix securitycard spacing
543473b
Merge branch 'psg-637/device-icon' of https://github.com/matrix-org/m…
2c4a142
Merge branch 'develop' into psg-637/device-icon
turt2live efb4bd3
Merge branch 'develop' into psg-637/device-icon
0b5077a
fix strict ts error
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
res/css/components/views/settings/devices/_DeviceType.pcss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test/components/views/settings/devices/DeviceType-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
DevicesPanel
will be retired after the new device manager reaches feature parity, so allow this hack