feat: introduce trigger functionality (#27644)
Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,12 @@ export const createChatVariableSlice: StateCreator<ChatVariableSliceShape> = (se
|
||||
|
||||
return ({
|
||||
showChatVariablePanel: false,
|
||||
setShowChatVariablePanel: showChatVariablePanel => set(() => ({ showChatVariablePanel })),
|
||||
setShowChatVariablePanel: showChatVariablePanel => set(() => {
|
||||
if (showChatVariablePanel)
|
||||
return { ...hideAllPanel, showChatVariablePanel: true }
|
||||
else
|
||||
return { showChatVariablePanel: false }
|
||||
}),
|
||||
showGlobalVariablePanel: false,
|
||||
setShowGlobalVariablePanel: showGlobalVariablePanel => set(() => {
|
||||
if (showGlobalVariablePanel)
|
||||
|
||||
@@ -10,11 +10,24 @@ export type EnvVariableSliceShape = {
|
||||
setEnvSecrets: (envSecrets: Record<string, string>) => void
|
||||
}
|
||||
|
||||
export const createEnvVariableSlice: StateCreator<EnvVariableSliceShape> = set => ({
|
||||
showEnvPanel: false,
|
||||
setShowEnvPanel: showEnvPanel => set(() => ({ showEnvPanel })),
|
||||
environmentVariables: [],
|
||||
setEnvironmentVariables: environmentVariables => set(() => ({ environmentVariables })),
|
||||
envSecrets: {},
|
||||
setEnvSecrets: envSecrets => set(() => ({ envSecrets })),
|
||||
})
|
||||
export const createEnvVariableSlice: StateCreator<EnvVariableSliceShape> = (set) => {
|
||||
const hideAllPanel = {
|
||||
showDebugAndPreviewPanel: false,
|
||||
showEnvPanel: false,
|
||||
showChatVariablePanel: false,
|
||||
showGlobalVariablePanel: false,
|
||||
}
|
||||
return ({
|
||||
showEnvPanel: false,
|
||||
setShowEnvPanel: showEnvPanel => set(() => {
|
||||
if (showEnvPanel)
|
||||
return { ...hideAllPanel, showEnvPanel: true }
|
||||
else
|
||||
return { showEnvPanel: false }
|
||||
}),
|
||||
environmentVariables: [],
|
||||
setEnvironmentVariables: environmentVariables => set(() => ({ environmentVariables })),
|
||||
envSecrets: {},
|
||||
setEnvSecrets: envSecrets => set(() => ({ envSecrets })),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,6 +48,11 @@ export type NodeSliceShape = {
|
||||
setLoopTimes: (loopTimes: number) => void
|
||||
iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>
|
||||
setIterParallelLogMap: (iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>) => void
|
||||
pendingSingleRun?: {
|
||||
nodeId: string
|
||||
action: 'run' | 'stop'
|
||||
}
|
||||
setPendingSingleRun: (payload?: NodeSliceShape['pendingSingleRun']) => void
|
||||
}
|
||||
|
||||
export const createNodeSlice: StateCreator<NodeSliceShape> = set => ({
|
||||
@@ -73,4 +78,6 @@ export const createNodeSlice: StateCreator<NodeSliceShape> = set => ({
|
||||
setLoopTimes: loopTimes => set(() => ({ loopTimes })),
|
||||
iterParallelLogMap: new Map<string, Map<string, NodeTracing[]>>(),
|
||||
setIterParallelLogMap: iterParallelLogMap => set(() => ({ iterParallelLogMap })),
|
||||
pendingSingleRun: undefined,
|
||||
setPendingSingleRun: payload => set(() => ({ pendingSingleRun: payload })),
|
||||
})
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
import type { ToolWithProvider } from '../../types'
|
||||
|
||||
export type ToolSliceShape = {
|
||||
toolPublished: boolean
|
||||
setToolPublished: (toolPublished: boolean) => void
|
||||
lastPublishedHasUserInput: boolean
|
||||
setLastPublishedHasUserInput: (hasUserInput: boolean) => void
|
||||
buildInTools?: ToolWithProvider[]
|
||||
customTools?: ToolWithProvider[]
|
||||
workflowTools?: ToolWithProvider[]
|
||||
mcpTools?: ToolWithProvider[]
|
||||
}
|
||||
|
||||
export const createToolSlice: StateCreator<ToolSliceShape> = set => ({
|
||||
toolPublished: false,
|
||||
setToolPublished: toolPublished => set(() => ({ toolPublished })),
|
||||
lastPublishedHasUserInput: false,
|
||||
setLastPublishedHasUserInput: hasUserInput => set(() => ({ lastPublishedHasUserInput: hasUserInput })),
|
||||
buildInTools: undefined,
|
||||
customTools: undefined,
|
||||
workflowTools: undefined,
|
||||
mcpTools: undefined,
|
||||
})
|
||||
|
||||
@@ -21,6 +21,8 @@ export type WorkflowDraftSliceShape = {
|
||||
setSyncWorkflowDraftHash: (hash: string) => void
|
||||
isSyncingWorkflowDraft: boolean
|
||||
setIsSyncingWorkflowDraft: (isSyncingWorkflowDraft: boolean) => void
|
||||
isWorkflowDataLoaded: boolean
|
||||
setIsWorkflowDataLoaded: (loaded: boolean) => void
|
||||
}
|
||||
|
||||
export const createWorkflowDraftSlice: StateCreator<WorkflowDraftSliceShape> = set => ({
|
||||
@@ -33,4 +35,6 @@ export const createWorkflowDraftSlice: StateCreator<WorkflowDraftSliceShape> = s
|
||||
setSyncWorkflowDraftHash: syncWorkflowDraftHash => set(() => ({ syncWorkflowDraftHash })),
|
||||
isSyncingWorkflowDraft: false,
|
||||
setIsSyncingWorkflowDraft: isSyncingWorkflowDraft => set(() => ({ isSyncingWorkflowDraft })),
|
||||
isWorkflowDataLoaded: false,
|
||||
setIsWorkflowDataLoaded: loaded => set(() => ({ isWorkflowDataLoaded: loaded })),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
import type {
|
||||
Node,
|
||||
TriggerNodeType,
|
||||
WorkflowRunningData,
|
||||
} from '@/app/components/workflow/types'
|
||||
import type { FileUploadConfigResponse } from '@/models/common'
|
||||
@@ -13,6 +14,16 @@ type PreviewRunningData = WorkflowRunningData & {
|
||||
export type WorkflowSliceShape = {
|
||||
workflowRunningData?: PreviewRunningData
|
||||
setWorkflowRunningData: (workflowData: PreviewRunningData) => void
|
||||
isListening: boolean
|
||||
setIsListening: (listening: boolean) => void
|
||||
listeningTriggerType: TriggerNodeType | null
|
||||
setListeningTriggerType: (triggerType: TriggerNodeType | null) => void
|
||||
listeningTriggerNodeId: string | null
|
||||
setListeningTriggerNodeId: (nodeId: string | null) => void
|
||||
listeningTriggerNodeIds: string[]
|
||||
setListeningTriggerNodeIds: (nodeIds: string[]) => void
|
||||
listeningTriggerIsAll: boolean
|
||||
setListeningTriggerIsAll: (isAll: boolean) => void
|
||||
clipboardElements: Node[]
|
||||
setClipboardElements: (clipboardElements: Node[]) => void
|
||||
selection: null | { x1: number; y1: number; x2: number; y2: number }
|
||||
@@ -36,6 +47,16 @@ export type WorkflowSliceShape = {
|
||||
export const createWorkflowSlice: StateCreator<WorkflowSliceShape> = set => ({
|
||||
workflowRunningData: undefined,
|
||||
setWorkflowRunningData: workflowRunningData => set(() => ({ workflowRunningData })),
|
||||
isListening: false,
|
||||
setIsListening: listening => set(() => ({ isListening: listening })),
|
||||
listeningTriggerType: null,
|
||||
setListeningTriggerType: triggerType => set(() => ({ listeningTriggerType: triggerType })),
|
||||
listeningTriggerNodeId: null,
|
||||
setListeningTriggerNodeId: nodeId => set(() => ({ listeningTriggerNodeId: nodeId })),
|
||||
listeningTriggerNodeIds: [],
|
||||
setListeningTriggerNodeIds: nodeIds => set(() => ({ listeningTriggerNodeIds: nodeIds })),
|
||||
listeningTriggerIsAll: false,
|
||||
setListeningTriggerIsAll: isAll => set(() => ({ listeningTriggerIsAll: isAll })),
|
||||
clipboardElements: [],
|
||||
setClipboardElements: clipboardElements => set(() => ({ clipboardElements })),
|
||||
selection: null,
|
||||
|
||||
Reference in New Issue
Block a user