mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 18:00:20 -04:00
70c4659452
## What kind of change does this PR introduce? Chore that references DEPR-394. ## What is the current behavior? This stack is consolidating RHF key/value array UIs in smaller reviewable steps. After PR 1, Database Webhooks HTTP parameters and Database Functions configuration parameters still use separate bespoke implementations. ## What is the new behavior? - reuses the shared `KeyValueFieldArray` for Database Webhooks HTTP parameters - reuses the shared `KeyValueFieldArray` for Database Functions configuration parameters - keeps existing form shapes and submission logic intact - adds focused tests for those two follow-up consumers ## Additional context This is PR 2 of a 3-PR stack for DEPR-394. Base PR: #43938
29 lines
907 B
TypeScript
29 lines
907 B
TypeScript
import { useFormContext } from 'react-hook-form'
|
|
import { KeyValueFieldArray } from 'ui-patterns/form/KeyValueFieldArray/KeyValueFieldArray'
|
|
|
|
type CreateFunctionConfigParamsFormValues = {
|
|
config_params: Array<{ name: string; value: string }>
|
|
}
|
|
|
|
export const CreateFunctionConfigParamsSection = () => {
|
|
const form = useFormContext<CreateFunctionConfigParamsFormValues>()
|
|
|
|
return (
|
|
<>
|
|
<h5 className="text-base text-foreground">Configuration Parameters</h5>
|
|
<KeyValueFieldArray
|
|
control={form.control}
|
|
name="config_params"
|
|
keyFieldName="name"
|
|
valueFieldName="value"
|
|
createEmptyRow={() => ({ name: '', value: '' })}
|
|
keyPlaceholder="parameter_name"
|
|
valuePlaceholder="parameter_value"
|
|
addLabel="Add a new config"
|
|
removeLabel="Remove configuration parameter"
|
|
rowsClassName="space-y-2 pt-4"
|
|
/>
|
|
</>
|
|
)
|
|
}
|