feat: start support readonly

This commit is contained in:
Joel 2024-03-20 15:09:12 +08:00
parent 1b857eba29
commit 698eb9671f
4 changed files with 7 additions and 5 deletions

View File

@ -383,7 +383,7 @@ export const useNodesReadOnly = () => {
}, [workflowStore])
return {
nodesReadOnly: workflowRunningData || historyWorkflowData || isRestoring,
nodesReadOnly: !!(workflowRunningData || historyWorkflowData || isRestoring),
getNodesReadOnly,
}
}

View File

@ -45,7 +45,7 @@ const VarItem: FC<Props> = ({
<div className='grow w-0 truncate text-[13px] font-medium text-gray-500'>{payload.label}</div>
</div>
<div className='shrink-0 ml-2 flex items-center'>
{!isHovering
{(!isHovering || readonly)
? (
<>
{payload.required && (

View File

@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next'
import VarList from './components/var-list'
import useConfig from './use-config'
import type { StartNodeType } from './types'
// import { useStore } from '@/app/components/workflow/store'
import Split from '@/app/components/workflow/nodes/_base/components/split'
import Field from '@/app/components/workflow/nodes/_base/components/field'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
@ -19,8 +18,8 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
data,
}) => {
const { t } = useTranslation()
const readOnly = false // useStore(s => s.readOnly)
const {
readOnly,
isChatMode,
inputs,
isShowAddVarModal,
@ -41,7 +40,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
<Field
title={t(`${i18nPrefix}.inputField`)}
operations={
<AddButton onClick={showAddVarModal} />
!readOnly ? <AddButton onClick={showAddVarModal} /> : undefined
}
>
<VarList

View File

@ -6,9 +6,11 @@ import type { InputVar } from '@/app/components/workflow/types'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import {
useIsChatMode,
useNodesReadOnly,
} from '@/app/components/workflow/hooks'
const useConfig = (id: string, payload: StartNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
const isChatMode = useIsChatMode()
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
@ -32,6 +34,7 @@ const useConfig = (id: string, payload: StartNodeType) => {
setInputs(newInputs)
}, [inputs, setInputs])
return {
readOnly,
isChatMode,
inputs,
isShowAddVarModal,