chore: pass specail value to fetch vars

pull/22214/head
Joel 10 months ago
parent 7cf6ef6756
commit 748c5355aa

@ -64,7 +64,10 @@ const WorkflowMain = ({
handleWorkflowStartRunInChatflow, handleWorkflowStartRunInChatflow,
handleWorkflowStartRunInWorkflow, handleWorkflowStartRunInWorkflow,
} = useWorkflowStartRun() } = useWorkflowStartRun()
const { fetchInspectVars } = useSetWorkflowVarsWithValue() const { fetchInspectVars } = useSetWorkflowVarsWithValue({
flowId: workflowStore.getState().appId,
...useConfigsMap(),
})
const { const {
hasNodeInspectVars, hasNodeInspectVars,
hasSetInspectVar, hasSetInspectVar,

@ -21,6 +21,7 @@ import { noop } from 'lodash-es'
import { useNodesSyncDraft } from './use-nodes-sync-draft' import { useNodesSyncDraft } from './use-nodes-sync-draft'
import { useInvalidAllLastRun } from '@/service/use-workflow' import { useInvalidAllLastRun } from '@/service/use-workflow'
import { useSetWorkflowVarsWithValue } from '../../workflow/hooks/use-fetch-workflow-inspect-vars' import { useSetWorkflowVarsWithValue } from '../../workflow/hooks/use-fetch-workflow-inspect-vars'
import { useConfigsMap } from './use-configs-map'
export const useWorkflowRun = () => { export const useWorkflowRun = () => {
const store = useStoreApi() const store = useStoreApi()
@ -32,7 +33,11 @@ export const useWorkflowRun = () => {
const pathname = usePathname() const pathname = usePathname()
const appId = useAppStore.getState().appDetail?.id const appId = useAppStore.getState().appDetail?.id
const invalidAllLastRun = useInvalidAllLastRun(appId as string) const invalidAllLastRun = useInvalidAllLastRun(appId as string)
const { fetchInspectVars } = useSetWorkflowVarsWithValue() const configsMap = useConfigsMap()
const { fetchInspectVars } = useSetWorkflowVarsWithValue({
flowId: appId as string,
...configsMap,
})
const { const {
handleWorkflowStarted, handleWorkflowStarted,

@ -6,12 +6,20 @@ import type { Node } from '@/app/components/workflow/types'
import { fetchAllInspectVars } from '@/service/workflow' import { fetchAllInspectVars } from '@/service/workflow'
import { useInvalidateConversationVarValues, useInvalidateSysVarValues } from '@/service/use-workflow' import { useInvalidateConversationVarValues, useInvalidateSysVarValues } from '@/service/use-workflow'
import { useNodesInteractionsWithoutSync } from '@/app/components/workflow/hooks/use-nodes-interactions-without-sync' import { useNodesInteractionsWithoutSync } from '@/app/components/workflow/hooks/use-nodes-interactions-without-sync'
import { useConfigsMap } from '../../workflow-app/hooks/use-configs-map'
export const useSetWorkflowVarsWithValue = () => { type Params = {
flowId: string
conversationVarsUrl: string
systemVarsUrl: string
}
export const useSetWorkflowVarsWithValue = ({
flowId,
conversationVarsUrl,
systemVarsUrl,
}: Params) => {
const workflowStore = useWorkflowStore() const workflowStore = useWorkflowStore()
const store = useStoreApi() const store = useStoreApi()
const { conversationVarsUrl, systemVarsUrl } = useConfigsMap()
const invalidateConversationVarValues = useInvalidateConversationVarValues(conversationVarsUrl) const invalidateConversationVarValues = useInvalidateConversationVarValues(conversationVarsUrl)
const invalidateSysVarValues = useInvalidateSysVarValues(systemVarsUrl) const invalidateSysVarValues = useInvalidateSysVarValues(systemVarsUrl)
const { handleCancelAllNodeSuccessStatus } = useNodesInteractionsWithoutSync() const { handleCancelAllNodeSuccessStatus } = useNodesInteractionsWithoutSync()
@ -58,13 +66,12 @@ export const useSetWorkflowVarsWithValue = () => {
}, [workflowStore, store]) }, [workflowStore, store])
const fetchInspectVars = useCallback(async () => { const fetchInspectVars = useCallback(async () => {
const { appId } = workflowStore.getState()
invalidateConversationVarValues() invalidateConversationVarValues()
invalidateSysVarValues() invalidateSysVarValues()
const data = await fetchAllInspectVars(appId) const data = await fetchAllInspectVars(flowId)
setInspectVarsToStore(data) setInspectVarsToStore(data)
handleCancelAllNodeSuccessStatus() // to make sure clear node output show the unset status handleCancelAllNodeSuccessStatus() // to make sure clear node output show the unset status
}, [workflowStore, invalidateConversationVarValues, invalidateSysVarValues, setInspectVarsToStore, handleCancelAllNodeSuccessStatus]) }, [invalidateConversationVarValues, invalidateSysVarValues, flowId, setInspectVarsToStore, handleCancelAllNodeSuccessStatus])
return { return {
fetchInspectVars, fetchInspectVars,
} }

@ -31,7 +31,6 @@ export const useInspectVarsCrudCommon = ({
systemVarsUrl, systemVarsUrl,
}: Params) => { }: Params) => {
const workflowStore = useWorkflowStore() const workflowStore = useWorkflowStore()
console.log(conversationVarsUrl, flowId)
const invalidateConversationVarValues = useInvalidateConversationVarValues(conversationVarsUrl!) const invalidateConversationVarValues = useInvalidateConversationVarValues(conversationVarsUrl!)
const { mutateAsync: doResetConversationVar } = useResetConversationVar(flowId) const { mutateAsync: doResetConversationVar } = useResetConversationVar(flowId)
const { mutateAsync: doResetToLastRunValue } = useResetToLastRunValue(flowId) const { mutateAsync: doResetToLastRunValue } = useResetToLastRunValue(flowId)

Loading…
Cancel
Save