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
d0f5318b
Commit
d0f5318b
authored
Mar 13, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: code node can run
parent
c74854ae
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
7 deletions
+18
-7
index.tsx
...workflow/nodes/_base/components/before-run-form/index.tsx
+2
-3
use-one-step-run.ts
...components/workflow/nodes/_base/hooks/use-one-step-run.ts
+3
-1
panel.tsx
web/app/components/workflow/nodes/code/panel.tsx
+2
-2
use-config.ts
web/app/components/workflow/nodes/code/use-config.ts
+11
-1
No files found.
web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx
View file @
d0f5318b
...
@@ -79,12 +79,11 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
...
@@ -79,12 +79,11 @@ const BeforeRunForm: FC<BeforeRunFormProps> = ({
</
div
>
</
div
>
{
isFinished
&&
(
{
isFinished
&&
(
<
div
className=
'px-4'
>
<>
{
result
}
{
result
}
</
div
>
</>
)
}
)
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
)
)
...
...
web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts
View file @
d0f5318b
...
@@ -64,7 +64,9 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
...
@@ -64,7 +64,9 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
})
})
return
false
return
false
}
}
finally
{
setRunResult
(
res
)
setRunResult
(
res
)
}
handleNodeDataUpdate
({
handleNodeDataUpdate
({
id
,
id
,
data
:
{
data
:
{
...
...
web/app/components/workflow/nodes/code/panel.tsx
View file @
d0f5318b
...
@@ -13,7 +13,7 @@ import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/
...
@@ -13,7 +13,7 @@ import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/
import
TypeSelector
from
'@/app/components/workflow/nodes/_base/components/selector'
import
TypeSelector
from
'@/app/components/workflow/nodes/_base/components/selector'
import
type
{
NodePanelProps
}
from
'@/app/components/workflow/types'
import
type
{
NodePanelProps
}
from
'@/app/components/workflow/types'
import
BeforeRunForm
from
'@/app/components/workflow/nodes/_base/components/before-run-form'
import
BeforeRunForm
from
'@/app/components/workflow/nodes/_base/components/before-run-form'
import
ResultPanel
from
'@/app/components/workflow/run/result-panel'
const
i18nPrefix
=
'workflow.nodes.code'
const
i18nPrefix
=
'workflow.nodes.code'
const
codeLanguages
=
[
const
codeLanguages
=
[
...
@@ -113,7 +113,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
...
@@ -113,7 +113,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
runningStatus=
{
runningStatus
}
runningStatus=
{
runningStatus
}
onRun=
{
handleRun
}
onRun=
{
handleRun
}
onStop=
{
handleStop
}
onStop=
{
handleStop
}
result=
{
<
span
className=
'text-gray-900'
>
{
JSON
.
stringify
(
runResult
,
null
,
2
)
}
</
span
>
}
result=
{
<
ResultPanel
{
...
runResult
}
showSteps=
{
false
}
/
>
}
/>
/>
)
}
)
}
</
div
>
</
div
>
...
...
web/app/components/workflow/nodes/code/use-config.ts
View file @
d0f5318b
...
@@ -43,12 +43,22 @@ const useConfig = (id: string, payload: CodeNodeType) => {
...
@@ -43,12 +43,22 @@ const useConfig = (id: string, payload: CodeNodeType) => {
handleStop
,
handleStop
,
runInputData
,
runInputData
,
setRunInputData
,
setRunInputData
,
runResult
,
runResult
:
unformattedRunResult
,
}
=
useOneStepRun
<
CodeNodeType
>
({
}
=
useOneStepRun
<
CodeNodeType
>
({
id
,
id
,
data
:
inputs
,
data
:
inputs
,
defaultRunInputData
:
{},
defaultRunInputData
:
{},
})
})
const
runResult
=
(()
=>
{
if
(
!
unformattedRunResult
)
return
{}
return
{
...
unformattedRunResult
,
created_by
:
unformattedRunResult
.
created_by_account
?.
name
||
''
,
}
})()
const
varInputs
=
toVarInputs
(
inputs
.
variables
)
const
varInputs
=
toVarInputs
(
inputs
.
variables
)
const
inputVarValues
=
(()
=>
{
const
inputVarValues
=
(()
=>
{
...
...
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