-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
edit duplicate variable name #1354
Draft
natalievalcin
wants to merge
3
commits into
responsively-org:main
Choose a base branch
from
natalievalcin:feature/filter-devices-1327
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,15 @@ import { | |
import { APP_VIEWS, setAppView } from 'renderer/store/features/ui'; | ||
import { defaultDevices, Device, getDevicesMap } from 'common/deviceList'; | ||
|
||
import cx from 'classnames'; | ||
import Button from '../Button'; | ||
import DeviceLabel from './DeviceLabel'; | ||
import DeviceDetailsModal from './DeviceDetailsModal'; | ||
import { PreviewSuites } from './PreviewSuites'; | ||
import { ManageSuitesTool } from './PreviewSuites/ManageSuitesTool/ManageSuitesTool'; | ||
import { Divider } from '../Divider'; | ||
import { AccordionItem, Accordion } from '../Accordion'; | ||
import { DropDown } from '../DropDown'; | ||
|
||
const filterDevices = (devices: Device[], filter: string) => { | ||
const sanitizedFilter = filter.trim().toLowerCase(); | ||
|
@@ -38,18 +40,28 @@ const DeviceManager = () => { | |
const activeSuite = useSelector(selectActiveSuite); | ||
const devices = activeSuite.devices?.map((id) => getDevicesMap()[id]); | ||
const [searchText, setSearchText] = useState<string>(''); | ||
const [filteredType, setFilteredType] = useState<string | null>(null); | ||
const [filteredDevices, setFilteredDevices] = | ||
useState<Device[]>(defaultDevices); | ||
const [customDevices, setCustomDevices] = useState<Device[]>( | ||
window.electron.store.get('deviceManager.customDevices') | ||
); | ||
const [filteredCustomDevices, setFilteredCustomDevices] = | ||
useState<Device[]>(customDevices); | ||
const deviceTypes = Array.from( | ||
new Set(defaultDevices.map((device) => device.type)) | ||
); | ||
|
||
useEffect(() => { | ||
setFilteredDevices(filterDevices(defaultDevices, searchText)); | ||
setFilteredCustomDevices(filterDevices(customDevices, searchText)); | ||
}, [customDevices, searchText]); | ||
const filtered = filterDevices(defaultDevices, searchText).filter( | ||
(device) => (filteredType ? device.type === filteredType : true) | ||
); | ||
const filteredCustom = filterDevices(customDevices, searchText).filter( | ||
(device) => (filteredType ? device.type === filteredType : true) | ||
); | ||
setFilteredDevices(filtered); | ||
setFilteredCustomDevices(filteredCustom); | ||
}, [customDevices, searchText, filteredType]); | ||
|
||
const saveCustomDevices = (newCustomDevices: Device[]) => { | ||
setCustomDevices(newCustomDevices); | ||
|
@@ -111,6 +123,50 @@ const DeviceManager = () => { | |
<div className="flex w-fit flex-col items-start px-1"> | ||
<h2 className="text-2xl font-bold">Manage Devices</h2> | ||
</div> | ||
<div> | ||
<DropDown | ||
label={ | ||
<div className="flex items-center gap-2"> | ||
<Icon icon="mdi:devices" fontSize={18} /> | ||
<span>Device Type</span> | ||
</div> | ||
} | ||
options={[ | ||
{ | ||
label: ( | ||
<div className="flex items-center gap-2"> | ||
{filteredType === null && <Icon icon="mdi:check" />} | ||
<span | ||
className={cx('capitalize', { | ||
'font-semibold text-black dark:text-white': | ||
filteredType === null, | ||
})} | ||
> | ||
All Device Types | ||
</span> | ||
</div> | ||
), | ||
onClick: () => setFilteredType(null), | ||
}, | ||
...deviceTypes.map((type) => ({ | ||
label: ( | ||
<div className="flex items-center gap-2"> | ||
{filteredType === type && <Icon icon="mdi:check" />} | ||
<span | ||
className={cx('capitalize', { | ||
'font-semibold text-black dark:text-white': | ||
filteredType === type, | ||
})} | ||
> | ||
{type} | ||
</span> | ||
</div> | ||
), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as the lines 137 to 147, please refactor into a reusable separate component. You could call it DeviceManagerLabel if you'd like, and pass props to it to handle variations |
||
onClick: () => setFilteredType(type), | ||
})), | ||
]} | ||
/> | ||
</div> | ||
<div className="flex w-fit items-center bg-white px-1 dark:bg-slate-900"> | ||
<Icon icon="ic:outline-search" height={24} /> | ||
<input | ||
|
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.
thanks for the PR, please follow the following structure:
export { DeviceManager } from './DeviceManager
-> this acts as a export hub for anything you need to export