diff --git a/packages/dashboard/lib/pages/function/FunctionSettings.tsx b/packages/dashboard/lib/pages/function/FunctionSettings.tsx index a4fa5821..bf0ba2a8 100644 --- a/packages/dashboard/lib/pages/function/FunctionSettings.tsx +++ b/packages/dashboard/lib/pages/function/FunctionSettings.tsx @@ -390,22 +390,30 @@ const FunctionSettings = ({ func, refetch }: FunctionSettingsProps) => { initialValues={{ env: func?.env || {}, }} - onSubmit={async ({ env }) => { + onSubmit={async ({ env, envKey, envValue }) => { if (!func) { return; } + const newEnv = Object.entries(env).reduce( + (acc, [key, value]) => [...acc, { key, value }], + [] as { key: string; value: string }[], + ); + + if (envKey && envValue) { + newEnv.push({ key: envKey, value: envValue }); + } + await updateFunction.mutateAsync({ functionId: func.id, - env: Object.entries(env).reduce( - (acc, [key, value]) => [...acc, { key, value }], - [] as { key: string; value: string }[], - ), + env: newEnv, }); }} - onSubmitSuccess={async () => { + onSubmitSuccess={async (_, form) => { toast.success('Function environment variables updated successfully.'); await refetch(); + form.change('envKey', ''); + form.change('envValue', ''); }} > {({ values, form }) => ( @@ -421,6 +429,29 @@ const FunctionSettings = ({ func, refetch }: FunctionSettingsProps) => { } >
+ {Object.entries(values.env).map(([key, value], index) => { + return ( +
+ + + +
+ ); + })}
{ {t('env.add')}
- {Object.entries(values.env).map(([key, value], index) => { - return ( -
- - - -
- ); - })}