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" className="py-4"
id="scrollableDiv" id="scrollableDiv"
style={{ style={{
height: 1000, // Specify a value
overflow: 'auto',
display: 'flex', display: 'flex',
flexDirection: 'column-reverse', flexDirection: 'column-reverse',
}}> }}>

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

@ -2,7 +2,10 @@ import type {
ForwardedRef, ForwardedRef,
ReactNode, ReactNode,
} from 'react' } from 'react'
import type { AnyFormApi } from '@tanstack/react-form' import type {
AnyFormApi,
FieldValidators,
} from '@tanstack/react-form'
export type TypeWithI18N<T = string> = { export type TypeWithI18N<T = string> = {
en_US: T en_US: T
@ -52,6 +55,7 @@ export type FormSchema = {
placeholder?: string | TypeWithI18N placeholder?: string | TypeWithI18N
options?: FormOption[] options?: FormOption[]
labelClassName?: string labelClassName?: string
validators?: FieldValidators<any, any, any, any, any, any, any, any, any, any>
} }
export type FormValues = Record<string, any> export type FormValues = Record<string, any>

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

@ -72,13 +72,21 @@ const ApiKeyModal = ({
...values ...values
} = store?.state.values } = store?.state.values
const isPristineSecretInputNames: string[] = [] 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) { if (schema.type === FormTypeEnum.secretInput) {
const fieldMeta = form?.getFieldMeta(schema.name) const fieldMeta = form?.getFieldMeta(schema.name)
if (fieldMeta?.isPristine) if (fieldMeta?.isPristine)
isPristineSecretInputNames.push(schema.name) isPristineSecretInputNames.push(schema.name)
} }
}) }
const transformedValues = transformFormSchemasSecretInput(isPristineSecretInputNames, values) const transformedValues = transformFormSchemasSecretInput(isPristineSecretInputNames, values)

@ -53,13 +53,21 @@ const OAuthClientSettings = ({
...values ...values
} = store?.state.values } = store?.state.values
const isPristineSecretInputNames: string[] = [] 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) { if (schema.type === FormTypeEnum.secretInput) {
const fieldMeta = form?.getFieldMeta(schema.name) const fieldMeta = form?.getFieldMeta(schema.name)
if (fieldMeta?.isPristine) if (fieldMeta?.isPristine)
isPristineSecretInputNames.push(schema.name) isPristineSecretInputNames.push(schema.name)
} }
}) }
const transformedValues = transformFormSchemasSecretInput(isPristineSecretInputNames, values) const transformedValues = transformFormSchemasSecretInput(isPristineSecretInputNames, values)

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

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

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

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

Loading…
Cancel
Save