mirror of https://github.com/langgenius/dify.git
fix
This commit is contained in:
parent
18883d9faa
commit
2919cc9adf
|
|
@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next'
|
|||
import { useStore } from './store'
|
||||
import {
|
||||
useIsChatMode,
|
||||
useNodesReadOnly,
|
||||
useNodesSyncDraft,
|
||||
} from './hooks'
|
||||
import { XClose } from '@/app/components/base/icons/src/vender/line/general'
|
||||
|
|
@ -18,7 +19,7 @@ const Features = () => {
|
|||
const { t } = useTranslation()
|
||||
const isChatMode = useIsChatMode()
|
||||
const setShowFeaturesPanel = useStore(s => s.setShowFeaturesPanel)
|
||||
const isRestoring = useStore(s => s.isRestoring)
|
||||
const { nodesReadOnly } = useNodesReadOnly()
|
||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||
|
||||
const handleFeaturesChange = useCallback(() => {
|
||||
|
|
@ -34,7 +35,7 @@ const Features = () => {
|
|||
isChatMode && (
|
||||
<>
|
||||
<FeaturesChoose
|
||||
disabled={isRestoring}
|
||||
disabled={nodesReadOnly}
|
||||
onChange={handleFeaturesChange}
|
||||
/>
|
||||
<div className='mx-3 w-[1px] h-[14px] bg-gray-200'></div>
|
||||
|
|
@ -51,7 +52,7 @@ const Features = () => {
|
|||
</div>
|
||||
<div className='p-4'>
|
||||
<FeaturesPanel
|
||||
disabled={isRestoring}
|
||||
disabled={nodesReadOnly}
|
||||
onChange={handleFeaturesChange}
|
||||
openingStatementProps={{
|
||||
onAutoAddPromptVariable: () => {},
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from '../store'
|
||||
import {
|
||||
useNodesReadOnly,
|
||||
useNodesSyncDraft,
|
||||
useWorkflowRun,
|
||||
} from '../hooks'
|
||||
import RunAndHistory from './run-and-history'
|
||||
|
|
@ -29,33 +30,31 @@ const Header: FC = () => {
|
|||
const appSidebarExpand = useAppStore(s => s.appSidebarExpand)
|
||||
const {
|
||||
nodesReadOnly,
|
||||
getNodesReadOnly,
|
||||
} = useNodesReadOnly()
|
||||
const isRestoring = useStore(s => s.isRestoring)
|
||||
const {
|
||||
handleLoadBackupDraft,
|
||||
handleRunSetting,
|
||||
handleRestoreFromPublishedWorkflow,
|
||||
} = useWorkflowRun()
|
||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||
|
||||
const handleShowFeatures = useCallback(() => {
|
||||
if (getNodesReadOnly())
|
||||
return
|
||||
|
||||
workflowStore.setState({ showFeaturesPanel: true })
|
||||
}, [getNodesReadOnly, workflowStore])
|
||||
}, [workflowStore])
|
||||
|
||||
const handleGoBackToEdit = useCallback(() => {
|
||||
handleRunSetting(true)
|
||||
}, [handleRunSetting])
|
||||
|
||||
const handleCancelRestore = useCallback(() => {
|
||||
handleLoadBackupDraft()
|
||||
workflowStore.setState({ isRestoring: false })
|
||||
}, [workflowStore])
|
||||
}, [workflowStore, handleLoadBackupDraft])
|
||||
|
||||
const handleRestore = useCallback(() => {
|
||||
handleRestoreFromPublishedWorkflow()
|
||||
workflowStore.setState({ isRestoring: false })
|
||||
}, [handleRestoreFromPublishedWorkflow, workflowStore])
|
||||
handleSyncWorkflowDraft(true)
|
||||
}, [handleSyncWorkflowDraft, workflowStore])
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -103,7 +102,6 @@ const Header: FC = () => {
|
|||
className={`
|
||||
mr-2 px-3 py-0 h-8 bg-white text-[13px] font-medium text-gray-700
|
||||
border-[0.5px] border-gray-200 shadow-xs
|
||||
${nodesReadOnly && '!cursor-not-allowed opacity-50'}
|
||||
`}
|
||||
onClick={handleShowFeatures}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ const Publish = () => {
|
|||
const [published, setPublished] = useState(false)
|
||||
const workflowStore = useWorkflowStore()
|
||||
const { formatTimeFromNow } = useWorkflow()
|
||||
const { handleCheckBeforePublish } = useWorkflowRun()
|
||||
const {
|
||||
handleBackupDraft,
|
||||
handleCheckBeforePublish,
|
||||
handleRestoreFromPublishedWorkflow,
|
||||
} = useWorkflowRun()
|
||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||
const {
|
||||
nodesReadOnly,
|
||||
|
|
@ -61,8 +65,10 @@ const Publish = () => {
|
|||
|
||||
const handleRestore = useCallback(() => {
|
||||
workflowStore.getState().setIsRestoring(true)
|
||||
handleBackupDraft()
|
||||
handleRestoreFromPublishedWorkflow()
|
||||
setOpen(false)
|
||||
}, [workflowStore])
|
||||
}, [workflowStore, handleBackupDraft, handleRestoreFromPublishedWorkflow])
|
||||
|
||||
const handleTrigger = useCallback(() => {
|
||||
if (getNodesReadOnly())
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ export const useNodesInteractions = () => {
|
|||
}, [store, getNodesReadOnly])
|
||||
|
||||
const handleNodeSelect = useCallback((nodeId: string, cancelSelection?: boolean) => {
|
||||
if (getNodesReadOnly())
|
||||
if (getNodesReadOnly() && !workflowStore.getState().isRestoring)
|
||||
return
|
||||
|
||||
const {
|
||||
|
|
@ -264,14 +264,14 @@ export const useNodesInteractions = () => {
|
|||
})
|
||||
setNodes(newNodes)
|
||||
handleSyncWorkflowDraft()
|
||||
}, [store, handleSyncWorkflowDraft, getNodesReadOnly])
|
||||
}, [store, handleSyncWorkflowDraft, getNodesReadOnly, workflowStore])
|
||||
|
||||
const handleNodeClick = useCallback<NodeMouseHandler>((_, node) => {
|
||||
if (getNodesReadOnly())
|
||||
if (getNodesReadOnly() && !workflowStore.getState().isRestoring)
|
||||
return
|
||||
|
||||
handleNodeSelect(node.id)
|
||||
}, [handleNodeSelect, getNodesReadOnly])
|
||||
}, [handleNodeSelect, getNodesReadOnly, workflowStore])
|
||||
|
||||
const handleNodeConnect = useCallback<OnConnect>(({
|
||||
source,
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ export const useNodesSyncDraft = () => {
|
|||
viewport: getViewport(),
|
||||
},
|
||||
features: {
|
||||
opening_statement: features.opening.opening_statement,
|
||||
suggested_questions: features.opening.suggested_questions,
|
||||
opening_statement: features.opening?.opening_statement || '',
|
||||
suggested_questions: features.opening?.suggested_questions || [],
|
||||
suggested_questions_after_answer: features.suggested,
|
||||
text_to_speech: features.text2speech,
|
||||
speech_to_text: features.speech2text,
|
||||
|
|
|
|||
|
|
@ -323,6 +323,7 @@ export const useWorkflowRun = () => {
|
|||
|
||||
return {
|
||||
handleBackupDraft,
|
||||
handleLoadBackupDraft,
|
||||
handleRunSetting,
|
||||
handleRun,
|
||||
handleStopRun,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
NodeRunningStatus,
|
||||
} from '../../types'
|
||||
import { useStore } from '../../store'
|
||||
import { useNodesReadOnly } from '../../hooks'
|
||||
import {
|
||||
NodeSourceHandle,
|
||||
NodeTargetHandle,
|
||||
|
|
@ -34,6 +35,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||
data,
|
||||
children,
|
||||
}) => {
|
||||
const { nodesReadOnly } = useNodesReadOnly()
|
||||
const toolsets = useStore(s => s.toolsets)
|
||||
const toolIcon = useMemo(() => {
|
||||
if (data.type === BlockEnum.Tool)
|
||||
|
|
@ -60,7 +62,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||
`}
|
||||
>
|
||||
{
|
||||
data.type !== BlockEnum.VariableAssigner && !data._runningStatus && (
|
||||
data.type !== BlockEnum.VariableAssigner && !data._runningStatus && !nodesReadOnly && (
|
||||
<NodeTargetHandle
|
||||
id={id}
|
||||
data={data}
|
||||
|
|
@ -70,7 +72,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||
)
|
||||
}
|
||||
{
|
||||
data.type !== BlockEnum.IfElse && data.type !== BlockEnum.QuestionClassifier && !data._runningStatus && (
|
||||
data.type !== BlockEnum.IfElse && data.type !== BlockEnum.QuestionClassifier && !data._runningStatus && !nodesReadOnly && (
|
||||
<NodeSourceHandle
|
||||
id={id}
|
||||
data={data}
|
||||
|
|
@ -80,7 +82,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||
)
|
||||
}
|
||||
{
|
||||
!data._runningStatus && (
|
||||
!data._runningStatus && !nodesReadOnly && (
|
||||
<NodeControl
|
||||
id={id}
|
||||
data={data}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {
|
|||
useNodeDataUpdate,
|
||||
useNodesExtraData,
|
||||
useNodesInteractions,
|
||||
useNodesReadOnly,
|
||||
useNodesSyncDraft,
|
||||
} from '@/app/components/workflow/hooks'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
|
|
@ -45,6 +46,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
const { t } = useTranslation()
|
||||
const { handleNodeSelect } = useNodesInteractions()
|
||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||
const { nodesReadOnly } = useNodesReadOnly()
|
||||
const nodesExtraData = useNodesExtraData()
|
||||
const availableNextNodes = nodesExtraData[data.type].availableNextNodes
|
||||
|
||||
|
|
@ -82,7 +84,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
/>
|
||||
<div className='shrink-0 flex items-center text-gray-500'>
|
||||
{
|
||||
canRunBySingle(data.type) && (
|
||||
canRunBySingle(data.type) && !nodesReadOnly && (
|
||||
<TooltipPlus
|
||||
popupContent={t('workflow.panel.runThisStep')}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ const ChatWrapper = forwardRef<ChatWrapperRefType>((_, ref) => {
|
|||
|
||||
const config = useMemo(() => {
|
||||
return {
|
||||
opening_statement: features.opening.opening_statement,
|
||||
suggested_questions: features.opening.suggested_questions,
|
||||
opening_statement: features.opening?.opening_statement || '',
|
||||
suggested_questions: features.opening?.suggested_questions || [],
|
||||
suggested_questions_after_answer: features.suggested,
|
||||
text_to_speech: features.text2speech,
|
||||
speech_to_text: features.speech2text,
|
||||
|
|
|
|||
Loading…
Reference in New Issue