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

Commit

Permalink
rename to filtered device list
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Archibald committed Aug 9, 2022
1 parent 4c02d35 commit 707076b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion res/css/_components.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@import "./components/views/messages/_MBeaconBody.pcss";
@import "./components/views/messages/shared/_MediaProcessingError.pcss";
@import "./components/views/settings/devices/_DeviceTile.pcss";
@import "./components/views/settings/devices/_SortedDeviceList.pcss";
@import "./components/views/settings/devices/_FilteredDeviceList.pcss";
@import "./components/views/settings/shared/_SettingsSubsection.pcss";
@import "./components/views/spaces/_QuickThemeSwitcher.pcss";
@import "./structures/_AutoHideScrollbar.pcss";
Expand Down
1 change: 0 additions & 1 deletion res/css/components/views/settings/devices/_DeviceTile.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ limitations under the License.
display: flex;
flex-direction: row;
align-items: center;
padding: 0 $spacing-8;

width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_SortedDeviceList {
.mx_FilteredDeviceList {
list-style-type: none;
display: grid;
grid-gap: $spacing-16;
margin: 0;
padding: 0;
padding: 0 $spacing-8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ const sortDevicesByLatestActivity = (left: DeviceWithVerification, right: Device
const getSortedDeviceIds = (devices: DevicesDictionary) =>
Object.values(devices).sort(sortDevicesByLatestActivity).map(device => device.device_id);

const SortedDeviceList: React.FC<Props> = ({ devices }) => {
const FilteredDeviceList: React.FC<Props> = ({ devices }) => {
const [sortedIds, setSortedIds] = useState([]);

useEffect(() => {
setSortedIds(getSortedDeviceIds(devices));
}, [devices]);

return <ol className='mx_SortedDeviceList'>
return <ol className='mx_FilteredDeviceList'>
{ sortedIds.map((deviceId) =>
<li key={deviceId}>

Expand All @@ -54,4 +54,4 @@ const SortedDeviceList: React.FC<Props> = ({ devices }) => {
</ol>;
};

export default SortedDeviceList;
export default FilteredDeviceList;
4 changes: 2 additions & 2 deletions src/components/views/settings/tabs/user/SessionManagerTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useOwnDevices } from '../../devices/useOwnDevices';
import DeviceTile from '../../devices/DeviceTile';
import SettingsSubsection from '../../shared/SettingsSubsection';
import SettingsTab from '../SettingsTab';
import SortedDeviceList, { DeviceSortOrder } from '../../devices/SortedDeviceList';
import FilteredDeviceList, { DeviceSortOrder } from '../../devices/FilteredDeviceList';

const SessionManagerTab: React.FC = () => {
const { devices, currentDeviceId, isLoading } = useOwnDevices();
Expand All @@ -49,7 +49,7 @@ const SessionManagerTab: React.FC = () => {
`from any session that you don't recognize or use anymore.`
)}
>
<SortedDeviceList devices={devices} sortOrder={DeviceSortOrder.LatestActivity} />
<FilteredDeviceList devices={devices} sortOrder={DeviceSortOrder.LatestActivity} />
</SettingsSubsection>
}
</SettingsTab>;
Expand Down
31 changes: 31 additions & 0 deletions test/components/views/settings/devices/FilteredDeviceList-test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
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 { mount } from 'enzyme';

import FilteredDeviceList from '../../../../../src/components/views/settings/devices/FilteredDeviceList';

describe('<FilteredDeviceList />', () => {
const defaultProps = {};
const getComponent = (props = {}) =>
mount(<FilteredDeviceList {...defaultProps} {...props} />);

it('renders', () => {
const component = getComponent();
expect(component).toBeTruthy();
});
});
16 changes: 0 additions & 16 deletions test/components/views/settings/devices/SortedDeviceList-test.tsx

This file was deleted.

0 comments on commit 707076b

Please sign in to comment.