Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
c20c9b53
Commit
c20c9b53
authored
Mar 08, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: template tranform support debug
parent
89fc90ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
panel.tsx
...pp/components/workflow/nodes/template-transform/panel.tsx
+26
-0
use-config.ts
...omponents/workflow/nodes/template-transform/use-config.ts
+43
-0
No files found.
web/app/components/workflow/nodes/template-transform/panel.tsx
View file @
c20c9b53
...
...
@@ -12,6 +12,7 @@ import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/
import
OutputVars
,
{
VarItem
}
from
'@/app/components/workflow/nodes/_base/components/output-vars'
import
{
HelpCircle
}
from
'@/app/components/base/icons/src/vender/line/general'
import
type
{
NodePanelProps
}
from
'@/app/components/workflow/types'
import
BeforeRunForm
from
'@/app/components/workflow/nodes/_base/components/before-run-form'
const
i18nPrefix
=
'workflow.nodes.templateTransform'
...
...
@@ -27,6 +28,15 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
handleVarListChange
,
handleAddVariable
,
handleCodeChange
,
// single run
isShowSingleRun
,
hideSingleRun
,
runningStatus
,
handleRun
,
handleStop
,
varInputs
,
inputVarValues
,
setInputVarValues
,
}
=
useConfig
(
id
,
data
)
return
(
...
...
@@ -80,6 +90,22 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
</>
</
OutputVars
>
</
div
>
{
isShowSingleRun
&&
(
<
BeforeRunForm
nodeName=
{
inputs
.
title
}
onHide=
{
hideSingleRun
}
forms=
{
[
{
inputs
:
varInputs
,
values
:
inputVarValues
,
onChange
:
setInputVarValues
,
},
]
}
runningStatus=
{
runningStatus
}
onRun=
{
handleRun
}
onStop=
{
handleStop
}
/>
)
}
</
div
>
)
}
...
...
web/app/components/workflow/nodes/template-transform/use-config.ts
View file @
c20c9b53
...
...
@@ -3,6 +3,7 @@ import produce from 'immer'
import
useVarList
from
'../_base/hooks/use-var-list'
import
type
{
TemplateTransformNodeType
}
from
'./types'
import
useNodeCrud
from
'@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import
useOneStepRun
from
'@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
const
useConfig
=
(
id
:
string
,
payload
:
TemplateTransformNodeType
)
=>
{
const
{
inputs
,
setInputs
}
=
useNodeCrud
<
TemplateTransformNodeType
>
(
id
,
payload
)
...
...
@@ -18,11 +19,53 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
setInputs
(
newInputs
)
},
[
setInputs
])
// single run
const
{
isShowSingleRun
,
hideSingleRun
,
toVarInputs
,
runningStatus
,
handleRun
,
handleStop
,
runInputData
,
setRunInputData
,
}
=
useOneStepRun
<
TemplateTransformNodeType
>
({
id
,
data
:
inputs
,
defaultRunInputData
:
{
name
:
'Joel'
,
age
:
'18'
,
},
})
const
varInputs
=
toVarInputs
(
inputs
.
variables
)
const
inputVarValues
=
(()
=>
{
const
vars
:
Record
<
string
,
any
>
=
{}
Object
.
keys
(
runInputData
)
.
forEach
((
key
)
=>
{
vars
[
key
]
=
runInputData
[
key
]
})
return
vars
})()
const
setInputVarValues
=
useCallback
((
newPayload
:
Record
<
string
,
any
>
)
=>
{
setRunInputData
(
newPayload
)
},
[
runInputData
,
setRunInputData
])
return
{
inputs
,
handleVarListChange
,
handleAddVariable
,
handleCodeChange
,
// single run
isShowSingleRun
,
hideSingleRun
,
runningStatus
,
handleRun
,
handleStop
,
varInputs
,
inputVarValues
,
setInputVarValues
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment