mirror of
https://github.com/langgenius/dify.git
synced 2026-04-27 19:27:23 +08:00
feat(workflow): add toast notifications for warning nodes during execution
This commit is contained in:
parent
66cb963df3
commit
8bcecce627
@ -19,6 +19,8 @@ import {
|
|||||||
} from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
} from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import { useWorkflowStore } from '@/app/components/workflow/store'
|
import { useWorkflowStore } from '@/app/components/workflow/store'
|
||||||
|
import { useWorkflowRunValidation } from '@/app/components/workflow/hooks/use-checklist'
|
||||||
|
import Toast from '@/app/components/base/toast'
|
||||||
|
|
||||||
type NodeControlProps = Pick<Node, 'id' | 'data'>
|
type NodeControlProps = Pick<Node, 'id' | 'data'>
|
||||||
const NodeControl: FC<NodeControlProps> = ({
|
const NodeControl: FC<NodeControlProps> = ({
|
||||||
@ -30,6 +32,8 @@ const NodeControl: FC<NodeControlProps> = ({
|
|||||||
const { handleNodeSelect } = useNodesInteractions()
|
const { handleNodeSelect } = useNodesInteractions()
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
const isSingleRunning = data._singleRunningStatus === NodeRunningStatus.Running
|
const isSingleRunning = data._singleRunningStatus === NodeRunningStatus.Running
|
||||||
|
const { warningNodes } = useWorkflowRunValidation()
|
||||||
|
const warningForNode = warningNodes.find(item => item.id === id)
|
||||||
const handleOpenChange = useCallback((newOpen: boolean) => {
|
const handleOpenChange = useCallback((newOpen: boolean) => {
|
||||||
setOpen(newOpen)
|
setOpen(newOpen)
|
||||||
}, [])
|
}, [])
|
||||||
@ -50,9 +54,15 @@ const NodeControl: FC<NodeControlProps> = ({
|
|||||||
{
|
{
|
||||||
canRunBySingle(data.type, isChildNode) && (
|
canRunBySingle(data.type, isChildNode) && (
|
||||||
<div
|
<div
|
||||||
className='flex h-5 w-5 cursor-pointer items-center justify-center rounded-md hover:bg-state-base-hover'
|
className={`flex h-5 w-5 items-center justify-center rounded-md ${isSingleRunning ? 'cursor-pointer hover:bg-state-base-hover' : warningForNode ? 'cursor-not-allowed text-text-disabled' : 'cursor-pointer hover:bg-state-base-hover'}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const action = isSingleRunning ? 'stop' : 'run'
|
const action = isSingleRunning ? 'stop' : 'run'
|
||||||
|
if (!isSingleRunning && warningForNode) {
|
||||||
|
const message = warningForNode.errorMessage || t('workflow.panel.checklistTip')
|
||||||
|
Toast.notify({ type: 'error', message })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const store = workflowStore.getState()
|
const store = workflowStore.getState()
|
||||||
store.setInitShowLastRunTab(true)
|
store.setInitShowLastRunTab(true)
|
||||||
store.setPendingSingleRun({
|
store.setPendingSingleRun({
|
||||||
@ -67,7 +77,7 @@ const NodeControl: FC<NodeControlProps> = ({
|
|||||||
? <Stop className='h-3 w-3' />
|
? <Stop className='h-3 w-3' />
|
||||||
: (
|
: (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
popupContent={t('workflow.panel.runThisStep')}
|
popupContent={warningForNode ? warningForNode.errorMessage || t('workflow.panel.checklistTip') : t('workflow.panel.runThisStep')}
|
||||||
asChild={false}
|
asChild={false}
|
||||||
>
|
>
|
||||||
<RiPlayLargeLine className='h-3 w-3' />
|
<RiPlayLargeLine className='h-3 w-3' />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user