diff --git a/web/app/components/base/form/components/base/base-form.tsx b/web/app/components/base/form/components/base/base-form.tsx
index 3fee80bac1..6911e4d95f 100644
--- a/web/app/components/base/form/components/base/base-form.tsx
+++ b/web/app/components/base/form/components/base/base-form.tsx
@@ -70,25 +70,33 @@ const BaseForm = ({
return null
}, [formSchemas, fieldClassName, labelClassName, inputContainerClassName, inputClassName, disabled])
+ const renderFieldWrapper = useCallback((formSchema: FormSchema) => {
+ const {
+ name,
+ } = formSchema
+
+ return (
+
+ {renderField}
+
+ )
+ }, [renderField, form])
+
if (!formSchemas?.length)
return null
return (
- {renderField}
-
- )
- })
- }
+ {formSchemas.map(renderFieldWrapper)}
)
}
diff --git a/web/app/components/base/form/types.ts b/web/app/components/base/form/types.ts
index 9255181518..02a93c3285 100644
--- a/web/app/components/base/form/types.ts
+++ b/web/app/components/base/form/types.ts
@@ -2,7 +2,10 @@ import type {
ForwardedRef,
ReactNode,
} from 'react'
-import type { AnyFormApi } from '@tanstack/react-form'
+import type {
+ AnyFormApi,
+ FieldValidators,
+} from '@tanstack/react-form'
export type TypeWithI18N = {
en_US: T
@@ -52,6 +55,7 @@ export type FormSchema = {
placeholder?: string | TypeWithI18N
options?: FormOption[]
labelClassName?: string
+ validators?: FieldValidators
}
export type FormValues = Record
diff --git a/web/app/components/plugins/plugin-auth/authorize/add-oauth-button.tsx b/web/app/components/plugins/plugin-auth/authorize/add-oauth-button.tsx
index 1372a3a5a8..8e6fc5aa03 100644
--- a/web/app/components/plugins/plugin-auth/authorize/add-oauth-button.tsx
+++ b/web/app/components/plugins/plugin-auth/authorize/add-oauth-button.tsx
@@ -217,6 +217,7 @@ const AddOAuthButton = ({
disabled={disabled}
schemas={memorizedSchemas}
onAuth={handleOAuth}
+ editValues={client_params}
/>
)
}
diff --git a/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx b/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx
index c29e984ae4..5e7f8a7adb 100644
--- a/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx
+++ b/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx
@@ -72,13 +72,21 @@ const ApiKeyModal = ({
...values
} = store?.state.values
const isPristineSecretInputNames: string[] = []
- formSchemas.forEach((schema) => {
+ for (let i = 0; i < formSchemas.length; i++) {
+ const schema = formSchemas[i]
+ if (schema.required && !values[schema.name]) {
+ notify({
+ type: 'error',
+ message: t('common.errorMsg.fieldRequired', { field: schema.name }),
+ })
+ return
+ }
if (schema.type === FormTypeEnum.secretInput) {
const fieldMeta = form?.getFieldMeta(schema.name)
if (fieldMeta?.isPristine)
isPristineSecretInputNames.push(schema.name)
}
- })
+ }
const transformedValues = transformFormSchemasSecretInput(isPristineSecretInputNames, values)
diff --git a/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx b/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx
index aa9722a1c5..7752d584fb 100644
--- a/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx
+++ b/web/app/components/plugins/plugin-auth/authorize/oauth-client-settings.tsx
@@ -53,13 +53,21 @@ const OAuthClientSettings = ({
...values
} = store?.state.values
const isPristineSecretInputNames: string[] = []
- schemas.forEach((schema) => {
+ for (let i = 0; i < schemas.length; i++) {
+ const schema = schemas[i]
+ if (schema.required && !values[schema.name]) {
+ notify({
+ type: 'error',
+ message: t('common.errorMsg.fieldRequired', { field: schema.name }),
+ })
+ return
+ }
if (schema.type === FormTypeEnum.secretInput) {
const fieldMeta = form?.getFieldMeta(schema.name)
if (fieldMeta?.isPristine)
isPristineSecretInputNames.push(schema.name)
}
- })
+ }
const transformedValues = transformFormSchemasSecretInput(isPristineSecretInputNames, values)
diff --git a/web/app/components/plugins/plugin-auth/authorized/index.tsx b/web/app/components/plugins/plugin-auth/authorized/index.tsx
index 5762bad2da..9caef74d95 100644
--- a/web/app/components/plugins/plugin-auth/authorized/index.tsx
+++ b/web/app/components/plugins/plugin-auth/authorized/index.tsx
@@ -282,8 +282,7 @@ const Authorized = ({
deleteCredentialId && (