Merge branch 'feat/tool-oauth' into deploy/dev

pull/22338/head^2
zxhlyh 10 months ago
commit 24d809a9bd

@ -470,8 +470,6 @@ function DetailPanel({ detail, onFeedback }: IDetailPanel) {
className="py-4"
id="scrollableDiv"
style={{
height: 1000, // Specify a value
overflow: 'auto',
display: 'flex',
flexDirection: 'column-reverse',
}}>

@ -70,25 +70,33 @@ const BaseForm = ({
return null
}, [formSchemas, fieldClassName, labelClassName, inputContainerClassName, inputClassName, disabled])
const renderFieldWrapper = useCallback((formSchema: FormSchema) => {
const {
name,
} = formSchema
return (
<form.Field
key={name}
name={name}
>
{renderField}
</form.Field>
)
}, [renderField, form])
if (!formSchemas?.length)
return null
return (
<form
className={cn(formClassName)}
onSubmit={(e) => {
e.preventDefault()
form?.handleSubmit()
}}
>
{
formSchemas.map((formSchema) => {
return (
<form.Field
key={formSchema.name}
name={formSchema.name}
>
{renderField}
</form.Field>
)
})
}
{formSchemas.map(renderFieldWrapper)}
</form>
)
}

@ -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<T = string> = {
en_US: T
@ -52,6 +55,7 @@ export type FormSchema = {
placeholder?: string | TypeWithI18N
options?: FormOption[]
labelClassName?: string
validators?: FieldValidators<any, any, any, any, any, any, any, any, any, any>
}
export type FormValues = Record<string, any>

@ -217,6 +217,7 @@ const AddOAuthButton = ({
disabled={disabled}
schemas={memorizedSchemas}
onAuth={handleOAuth}
editValues={client_params}
/>
)
}

@ -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)

@ -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)

@ -282,8 +282,7 @@ const Authorized = ({
deleteCredentialId && (
<Confirm
isShow
title='Are you sure?'
content='content'
title={t('datasetDocuments.list.delete.title')}
onCancel={closeConfirm}
onConfirm={handleConfirm}
/>

@ -49,7 +49,7 @@ type Props = {
value?: ToolValue
selectedTools?: ToolValue[]
onSelect: (tool: ToolValue) => void
onSelectMultiple: (tool: ToolValue[]) => void
onSelectMultiple?: (tool: ToolValue[]) => void
isEdit?: boolean
onDelete?: () => void
supportEnableSwitch?: boolean
@ -137,7 +137,7 @@ const ToolSelector: FC<Props> = ({
}
const handleSelectMultipleTool = (tool: ToolDefaultValue[]) => {
const toolValues = tool.map(item => getToolValue(item))
onSelectMultiple(toolValues)
onSelectMultiple?.(toolValues)
}
const handleDescriptionChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {

@ -20,7 +20,7 @@ import { useRenderI18nObject } from '@/hooks/use-i18n'
import type { NodeOutPutVar } from '../../../types'
import type { Node } from 'reactflow'
import type { PluginMeta } from '@/app/components/plugins/types'
import { noop } from 'lodash'
import { noop } from 'lodash-es'
import { useDocLink } from '@/context/i18n'
export type Strategy = {

@ -6,7 +6,7 @@ import type { EditData } from './edit-card'
import { ArrayType, type Field, Type } from '../../../types'
import Toast from '@/app/components/base/toast'
import { findPropertyWithPath } from '../../../utils'
import _ from 'lodash'
import { noop } from 'lodash-es'
type ChangeEventParams = {
path: string[],
@ -21,7 +21,7 @@ type AddEventParams = {
export const useSchemaNodeOperations = (props: VisualEditorProps) => {
const { schema: jsonSchema, onChange: doOnChange } = props
const onChange = doOnChange || _.noop
const onChange = doOnChange || noop
const backupSchema = useVisualEditorStore(state => state.backupSchema)
const setBackupSchema = useVisualEditorStore(state => state.setBackupSchema)
const isAddingNewField = useVisualEditorStore(state => state.isAddingNewField)

Loading…
Cancel
Save