Files
supabase/apps/studio/components/interfaces/Database/Functions/CreateFunction/CreateFunctionConfigParamsSection.tsx
Danny White 70c4659452 chore(studio): reuse key-value field array for params (#44058)
## 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
2026-03-25 11:39:36 +11:00

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"
/>
</>
)
}