feat: question classify support readonly

This commit is contained in:
Joel 2024-03-20 16:48:52 +08:00
parent beca05848c
commit c9168c19cd
4 changed files with 28 additions and 10 deletions

View File

@ -13,6 +13,7 @@ type Props = {
hideMemorySetting: boolean
memory: Memory
onMemoryChange: (memory: Memory) => void
readonly?: boolean
}
const AdvancedSetting: FC<Props> = ({
@ -21,6 +22,7 @@ const AdvancedSetting: FC<Props> = ({
hideMemorySetting,
memory,
onMemoryChange,
readonly,
}) => {
const { t } = useTranslation()
@ -38,6 +40,7 @@ const AdvancedSetting: FC<Props> = ({
<div className='mx-3 h-3 w-px bg-gray-200'></div>
</div>
)}
readonly={readonly}
/>
{!hideMemorySetting && (
<MemoryConfig

View File

@ -13,6 +13,7 @@ type Props = {
onChange: (payload: Topic) => void
onRemove: () => void
index: number
readonly?: boolean
}
const ClassItem: FC<Props> = ({
@ -20,6 +21,7 @@ const ClassItem: FC<Props> = ({
onChange,
onRemove,
index,
readonly,
}) => {
const { t } = useTranslation()
@ -45,12 +47,15 @@ const ClassItem: FC<Props> = ({
<div className='flex items-center h-full'>
<div className='text-xs font-medium text-gray-500'>{payload.name.length}</div>
<div className='mx-3 h-3 w-px bg-gray-200'></div>
<Trash03
className='mr-1 w-3.5 h-3.5 text-gray-500 cursor-pointer'
onClick={onRemove}
/>
{!readonly && (
<Trash03
className='mr-1 w-3.5 h-3.5 text-gray-500 cursor-pointer'
onClick={onRemove}
/>
)}
</div>
)}
readonly={readonly}
minHeight={64}
/>
)

View File

@ -14,12 +14,14 @@ type Props = {
id: string
list: Topic[]
onChange: (list: Topic[]) => void
readonly?: boolean
}
const ClassList: FC<Props> = ({
id,
list,
onChange,
readonly,
}) => {
const { t } = useTranslation()
const { handleEdgeDeleteByDeleteBranch } = useEdgesInteractions()
@ -62,14 +64,18 @@ const ClassList: FC<Props> = ({
onChange={handleClassChange(index)}
onRemove={handleRemoveClass(index)}
index={index + 1}
readonly={readonly}
/>
)
})
}
<AddButton
onClick={handleAddClass}
text={t(`${i18nPrefix}.addClass`)}
/>
{!readonly && (
<AddButton
onClick={handleAddClass}
text={t(`${i18nPrefix}.addClass`)}
/>
)}
</div>
)
}

View File

@ -19,9 +19,9 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
data,
}) => {
const { t } = useTranslation()
const readOnly = false
const {
readOnly,
inputs,
handleModelChanged,
isChatModel,
@ -73,6 +73,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
onCompletionParamsChange={handleCompletionParamsChange}
hideDebugWithMultipleModel
debugWithMultipleModel={false}
readonly={readOnly}
/>
</Field>
<Field
@ -81,7 +82,9 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
<ClassList
id={id}
list={inputs.classes}
onChange={handleTopicsChange} />
onChange={handleTopicsChange}
readonly={readOnly}
/>
</Field>
<Field
title={t(`${i18nPrefix}.advancedSetting`)}
@ -93,6 +96,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
onInstructionChange={handleInstructionChange}
memory={inputs.memory}
onMemoryChange={handleMemoryChange}
readonly={readOnly}
/>
</Field>
</div>