-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74ff3f8
commit c8a7263
Showing
16 changed files
with
143 additions
and
74 deletions.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@msw-devtools/extension': patch | ||
'@msw-devtools/core': patch | ||
--- | ||
|
||
Passthrough support |
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.
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
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
87 changes: 49 additions & 38 deletions
87
packages/extension/src/popup/ConfigListButtons/ConfigListButtons.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 |
---|---|---|
@@ -1,55 +1,66 @@ | ||
import React, { FC } from 'react' | ||
import { clsx } from 'clsx' | ||
|
||
import { | ||
BackgroundResponseMessage, | ||
LocalStorageConfigKey, | ||
MessageType | ||
} from '@msw-devtools/core' | ||
import { BackgroundResponseMessage, MessageType } from '@msw-devtools/core' | ||
|
||
import TrashIcon from './trash.svg' | ||
import PausedIcon from './pause.svg' | ||
import PlayIcon from './play.svg' | ||
|
||
import styles from './ConfigListButtons.module.css' | ||
|
||
type ConfigNames = Extract< | ||
BackgroundResponseMessage, | ||
{ type: MessageType.Status; payload: any } | ||
>['payload']['configNames'] | ||
|
||
export const ConfigListButtons: FC<{ | ||
list?: Extract< | ||
BackgroundResponseMessage, | ||
{ type: MessageType.Status; payload: any } | ||
>['payload']['configNames'] | ||
activeKey?: LocalStorageConfigKey | ||
onRemove: (key: LocalStorageConfigKey) => void | ||
onSetActive: (key: LocalStorageConfigKey) => void | ||
list?: ConfigNames | ||
activeKey?: ConfigNames[0]['key'] | ||
onRemove: (key: ConfigNames[0]['key']) => void | ||
onSetActive: (key: ConfigNames[0]['key']) => void | ||
}> = ({ list, onSetActive, activeKey, onRemove }) => { | ||
if (!list) return | ||
|
||
const listEntries = Object.entries(list) | ||
if (!listEntries.length) return | ||
if (!list?.length) return | ||
|
||
return ( | ||
<div className={styles.wrapper}> | ||
{listEntries.map(([name, { key }], index) => ( | ||
<div | ||
className={clsx(styles.item, { | ||
[styles.active]: key === activeKey | ||
})} | ||
key={key} | ||
> | ||
<button | ||
onClick={() => onSetActive(key)} | ||
title="Click to chose" | ||
className={styles.button} | ||
> | ||
{name} | ||
</button> | ||
<button | ||
onClick={() => onRemove(key)} | ||
title="Click to remove" | ||
className={styles.button} | ||
{list.map(({ name, key, passthrough }) => { | ||
const isActive = key === activeKey || (passthrough && !activeKey) | ||
|
||
return ( | ||
<div | ||
className={clsx(styles.item, { | ||
[styles.active]: isActive | ||
})} | ||
key={key} | ||
> | ||
<TrashIcon /> | ||
</button> | ||
</div> | ||
))} | ||
<button | ||
onClick={() => onSetActive(key)} | ||
title="Click to chose" | ||
className={styles.button} | ||
> | ||
{name} | ||
</button> | ||
<button | ||
onClick={() => { | ||
onRemove(key) | ||
}} | ||
disabled={passthrough && !isActive} | ||
className={styles.button} | ||
> | ||
{passthrough ? ( | ||
isActive ? ( | ||
<PlayIcon fill="#fff" width={14} height={14} /> | ||
) : ( | ||
<PausedIcon fill="#fff" width={14} height={14} /> | ||
) | ||
) : ( | ||
<TrashIcon fill="#fff" width={14} height={14} /> | ||
)} | ||
</button> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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