fix: bing search response filter (#2519)

This commit is contained in:
Yeuoly
2024-02-22 13:06:55 +08:00
committed by GitHub
parent 1ecbd95adf
commit d8ab4474b4
6 changed files with 170 additions and 23 deletions

View File

@@ -116,7 +116,7 @@ const SettingBuiltInTool: FC<Props> = ({
</div>
)
const setttingUI = (
const settingUI = (
<Form
value={tempSetting}
onChange={setTempSetting}
@@ -174,7 +174,7 @@ const SettingBuiltInTool: FC<Props> = ({
</div>
: (<div className='flex flex-col h-full'>
<div className='grow h-0 overflow-y-auto px-6'>
{isInfoActive ? infoUI : setttingUI}
{isInfoActive ? infoUI : settingUI}
</div>
{!readonly && !isInfoActive && (
<div className='mt-2 shrink-0 flex justify-end py-4 px-6 space-x-2 rounded-b-[10px] bg-gray-50 border-t border-black/5'>

View File

@@ -17,6 +17,7 @@ import Input from './Input'
import { SimpleSelect } from '@/app/components/base/select'
import Tooltip from '@/app/components/base/tooltip-plus'
import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
import Radio from '@/app/components/base/radio'
type FormProps = {
value: FormValue
onChange: (val: FormValue) => void
@@ -47,7 +48,7 @@ const Form: FC<FormProps> = ({
const language = useLanguage()
const [changeKey, setChangeKey] = useState('')
const handleFormChange = (key: string, val: string) => {
const handleFormChange = (key: string, val: string | boolean) => {
if (isEditMode && (key === '__model_type' || key === '__model_name'))
return
@@ -214,6 +215,37 @@ const Form: FC<FormProps> = ({
</div>
)
}
if (formSchema.type === 'boolean') {
const {
variable,
label,
show_on,
} = formSchema as CredentialFormSchemaRadio
if (show_on.length && !show_on.every(showOnItem => value[showOnItem.variable] === showOnItem.value))
return null
return (
<div key={variable} className='py-3'>
<div className='flex items-center justify-between py-2 text-sm text-gray-900'>
<div className='flex items-center space-x-2'>
<span>{label[language]}</span>
{tooltipContent}
</div>
<Radio.Group
className='flex items-center'
value={value[variable] ? 1 : 0}
onChange={val => handleFormChange(variable, val === 1)}
>
<Radio value={1} className='!mr-1'>True</Radio>
<Radio value={0}>False</Radio>
</Radio.Group>
</div>
{fieldMoreInfo?.(formSchema)}
</div>
)
}
}
return (

View File

@@ -57,7 +57,7 @@ export const addDefaultValue = (value: Record<string, any>, formSchemas: { varia
const newValues = { ...value }
formSchemas.forEach((formSchema) => {
const itemValue = value[formSchema.variable]
if (formSchema.default && (value === undefined || itemValue === null || itemValue === ''))
if ((formSchema.default !== undefined) && (value === undefined || itemValue === null || itemValue === '' || itemValue === undefined))
newValues[formSchema.variable] = formSchema.default
})
return newValues