fix(editor): 🐛 FIx Webhook settings debounce
This commit is contained in:
@@ -10,14 +10,16 @@ import { useDebouncedCallback } from 'use-debounce'
|
|||||||
type Props = {
|
type Props = {
|
||||||
value: string
|
value: string
|
||||||
lang?: 'css' | 'json' | 'js' | 'html'
|
lang?: 'css' | 'json' | 'js' | 'html'
|
||||||
onChange?: (value: string) => void
|
|
||||||
isReadOnly?: boolean
|
isReadOnly?: boolean
|
||||||
|
debounceTimeout?: number
|
||||||
|
onChange?: (value: string) => void
|
||||||
}
|
}
|
||||||
export const CodeEditor = ({
|
export const CodeEditor = ({
|
||||||
value,
|
value,
|
||||||
lang,
|
lang,
|
||||||
onChange,
|
onChange,
|
||||||
isReadOnly = false,
|
isReadOnly = false,
|
||||||
|
debounceTimeout = 1000,
|
||||||
...props
|
...props
|
||||||
}: Props & Omit<BoxProps, 'onChange'>) => {
|
}: Props & Omit<BoxProps, 'onChange'>) => {
|
||||||
const editorContainer = useRef<HTMLDivElement | null>(null)
|
const editorContainer = useRef<HTMLDivElement | null>(null)
|
||||||
@@ -28,7 +30,7 @@ export const CodeEditor = ({
|
|||||||
setPlainTextValue(value)
|
setPlainTextValue(value)
|
||||||
onChange && onChange(value)
|
onChange && onChange(value)
|
||||||
},
|
},
|
||||||
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : 1000
|
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : debounceTimeout
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const KeyValueInputs = ({
|
|||||||
onItemChange,
|
onItemChange,
|
||||||
keyPlaceholder,
|
keyPlaceholder,
|
||||||
valuePlaceholder,
|
valuePlaceholder,
|
||||||
|
debounceTimeout,
|
||||||
}: TableListItemProps<KeyValue> & {
|
}: TableListItemProps<KeyValue> & {
|
||||||
keyPlaceholder?: string
|
keyPlaceholder?: string
|
||||||
valuePlaceholder?: string
|
valuePlaceholder?: string
|
||||||
@@ -45,6 +46,7 @@ export const KeyValueInputs = ({
|
|||||||
defaultValue={item.key ?? ''}
|
defaultValue={item.key ?? ''}
|
||||||
onChange={handleKeyChange}
|
onChange={handleKeyChange}
|
||||||
placeholder={keyPlaceholder}
|
placeholder={keyPlaceholder}
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
@@ -54,6 +56,7 @@ export const KeyValueInputs = ({
|
|||||||
defaultValue={item.value ?? ''}
|
defaultValue={item.value ?? ''}
|
||||||
onChange={handleValueChange}
|
onChange={handleValueChange}
|
||||||
placeholder={valuePlaceholder}
|
placeholder={valuePlaceholder}
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export const DataVariableInputs = ({
|
|||||||
item,
|
item,
|
||||||
onItemChange,
|
onItemChange,
|
||||||
dataItems,
|
dataItems,
|
||||||
|
debounceTimeout,
|
||||||
}: TableListItemProps<ResponseVariableMapping> & { dataItems: string[] }) => {
|
}: TableListItemProps<ResponseVariableMapping> & { dataItems: string[] }) => {
|
||||||
const handleBodyPathChange = (bodyPath: string) =>
|
const handleBodyPathChange = (bodyPath: string) =>
|
||||||
onItemChange({ ...item, bodyPath })
|
onItemChange({ ...item, bodyPath })
|
||||||
@@ -23,6 +24,7 @@ export const DataVariableInputs = ({
|
|||||||
value={item.bodyPath}
|
value={item.bodyPath}
|
||||||
onValueChange={handleBodyPathChange}
|
onValueChange={handleBodyPathChange}
|
||||||
placeholder="Select the data"
|
placeholder="Select the data"
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
@@ -31,6 +33,7 @@ export const DataVariableInputs = ({
|
|||||||
onSelectVariable={handleVariableChange}
|
onSelectVariable={handleVariableChange}
|
||||||
placeholder="Search for a variable"
|
placeholder="Search for a variable"
|
||||||
initialVariableId={item.variableId}
|
initialVariableId={item.variableId}
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { VariableForTest, Variable } from 'models'
|
|||||||
export const VariableForTestInputs = ({
|
export const VariableForTestInputs = ({
|
||||||
item,
|
item,
|
||||||
onItemChange,
|
onItemChange,
|
||||||
|
debounceTimeout,
|
||||||
}: TableListItemProps<VariableForTest>) => {
|
}: TableListItemProps<VariableForTest>) => {
|
||||||
const handleVariableSelect = (variable?: Variable) =>
|
const handleVariableSelect = (variable?: Variable) =>
|
||||||
onItemChange({ ...item, variableId: variable?.id })
|
onItemChange({ ...item, variableId: variable?.id })
|
||||||
@@ -22,6 +23,7 @@ export const VariableForTestInputs = ({
|
|||||||
id={'name' + item.id}
|
id={'name' + item.id}
|
||||||
initialVariableId={item.variableId}
|
initialVariableId={item.variableId}
|
||||||
onSelectVariable={handleVariableSelect}
|
onSelectVariable={handleVariableSelect}
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
@@ -30,6 +32,7 @@ export const VariableForTestInputs = ({
|
|||||||
id={'value' + item.id}
|
id={'value' + item.id}
|
||||||
defaultValue={item.value ?? ''}
|
defaultValue={item.value ?? ''}
|
||||||
onChange={handleValueChange}
|
onChange={handleValueChange}
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export const WebhookSettings = ({
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
setLocalWebhook((localWebhook) => {
|
setLocalWebhook((localWebhook) => {
|
||||||
|
console.log(localWebhook)
|
||||||
if (!localWebhook) return
|
if (!localWebhook) return
|
||||||
updateWebhook(webhookId, localWebhook).then()
|
updateWebhook(webhookId, localWebhook).then()
|
||||||
return localWebhook
|
return localWebhook
|
||||||
@@ -148,6 +149,7 @@ export const WebhookSettings = ({
|
|||||||
placeholder="Your Webhook URL..."
|
placeholder="Your Webhook URL..."
|
||||||
defaultValue={localWebhook.url ?? ''}
|
defaultValue={localWebhook.url ?? ''}
|
||||||
onChange={handleUrlChange}
|
onChange={handleUrlChange}
|
||||||
|
debounceTimeout={0}
|
||||||
/>
|
/>
|
||||||
<SwitchWithLabel
|
<SwitchWithLabel
|
||||||
id={'easy-config'}
|
id={'easy-config'}
|
||||||
@@ -177,6 +179,7 @@ export const WebhookSettings = ({
|
|||||||
onItemsChange={handleQueryParamsChange}
|
onItemsChange={handleQueryParamsChange}
|
||||||
Item={QueryParamsInputs}
|
Item={QueryParamsInputs}
|
||||||
addLabel="Add a param"
|
addLabel="Add a param"
|
||||||
|
debounceTimeout={0}
|
||||||
/>
|
/>
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
@@ -191,6 +194,7 @@ export const WebhookSettings = ({
|
|||||||
onItemsChange={handleHeadersChange}
|
onItemsChange={handleHeadersChange}
|
||||||
Item={HeadersInputs}
|
Item={HeadersInputs}
|
||||||
addLabel="Add a value"
|
addLabel="Add a value"
|
||||||
|
debounceTimeout={0}
|
||||||
/>
|
/>
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
@@ -211,6 +215,7 @@ export const WebhookSettings = ({
|
|||||||
value={localWebhook.body ?? ''}
|
value={localWebhook.body ?? ''}
|
||||||
lang="json"
|
lang="json"
|
||||||
onChange={handleBodyChange}
|
onChange={handleBodyChange}
|
||||||
|
debounceTimeout={0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
@@ -228,6 +233,7 @@ export const WebhookSettings = ({
|
|||||||
onItemsChange={handleVariablesChange}
|
onItemsChange={handleVariablesChange}
|
||||||
Item={VariableForTestInputs}
|
Item={VariableForTestInputs}
|
||||||
addLabel="Add an entry"
|
addLabel="Add an entry"
|
||||||
|
debounceTimeout={0}
|
||||||
/>
|
/>
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
@@ -258,6 +264,7 @@ export const WebhookSettings = ({
|
|||||||
onItemsChange={handleResponseMappingChange}
|
onItemsChange={handleResponseMappingChange}
|
||||||
Item={ResponseMappingInputs}
|
Item={ResponseMappingInputs}
|
||||||
addLabel="Add an entry"
|
addLabel="Add an entry"
|
||||||
|
debounceTimeout={0}
|
||||||
/>
|
/>
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
|
|||||||
@@ -15,12 +15,14 @@ import { useDebounce } from 'use-debounce'
|
|||||||
type Props = {
|
type Props = {
|
||||||
selectedItem?: string
|
selectedItem?: string
|
||||||
items: string[]
|
items: string[]
|
||||||
|
debounceTimeout?: number
|
||||||
onValueChange?: (value: string) => void
|
onValueChange?: (value: string) => void
|
||||||
} & InputProps
|
} & InputProps
|
||||||
|
|
||||||
export const SearchableDropdown = ({
|
export const SearchableDropdown = ({
|
||||||
selectedItem,
|
selectedItem,
|
||||||
items,
|
items,
|
||||||
|
debounceTimeout = 1000,
|
||||||
onValueChange,
|
onValueChange,
|
||||||
...inputProps
|
...inputProps
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
@@ -28,7 +30,7 @@ export const SearchableDropdown = ({
|
|||||||
const [inputValue, setInputValue] = useState(selectedItem ?? '')
|
const [inputValue, setInputValue] = useState(selectedItem ?? '')
|
||||||
const [debouncedInputValue] = useDebounce(
|
const [debouncedInputValue] = useDebounce(
|
||||||
inputValue,
|
inputValue,
|
||||||
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : 1000
|
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : debounceTimeout
|
||||||
)
|
)
|
||||||
const [filteredItems, setFilteredItems] = useState([
|
const [filteredItems, setFilteredItems] = useState([
|
||||||
...items
|
...items
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import { useDebounce } from 'use-debounce'
|
|||||||
export const SmartNumberInput = ({
|
export const SmartNumberInput = ({
|
||||||
value,
|
value,
|
||||||
onValueChange,
|
onValueChange,
|
||||||
|
debounceTimeout = 1000,
|
||||||
...props
|
...props
|
||||||
}: {
|
}: {
|
||||||
value?: number
|
value?: number
|
||||||
|
debounceTimeout?: number
|
||||||
onValueChange: (value?: number) => void
|
onValueChange: (value?: number) => void
|
||||||
} & NumberInputProps) => {
|
} & NumberInputProps) => {
|
||||||
const [currentValue, setCurrentValue] = useState(value?.toString() ?? '')
|
const [currentValue, setCurrentValue] = useState(value?.toString() ?? '')
|
||||||
@@ -23,7 +25,7 @@ export const SmartNumberInput = ({
|
|||||||
)
|
)
|
||||||
const [debouncedValue] = useDebounce(
|
const [debouncedValue] = useDebounce(
|
||||||
valueToReturn,
|
valueToReturn,
|
||||||
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : 1000
|
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : debounceTimeout
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ type ItemWithId<T> = T & { id: string }
|
|||||||
|
|
||||||
export type TableListItemProps<T> = {
|
export type TableListItemProps<T> = {
|
||||||
item: T
|
item: T
|
||||||
|
debounceTimeout?: number
|
||||||
onItemChange: (item: T) => void
|
onItemChange: (item: T) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props<T> = {
|
type Props<T> = {
|
||||||
initialItems: ItemWithId<T>[]
|
initialItems: ItemWithId<T>[]
|
||||||
onItemsChange: (items: ItemWithId<T>[]) => void
|
|
||||||
addLabel?: string
|
addLabel?: string
|
||||||
|
debounceTimeout?: number
|
||||||
|
onItemsChange: (items: ItemWithId<T>[]) => void
|
||||||
Item: (props: TableListItemProps<T>) => JSX.Element
|
Item: (props: TableListItemProps<T>) => JSX.Element
|
||||||
ComponentBetweenItems?: (props: unknown) => JSX.Element
|
ComponentBetweenItems?: (props: unknown) => JSX.Element
|
||||||
}
|
}
|
||||||
@@ -25,6 +27,7 @@ export const TableList = <T,>({
|
|||||||
initialItems,
|
initialItems,
|
||||||
onItemsChange,
|
onItemsChange,
|
||||||
addLabel = 'Add',
|
addLabel = 'Add',
|
||||||
|
debounceTimeout,
|
||||||
Item,
|
Item,
|
||||||
ComponentBetweenItems = () => <></>,
|
ComponentBetweenItems = () => <></>,
|
||||||
}: Props<T>) => {
|
}: Props<T>) => {
|
||||||
@@ -75,7 +78,11 @@ export const TableList = <T,>({
|
|||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
mt={itemIndex !== 0 && ComponentBetweenItems ? 4 : 0}
|
mt={itemIndex !== 0 && ComponentBetweenItems ? 4 : 0}
|
||||||
>
|
>
|
||||||
<Item item={item} onItemChange={handleCellChange(itemIndex)} />
|
<Item
|
||||||
|
item={item}
|
||||||
|
onItemChange={handleCellChange(itemIndex)}
|
||||||
|
debounceTimeout={debounceTimeout}
|
||||||
|
/>
|
||||||
<Fade in={showDeleteIndex === itemIndex}>
|
<Fade in={showDeleteIndex === itemIndex}>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<TrashIcon />}
|
icon={<TrashIcon />}
|
||||||
|
|||||||
@@ -22,12 +22,14 @@ export type TextBoxProps = {
|
|||||||
| ComponentWithAs<'textarea', TextareaProps>
|
| ComponentWithAs<'textarea', TextareaProps>
|
||||||
| ComponentWithAs<'input', InputProps>
|
| ComponentWithAs<'input', InputProps>
|
||||||
withVariableButton?: boolean
|
withVariableButton?: boolean
|
||||||
|
debounceTimeout?: number
|
||||||
} & Omit<InputProps & TextareaProps, 'onChange'>
|
} & Omit<InputProps & TextareaProps, 'onChange'>
|
||||||
|
|
||||||
export const TextBox = ({
|
export const TextBox = ({
|
||||||
onChange,
|
onChange,
|
||||||
TextBox,
|
TextBox,
|
||||||
withVariableButton = true,
|
withVariableButton = true,
|
||||||
|
debounceTimeout = 1000,
|
||||||
...props
|
...props
|
||||||
}: TextBoxProps) => {
|
}: TextBoxProps) => {
|
||||||
const textBoxRef = useRef<(HTMLInputElement & HTMLTextAreaElement) | null>(
|
const textBoxRef = useRef<(HTMLInputElement & HTMLTextAreaElement) | null>(
|
||||||
@@ -39,7 +41,7 @@ export const TextBox = ({
|
|||||||
(value) => {
|
(value) => {
|
||||||
onChange(value)
|
onChange(value)
|
||||||
},
|
},
|
||||||
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : 1000
|
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : debounceTimeout
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
|
|||||||
@@ -224,12 +224,14 @@ const CollaborationTypeMenuButton = ({
|
|||||||
{convertCollaborationTypeEnumToReadable(type)}
|
{convertCollaborationTypeEnumToReadable(type)}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuList minW={0}>
|
<MenuList minW={0}>
|
||||||
|
<Stack maxH={'35vh'} overflowY="scroll" spacing="0">
|
||||||
<MenuItem onClick={() => onChange(CollaborationType.READ)}>
|
<MenuItem onClick={() => onChange(CollaborationType.READ)}>
|
||||||
{convertCollaborationTypeEnumToReadable(CollaborationType.READ)}
|
{convertCollaborationTypeEnumToReadable(CollaborationType.READ)}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem onClick={() => onChange(CollaborationType.WRITE)}>
|
<MenuItem onClick={() => onChange(CollaborationType.WRITE)}>
|
||||||
{convertCollaborationTypeEnumToReadable(CollaborationType.WRITE)}
|
{convertCollaborationTypeEnumToReadable(CollaborationType.WRITE)}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
</Stack>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,16 +20,18 @@ import { byId, isNotDefined } from 'utils'
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
initialVariableId?: string
|
initialVariableId?: string
|
||||||
|
debounceTimeout?: number
|
||||||
|
isDefaultOpen?: boolean
|
||||||
onSelectVariable: (
|
onSelectVariable: (
|
||||||
variable: Pick<Variable, 'id' | 'name'> | undefined
|
variable: Pick<Variable, 'id' | 'name'> | undefined
|
||||||
) => void
|
) => void
|
||||||
isDefaultOpen?: boolean
|
|
||||||
} & InputProps
|
} & InputProps
|
||||||
|
|
||||||
export const VariableSearchInput = ({
|
export const VariableSearchInput = ({
|
||||||
initialVariableId,
|
initialVariableId,
|
||||||
onSelectVariable,
|
onSelectVariable,
|
||||||
isDefaultOpen,
|
isDefaultOpen,
|
||||||
|
debounceTimeout = 1000,
|
||||||
...inputProps
|
...inputProps
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { onOpen, onClose, isOpen } = useDisclosure()
|
const { onOpen, onClose, isOpen } = useDisclosure()
|
||||||
@@ -40,7 +42,7 @@ export const VariableSearchInput = ({
|
|||||||
)
|
)
|
||||||
const [debouncedInputValue] = useDebounce(
|
const [debouncedInputValue] = useDebounce(
|
||||||
inputValue,
|
inputValue,
|
||||||
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : 1000
|
process.env.NEXT_PUBLIC_E2E_TEST ? 0 : debounceTimeout
|
||||||
)
|
)
|
||||||
const [filteredItems, setFilteredItems] = useState<Variable[]>(
|
const [filteredItems, setFilteredItems] = useState<Variable[]>(
|
||||||
variables ?? []
|
variables ?? []
|
||||||
|
|||||||
Reference in New Issue
Block a user