mirror of https://github.com/langgenius/dify.git
chore: start form boolean to checkbox
This commit is contained in:
parent
bd04ddd544
commit
6d03a15e0f
|
|
@ -97,8 +97,8 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||
value: InputVarType.number,
|
||||
},
|
||||
{
|
||||
name: t('appDebug.variableConfig.boolean'),
|
||||
value: InputVarType.boolean,
|
||||
name: t('appDebug.variableConfig.checkbox'),
|
||||
value: InputVarType.checkbox,
|
||||
},
|
||||
...(supportFile ? [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ const SelectVarType: FC<Props> = ({
|
|||
<SelectItem type={InputVarType.paragraph} value='paragraph' text={t('appDebug.variableConfig.paragraph')} onClick={handleChange}></SelectItem>
|
||||
<SelectItem type={InputVarType.select} value='select' text={t('appDebug.variableConfig.select')} onClick={handleChange}></SelectItem>
|
||||
<SelectItem type={InputVarType.number} value='number' text={t('appDebug.variableConfig.number')} onClick={handleChange}></SelectItem>
|
||||
<SelectItem type={InputVarType.boolean} value='boolean' text={t('appDebug.variableConfig.boolean')} onClick={handleChange}></SelectItem>
|
||||
<SelectItem type={InputVarType.checkbox} value='checkbox' text={t('appDebug.variableConfig.checkbox')} onClick={handleChange}></SelectItem>
|
||||
</div>
|
||||
<div className='h-[1px] border-t border-components-panel-border'></div>
|
||||
<div className='p-1'>
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ const SettingBuiltInTool: FC<Props> = ({
|
|||
return t('tools.setBuiltInTools.number')
|
||||
if (type === 'text-input')
|
||||
return t('tools.setBuiltInTools.string')
|
||||
if (type === 'checkbox')
|
||||
return 'boolean'
|
||||
if (type === 'file')
|
||||
return t('tools.setBuiltInTools.file')
|
||||
return type
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ const ChatWrapper = () => {
|
|||
|
||||
let hasEmptyInput = ''
|
||||
let fileIsUploading = false
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean)
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox)
|
||||
if (requiredVars.length) {
|
||||
requiredVars.forEach(({ variable, label, type }) => {
|
||||
if (hasEmptyInput)
|
||||
|
|
|
|||
|
|
@ -208,11 +208,11 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
|
|||
}
|
||||
}
|
||||
|
||||
if(item.boolean) {
|
||||
if(item.checkbox) {
|
||||
return {
|
||||
...item.boolean,
|
||||
...item.checkbox,
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
type: 'checkbox',
|
||||
}
|
||||
}
|
||||
if (item.select) {
|
||||
|
|
@ -333,7 +333,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
|
|||
|
||||
let hasEmptyInput = ''
|
||||
let fileIsUploading = false
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean)
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox)
|
||||
if (requiredVars.length) {
|
||||
requiredVars.forEach(({ variable, label, type }) => {
|
||||
if (hasEmptyInput)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ const InputsFormContent = ({ showTip }: Props) => {
|
|||
<div className='space-y-4'>
|
||||
{visibleInputsForms.map(form => (
|
||||
<div key={form.variable} className='space-y-1'>
|
||||
{form.type !== InputVarType.boolean && (
|
||||
{form.type !== InputVarType.checkbox && (
|
||||
<div className='flex h-6 items-center gap-1'>
|
||||
<div className='system-md-semibold text-text-secondary'>{form.label}</div>
|
||||
{!form.required && (
|
||||
|
|
@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => {
|
|||
placeholder={form.label}
|
||||
/>
|
||||
)}
|
||||
{form.type === InputVarType.boolean && (
|
||||
{form.type === InputVarType.checkbox && (
|
||||
<BoolInput
|
||||
name={form.label}
|
||||
value={!!inputsFormValue?.[form.variable]}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export const useCheckInputsForms = () => {
|
|||
const checkInputsForm = useCallback((inputs: Record<string, any>, inputsForm: InputForm[]) => {
|
||||
let hasEmptyInput = ''
|
||||
let fileIsUploading = false
|
||||
const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.boolean) // boolean can be not checked
|
||||
const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.checkbox) // boolean can be not checked
|
||||
|
||||
if (requiredVars?.length) {
|
||||
requiredVars.forEach(({ variable, label, type }) => {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: Inpu
|
|||
inputsForm.forEach((item) => {
|
||||
const inputValue = inputs[item.variable]
|
||||
// set boolean type default value
|
||||
if(item.type === InputVarType.boolean) {
|
||||
if(item.type === InputVarType.checkbox) {
|
||||
processedInputs[item.variable] = !!inputValue
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ const ChatWrapper = () => {
|
|||
|
||||
let hasEmptyInput = ''
|
||||
let fileIsUploading = false
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean)
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox) // boolean can be not checked
|
||||
if (requiredVars.length) {
|
||||
requiredVars.forEach(({ variable, label, type }) => {
|
||||
if (hasEmptyInput)
|
||||
|
|
|
|||
|
|
@ -195,6 +195,13 @@ export const useEmbeddedChatbot = () => {
|
|||
type: 'number',
|
||||
}
|
||||
}
|
||||
if (item.checkbox) {
|
||||
return {
|
||||
...item.checkbox,
|
||||
default: false,
|
||||
type: 'checkbox',
|
||||
}
|
||||
}
|
||||
if (item.select) {
|
||||
const isInputInOptions = item.select.options.includes(initInputs[item.select.variable])
|
||||
return {
|
||||
|
|
@ -312,7 +319,7 @@ export const useEmbeddedChatbot = () => {
|
|||
|
||||
let hasEmptyInput = ''
|
||||
let fileIsUploading = false
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean)
|
||||
const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox)
|
||||
if (requiredVars.length) {
|
||||
requiredVars.forEach(({ variable, label, type }) => {
|
||||
if (hasEmptyInput)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ const InputsFormContent = ({ showTip }: Props) => {
|
|||
<div className='space-y-4'>
|
||||
{visibleInputsForms.map(form => (
|
||||
<div key={form.variable} className='space-y-1'>
|
||||
{form.type !== InputVarType.boolean && (
|
||||
{form.type !== InputVarType.checkbox && (
|
||||
<div className='flex h-6 items-center gap-1'>
|
||||
<div className='system-md-semibold text-text-secondary'>{form.label}</div>
|
||||
{!form.required && (
|
||||
|
|
@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => {
|
|||
placeholder={form.label}
|
||||
/>
|
||||
)}
|
||||
{form.type === InputVarType.boolean && (
|
||||
{form.type === InputVarType.checkbox && (
|
||||
<BoolInput
|
||||
name={form.label}
|
||||
value={inputsFormValue?.[form.variable]}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export enum FormTypeEnum {
|
|||
secretInput = 'secret-input',
|
||||
select = 'select',
|
||||
radio = 'radio',
|
||||
boolean = 'boolean',
|
||||
checkbox = 'checkbox',
|
||||
files = 'files',
|
||||
file = 'file',
|
||||
modelSelector = 'model-selector',
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ const AppInputsPanel = ({
|
|||
required: false,
|
||||
}
|
||||
}
|
||||
if(item.checkbox) {
|
||||
return {
|
||||
...item.checkbox,
|
||||
type: 'checkbox',
|
||||
required: false,
|
||||
}
|
||||
}
|
||||
if (item.select) {
|
||||
return {
|
||||
...item.select,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ const StrategyDetail: FC<Props> = ({
|
|||
return t('tools.setBuiltInTools.number')
|
||||
if (type === 'text-input')
|
||||
return t('tools.setBuiltInTools.string')
|
||||
if (type === 'checkbox')
|
||||
return 'boolean'
|
||||
if (type === 'file')
|
||||
return t('tools.setBuiltInTools.file')
|
||||
if (type === 'array[tools]')
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ export const toType = (type: string) => {
|
|||
return 'text-input'
|
||||
case 'number':
|
||||
return 'number-input'
|
||||
case 'boolean':
|
||||
return 'checkbox'
|
||||
default:
|
||||
return type
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ const FormItem: FC<Props> = ({
|
|||
return ''
|
||||
})()
|
||||
|
||||
const isBooleanType = type === InputVarType.boolean
|
||||
const isBooleanType = type === InputVarType.checkbox
|
||||
const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type)
|
||||
const isContext = type === InputVarType.contexts
|
||||
const isIterator = type === InputVarType.iterator
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export type BeforeRunFormProps = {
|
|||
} & Partial<SpecialResultPanelProps>
|
||||
|
||||
function formatValue(value: string | any, type: InputVarType) {
|
||||
if(type === InputVarType.boolean)
|
||||
if(type === InputVarType.checkbox)
|
||||
return !!value
|
||||
if(value === undefined || value === null)
|
||||
return value
|
||||
|
|
@ -89,7 +89,7 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
|
|||
|
||||
form.inputs.forEach((input) => {
|
||||
const value = form.values[input.variable] as any
|
||||
if (!errMsg && input.required && (input.type !== InputVarType.boolean) && !(input.variable in existVarValuesInForm) && (value === '' || value === undefined || value === null || (input.type === InputVarType.files && value.length === 0)))
|
||||
if (!errMsg && input.required && (input.type !== InputVarType.checkbox) && !(input.variable in existVarValuesInForm) && (value === '' || value === undefined || value === null || (input.type === InputVarType.files && value.length === 0)))
|
||||
errMsg = t('workflow.errorMsg.fieldRequired', { field: typeof input.label === 'object' ? input.label.variable : input.label })
|
||||
|
||||
if (!errMsg && (input.type === InputVarType.singleFile || input.type === InputVarType.multiFiles) && value) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const getIcon = (type: InputVarType) => {
|
|||
[InputVarType.paragraph]: RiAlignLeft,
|
||||
[InputVarType.select]: RiCheckboxMultipleLine,
|
||||
[InputVarType.number]: RiHashtag,
|
||||
[InputVarType.boolean]: RiCheckboxLine,
|
||||
[InputVarType.checkbox]: RiCheckboxLine,
|
||||
[InputVarType.singleFile]: RiFileList2Line,
|
||||
[InputVarType.multiFiles]: RiFileCopy2Line,
|
||||
} as any)[type] || RiTextSnippet
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export const hasValidChildren = (children: any): boolean => {
|
|||
export const inputVarTypeToVarType = (type: InputVarType): VarType => {
|
||||
return ({
|
||||
[InputVarType.number]: VarType.number,
|
||||
[InputVarType.boolean]: VarType.boolean,
|
||||
[InputVarType.checkbox]: VarType.boolean,
|
||||
[InputVarType.singleFile]: VarType.file,
|
||||
[InputVarType.multiFiles]: VarType.arrayFile,
|
||||
} as any)[type] || VarType.string
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ const varTypeToInputVarType = (type: VarType, {
|
|||
if (type === VarType.number)
|
||||
return InputVarType.number
|
||||
if (type === VarType.boolean)
|
||||
return InputVarType.boolean
|
||||
return InputVarType.checkbox
|
||||
if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type))
|
||||
return InputVarType.json
|
||||
if (type === VarType.file)
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ export enum InputVarType {
|
|||
paragraph = 'paragraph',
|
||||
select = 'select',
|
||||
number = 'number',
|
||||
boolean = 'boolean',
|
||||
checkbox = 'checkbox',
|
||||
url = 'url',
|
||||
files = 'files',
|
||||
json = 'json', // obj, array
|
||||
|
|
@ -449,6 +449,6 @@ export enum VersionHistoryContextMenuOptions {
|
|||
delete = 'delete',
|
||||
}
|
||||
|
||||
export interface ChildNodeTypeCount {
|
||||
export type ChildNodeTypeCount = {
|
||||
[key: string]: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ const translation = {
|
|||
'paragraph': 'Paragraph',
|
||||
'select': 'Select',
|
||||
'number': 'Number',
|
||||
'boolean': 'Checkbox',
|
||||
'checkbox': 'Checkbox',
|
||||
'single-file': 'Single File',
|
||||
'multi-files': 'File List',
|
||||
'notSet': 'Not set, try typing {{input}} in the prefix prompt',
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ const translation = {
|
|||
'paragraph': '段落',
|
||||
'select': '下拉选项',
|
||||
'number': '数字',
|
||||
'boolean': '复选框',
|
||||
'checkbox': '复选框',
|
||||
'single-file': '单文件',
|
||||
'multi-files': '文件列表',
|
||||
'notSet': '未设置,在 Prompt 中输入 {{input}} 试试',
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
|
|||
if (item.number)
|
||||
return ['number', item.number]
|
||||
|
||||
if (item.checkbox)
|
||||
return ['boolean', item.checkbox]
|
||||
|
||||
if (item.file)
|
||||
return ['file', item.file]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue