mirror of
https://github.com/langgenius/dify.git
synced 2026-04-26 10:16:40 +08:00
fix: display correct icon for trigger nodes in listening panel
This commit is contained in:
parent
90ae5e5865
commit
1d4e36d58f
@ -237,6 +237,8 @@ export const useWorkflowRun = () => {
|
|||||||
setWorkflowRunningData,
|
setWorkflowRunningData,
|
||||||
setIsListening,
|
setIsListening,
|
||||||
setShowVariableInspectPanel,
|
setShowVariableInspectPanel,
|
||||||
|
setListeningTriggerType,
|
||||||
|
setListeningTriggerNodeId,
|
||||||
} = workflowStore.getState()
|
} = workflowStore.getState()
|
||||||
|
|
||||||
if (runMode === 'webhook') {
|
if (runMode === 'webhook') {
|
||||||
@ -267,6 +269,8 @@ export const useWorkflowRun = () => {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setIsListening(false)
|
setIsListening(false)
|
||||||
|
setListeningTriggerType(null)
|
||||||
|
setListeningTriggerNodeId(null)
|
||||||
setWorkflowRunningData({
|
setWorkflowRunningData({
|
||||||
result: {
|
result: {
|
||||||
status: WorkflowRunningStatus.Running,
|
status: WorkflowRunningStatus.Running,
|
||||||
@ -302,6 +306,8 @@ export const useWorkflowRun = () => {
|
|||||||
const clearListeningState = () => {
|
const clearListeningState = () => {
|
||||||
const state = workflowStore.getState()
|
const state = workflowStore.getState()
|
||||||
state.setIsListening(false)
|
state.setIsListening(false)
|
||||||
|
state.setListeningTriggerType(null)
|
||||||
|
state.setListeningTriggerNodeId(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrappedOnError = (params: any) => {
|
const wrappedOnError = (params: any) => {
|
||||||
@ -625,7 +631,7 @@ export const useWorkflowRun = () => {
|
|||||||
abortControllerRef.current.abort()
|
abortControllerRef.current.abort()
|
||||||
|
|
||||||
abortControllerRef.current = null
|
abortControllerRef.current = null
|
||||||
const { setWorkflowRunningData, setIsListening, setShowVariableInspectPanel } = workflowStore.getState()
|
const { setWorkflowRunningData, setIsListening, setShowVariableInspectPanel, setListeningTriggerType, setListeningTriggerNodeId } = workflowStore.getState()
|
||||||
setWorkflowRunningData({
|
setWorkflowRunningData({
|
||||||
result: {
|
result: {
|
||||||
status: WorkflowRunningStatus.Stopped,
|
status: WorkflowRunningStatus.Stopped,
|
||||||
@ -637,6 +643,8 @@ export const useWorkflowRun = () => {
|
|||||||
resultText: '',
|
resultText: '',
|
||||||
})
|
})
|
||||||
setIsListening(false)
|
setIsListening(false)
|
||||||
|
setListeningTriggerType(null)
|
||||||
|
setListeningTriggerNodeId(null)
|
||||||
setShowVariableInspectPanel(true)
|
setShowVariableInspectPanel(true)
|
||||||
}, [workflowStore])
|
}, [workflowStore])
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,8 @@ export const useWorkflowStartRun = () => {
|
|||||||
setShowDebugAndPreviewPanel,
|
setShowDebugAndPreviewPanel,
|
||||||
setShowInputsPanel,
|
setShowInputsPanel,
|
||||||
setShowEnvPanel,
|
setShowEnvPanel,
|
||||||
|
setListeningTriggerType,
|
||||||
|
setListeningTriggerNodeId,
|
||||||
} = workflowStore.getState()
|
} = workflowStore.getState()
|
||||||
|
|
||||||
if (workflowRunningData?.result.status === WorkflowRunningStatus.Running)
|
if (workflowRunningData?.result.status === WorkflowRunningStatus.Running)
|
||||||
@ -92,6 +94,9 @@ export const useWorkflowStartRun = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setListeningTriggerType(BlockEnum.TriggerSchedule)
|
||||||
|
setListeningTriggerNodeId(nodeId)
|
||||||
|
|
||||||
await doSyncWorkflowDraft()
|
await doSyncWorkflowDraft()
|
||||||
handleRun(
|
handleRun(
|
||||||
{},
|
{},
|
||||||
@ -115,6 +120,8 @@ export const useWorkflowStartRun = () => {
|
|||||||
setShowDebugAndPreviewPanel,
|
setShowDebugAndPreviewPanel,
|
||||||
setShowInputsPanel,
|
setShowInputsPanel,
|
||||||
setShowEnvPanel,
|
setShowEnvPanel,
|
||||||
|
setListeningTriggerType,
|
||||||
|
setListeningTriggerNodeId,
|
||||||
} = workflowStore.getState()
|
} = workflowStore.getState()
|
||||||
|
|
||||||
if (workflowRunningData?.result.status === WorkflowRunningStatus.Running)
|
if (workflowRunningData?.result.status === WorkflowRunningStatus.Running)
|
||||||
@ -135,6 +142,8 @@ export const useWorkflowStartRun = () => {
|
|||||||
setShowDebugAndPreviewPanel(true)
|
setShowDebugAndPreviewPanel(true)
|
||||||
|
|
||||||
setShowInputsPanel(false)
|
setShowInputsPanel(false)
|
||||||
|
setListeningTriggerType(BlockEnum.TriggerWebhook)
|
||||||
|
setListeningTriggerNodeId(nodeId)
|
||||||
|
|
||||||
await doSyncWorkflowDraft()
|
await doSyncWorkflowDraft()
|
||||||
handleRun(
|
handleRun(
|
||||||
@ -156,6 +165,8 @@ export const useWorkflowStartRun = () => {
|
|||||||
setShowDebugAndPreviewPanel,
|
setShowDebugAndPreviewPanel,
|
||||||
setShowInputsPanel,
|
setShowInputsPanel,
|
||||||
setShowEnvPanel,
|
setShowEnvPanel,
|
||||||
|
setListeningTriggerType,
|
||||||
|
setListeningTriggerNodeId,
|
||||||
} = workflowStore.getState()
|
} = workflowStore.getState()
|
||||||
|
|
||||||
if (workflowRunningData?.result.status === WorkflowRunningStatus.Running)
|
if (workflowRunningData?.result.status === WorkflowRunningStatus.Running)
|
||||||
@ -176,6 +187,8 @@ export const useWorkflowStartRun = () => {
|
|||||||
setShowDebugAndPreviewPanel(true)
|
setShowDebugAndPreviewPanel(true)
|
||||||
|
|
||||||
setShowInputsPanel(false)
|
setShowInputsPanel(false)
|
||||||
|
setListeningTriggerType(BlockEnum.TriggerPlugin)
|
||||||
|
setListeningTriggerNodeId(nodeId)
|
||||||
|
|
||||||
await doSyncWorkflowDraft()
|
await doSyncWorkflowDraft()
|
||||||
handleRun(
|
handleRun(
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import type { StateCreator } from 'zustand'
|
import type { StateCreator } from 'zustand'
|
||||||
import type {
|
import type {
|
||||||
Node,
|
Node,
|
||||||
|
TriggerNodeType,
|
||||||
WorkflowRunningData,
|
WorkflowRunningData,
|
||||||
} from '@/app/components/workflow/types'
|
} from '@/app/components/workflow/types'
|
||||||
import type { FileUploadConfigResponse } from '@/models/common'
|
import type { FileUploadConfigResponse } from '@/models/common'
|
||||||
@ -15,6 +16,10 @@ export type WorkflowSliceShape = {
|
|||||||
setWorkflowRunningData: (workflowData: PreviewRunningData) => void
|
setWorkflowRunningData: (workflowData: PreviewRunningData) => void
|
||||||
isListening: boolean
|
isListening: boolean
|
||||||
setIsListening: (listening: boolean) => void
|
setIsListening: (listening: boolean) => void
|
||||||
|
listeningTriggerType: TriggerNodeType | null
|
||||||
|
setListeningTriggerType: (triggerType: TriggerNodeType | null) => void
|
||||||
|
listeningTriggerNodeId: string | null
|
||||||
|
setListeningTriggerNodeId: (nodeId: string | null) => void
|
||||||
clipboardElements: Node[]
|
clipboardElements: Node[]
|
||||||
setClipboardElements: (clipboardElements: Node[]) => void
|
setClipboardElements: (clipboardElements: Node[]) => void
|
||||||
selection: null | { x1: number; y1: number; x2: number; y2: number }
|
selection: null | { x1: number; y1: number; x2: number; y2: number }
|
||||||
@ -40,6 +45,10 @@ export const createWorkflowSlice: StateCreator<WorkflowSliceShape> = set => ({
|
|||||||
setWorkflowRunningData: workflowRunningData => set(() => ({ workflowRunningData })),
|
setWorkflowRunningData: workflowRunningData => set(() => ({ workflowRunningData })),
|
||||||
isListening: false,
|
isListening: false,
|
||||||
setIsListening: listening => set(() => ({ isListening: listening })),
|
setIsListening: listening => set(() => ({ isListening: listening })),
|
||||||
|
listeningTriggerType: null,
|
||||||
|
setListeningTriggerType: triggerType => set(() => ({ listeningTriggerType: triggerType })),
|
||||||
|
listeningTriggerNodeId: null,
|
||||||
|
setListeningTriggerNodeId: nodeId => set(() => ({ listeningTriggerNodeId: nodeId })),
|
||||||
clipboardElements: [],
|
clipboardElements: [],
|
||||||
setClipboardElements: clipboardElements => set(() => ({ clipboardElements })),
|
setClipboardElements: clipboardElements => set(() => ({ clipboardElements })),
|
||||||
selection: null,
|
selection: null,
|
||||||
|
|||||||
@ -507,6 +507,9 @@ export const TRIGGER_NODE_TYPES = [
|
|||||||
BlockEnum.TriggerPlugin,
|
BlockEnum.TriggerPlugin,
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
// Type-safe trigger node type extracted from TRIGGER_NODE_TYPES array
|
||||||
|
export type TriggerNodeType = typeof TRIGGER_NODE_TYPES[number]
|
||||||
|
|
||||||
export function isTriggerNode(nodeType: BlockEnum): boolean {
|
export function isTriggerNode(nodeType: BlockEnum): boolean {
|
||||||
return TRIGGER_NODE_TYPES.includes(nodeType as any)
|
return TRIGGER_NODE_TYPES.includes(nodeType as any)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useStoreApi } from 'reactflow'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import BlockIcon from '@/app/components/workflow/block-icon'
|
import BlockIcon from '@/app/components/workflow/block-icon'
|
||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
import { StopCircle } from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
import { StopCircle } from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
||||||
|
import { useStore } from '../store'
|
||||||
|
import { useToolIcon } from '@/app/components/workflow/hooks/use-tool-icon'
|
||||||
|
|
||||||
export type ListeningProps = {
|
export type ListeningProps = {
|
||||||
onStop: () => void
|
onStop: () => void
|
||||||
@ -15,12 +18,26 @@ const Listening: FC<ListeningProps> = ({
|
|||||||
message,
|
message,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const store = useStoreApi()
|
||||||
|
|
||||||
|
// Get the current trigger type and node ID from store
|
||||||
|
const listeningTriggerType = useStore(s => s.listeningTriggerType)
|
||||||
|
const listeningTriggerNodeId = useStore(s => s.listeningTriggerNodeId)
|
||||||
|
const triggerType = listeningTriggerType || BlockEnum.TriggerWebhook
|
||||||
|
|
||||||
|
// Get the trigger node data to extract icon information
|
||||||
|
const { getNodes } = store.getState()
|
||||||
|
const nodes = getNodes()
|
||||||
|
const triggerNode = listeningTriggerNodeId
|
||||||
|
? nodes.find(node => node.id === listeningTriggerNodeId)
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
// Use the useToolIcon hook to get the icon for plugin/datasource triggers
|
||||||
|
const toolIcon = useToolIcon(triggerNode?.data)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex h-full flex-col gap-4 rounded-xl bg-background-section p-8'>
|
<div className='flex h-full flex-col gap-4 rounded-xl bg-background-section p-8'>
|
||||||
<div className='flex h-10 w-10 items-center justify-center rounded-[10px] border-[0.5px] bg-util-colors-blue-blue-500 shadow-lg backdrop-blur-sm'>
|
<BlockIcon type={triggerType} toolIcon={toolIcon} size="md" className="!h-10 !w-10 !rounded-xl [&_svg]:!h-7 [&_svg]:!w-7" />
|
||||||
<BlockIcon type={BlockEnum.TriggerWebhook} size="md" />
|
|
||||||
</div>
|
|
||||||
<div className='flex flex-col gap-1'>
|
<div className='flex flex-col gap-1'>
|
||||||
<div className='system-sm-semibold text-text-secondary'>{t('workflow.debug.variableInspect.listening.title')}</div>
|
<div className='system-sm-semibold text-text-secondary'>{t('workflow.debug.variableInspect.listening.title')}</div>
|
||||||
<div className='system-xs-regular text-text-tertiary'>{message ?? t('workflow.debug.variableInspect.listening.tip')}</div>
|
<div className='system-xs-regular text-text-tertiary'>{message ?? t('workflow.debug.variableInspect.listening.tip')}</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user