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
1653e5ee
Commit
1653e5ee
authored
Mar 13, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: template transform
parent
cedc1bad
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
20 deletions
+19
-20
use-one-step-run.ts
...components/workflow/nodes/_base/hooks/use-one-step-run.ts
+13
-10
use-config.ts
web/app/components/workflow/nodes/code/use-config.ts
+1
-10
panel.tsx
...pp/components/workflow/nodes/template-transform/panel.tsx
+3
-0
use-config.ts
...omponents/workflow/nodes/template-transform/use-config.ts
+2
-0
No files found.
web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts
View file @
1653e5ee
...
@@ -5,7 +5,7 @@ import type { CommonNodeType, InputVar, Variable } from '@/app/components/workfl
...
@@ -5,7 +5,7 @@ import type { CommonNodeType, InputVar, Variable } from '@/app/components/workfl
import
{
InputVarType
,
NodeRunningStatus
}
from
'@/app/components/workflow/types'
import
{
InputVarType
,
NodeRunningStatus
}
from
'@/app/components/workflow/types'
import
{
useStore
as
useAppStore
}
from
'@/app/components/app/store'
import
{
useStore
as
useAppStore
}
from
'@/app/components/app/store'
import
{
singleNodeRun
}
from
'@/service/workflow'
import
{
singleNodeRun
}
from
'@/service/workflow'
import
Toast
from
'@/app/components/base/toast'
//
import Toast from '@/app/components/base/toast'
type
Params
<
T
>
=
{
type
Params
<
T
>
=
{
id
:
string
id
:
string
...
@@ -51,10 +51,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
...
@@ -51,10 +51,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
throw
new
Error
(
res
.
error
)
throw
new
Error
(
res
.
error
)
}
}
catch
(
e
:
any
)
{
catch
(
e
:
any
)
{
Toast
.
notify
({
//
Toast.notify({
type
:
'error'
,
//
type: 'error',
message
:
e
.
toString
(),
//
message: e.toString(),
})
//
})
handleNodeDataUpdate
({
handleNodeDataUpdate
({
id
,
id
,
data
:
{
data
:
{
...
@@ -65,7 +65,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
...
@@ -65,7 +65,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
return
false
return
false
}
}
finally
{
finally
{
setRunResult
(
res
)
setRunResult
({
...
res
,
created_by
:
res
.
created_by_account
?.
name
||
''
,
})
}
}
handleNodeDataUpdate
({
handleNodeDataUpdate
({
id
,
id
,
...
@@ -74,10 +77,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
...
@@ -74,10 +77,10 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
_singleRunningStatus
:
NodeRunningStatus
.
Succeeded
,
_singleRunningStatus
:
NodeRunningStatus
.
Succeeded
,
},
},
})
})
Toast
.
notify
({
//
Toast.notify({
type
:
'success'
,
//
type: 'success',
message
:
t
(
'common.api.success'
),
//
message: t('common.api.success'),
})
//
})
}
}
const
handleStop
=
()
=>
{
const
handleStop
=
()
=>
{
...
...
web/app/components/workflow/nodes/code/use-config.ts
View file @
1653e5ee
...
@@ -43,22 +43,13 @@ const useConfig = (id: string, payload: CodeNodeType) => {
...
@@ -43,22 +43,13 @@ const useConfig = (id: string, payload: CodeNodeType) => {
handleStop
,
handleStop
,
runInputData
,
runInputData
,
setRunInputData
,
setRunInputData
,
runResult
:
unformattedRunResult
,
runResult
,
}
=
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
=
(()
=>
{
...
...
web/app/components/workflow/nodes/template-transform/panel.tsx
View file @
1653e5ee
...
@@ -13,6 +13,7 @@ import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/compo
...
@@ -13,6 +13,7 @@ import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/compo
import
{
HelpCircle
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
HelpCircle
}
from
'@/app/components/base/icons/src/vender/line/general'
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.templateTransform'
const
i18nPrefix
=
'workflow.nodes.templateTransform'
...
@@ -37,6 +38,7 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
...
@@ -37,6 +38,7 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
varInputs
,
varInputs
,
inputVarValues
,
inputVarValues
,
setInputVarValues
,
setInputVarValues
,
runResult
,
}
=
useConfig
(
id
,
data
)
}
=
useConfig
(
id
,
data
)
return
(
return
(
...
@@ -105,6 +107,7 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
...
@@ -105,6 +107,7 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
runningStatus=
{
runningStatus
}
runningStatus=
{
runningStatus
}
onRun=
{
handleRun
}
onRun=
{
handleRun
}
onStop=
{
handleStop
}
onStop=
{
handleStop
}
result=
{
<
ResultPanel
{
...
runResult
}
showSteps=
{
false
}
/>
}
/>
/>
)
}
)
}
</
div
>
</
div
>
...
...
web/app/components/workflow/nodes/template-transform/use-config.ts
View file @
1653e5ee
...
@@ -29,6 +29,7 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
...
@@ -29,6 +29,7 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
handleStop
,
handleStop
,
runInputData
,
runInputData
,
setRunInputData
,
setRunInputData
,
runResult
,
}
=
useOneStepRun
<
TemplateTransformNodeType
>
({
}
=
useOneStepRun
<
TemplateTransformNodeType
>
({
id
,
id
,
data
:
inputs
,
data
:
inputs
,
...
@@ -63,6 +64,7 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
...
@@ -63,6 +64,7 @@ const useConfig = (id: string, payload: TemplateTransformNodeType) => {
varInputs
,
varInputs
,
inputVarValues
,
inputVarValues
,
setInputVarValues
,
setInputVarValues
,
runResult
,
}
}
}
}
...
...
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