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
17e8c912
Commit
17e8c912
authored
Feb 21, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: template transform panel content
parent
db7dccf3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
110 additions
and
8 deletions
+110
-8
page.tsx
web/app/(commonLayout)/workflow/nodes/page.tsx
+2
-2
code-editor.tsx
...ts/workflow/nodes/_base/components/editor/code-editor.tsx
+0
-3
panel.tsx
web/app/components/workflow/nodes/code/panel.tsx
+0
-2
mock.ts
web/app/components/workflow/nodes/template-transform/mock.ts
+18
-0
panel.tsx
...pp/components/workflow/nodes/template-transform/panel.tsx
+52
-1
use-config.ts
...omponents/workflow/nodes/template-transform/use-config.ts
+24
-0
workflow.en.ts
web/i18n/lang/workflow.en.ts
+7
-0
workflow.zh.ts
web/i18n/lang/workflow.zh.ts
+7
-0
No files found.
web/app/(commonLayout)/workflow/nodes/page.tsx
View file @
17e8c912
...
@@ -46,9 +46,9 @@ const Page: FC = () => {
...
@@ -46,9 +46,9 @@ const Page: FC = () => {
/*
/*
* TODO: for debug.
* TODO: for debug.
* 2 directAnswer 3: llm 5: questionClassifier
* 2 directAnswer 3: llm 5: questionClassifier
* 7 Code
* 7 Code
, 8 TemplateTransform
*/
*/
selectedNodeId=
'
7
'
selectedNodeId=
'
8
'
/>
/>
</
div
>
</
div
>
)
)
...
...
web/app/components/workflow/nodes/_base/components/editor/code-editor.tsx
View file @
17e8c912
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
React
from
'react'
import
type
{
CodeLanguage
}
from
'../../../code/types'
import
Base
from
'./base'
import
Base
from
'./base'
type
Props
=
{
type
Props
=
{
value
:
string
value
:
string
onChange
:
(
value
:
string
)
=>
void
onChange
:
(
value
:
string
)
=>
void
title
:
JSX
.
Element
title
:
JSX
.
Element
codeLanguage
:
string
onCodeLanguageChange
:
(
codeLanguage
:
CodeLanguage
)
=>
void
}
}
const
CodeEditor
:
FC
<
Props
>
=
({
const
CodeEditor
:
FC
<
Props
>
=
({
...
...
web/app/components/workflow/nodes/code/panel.tsx
View file @
17e8c912
...
@@ -57,8 +57,6 @@ const Panel: FC = () => {
...
@@ -57,8 +57,6 @@ const Panel: FC = () => {
}
}
value=
{
inputs
.
code
}
value=
{
inputs
.
code
}
onChange=
{
handleCodeChange
}
onChange=
{
handleCodeChange
}
codeLanguage=
{
inputs
.
code_language
}
onCodeLanguageChange=
{
handleCodeLanguageChange
}
/>
/>
<
Split
/>
<
Split
/>
</
div
>
</
div
>
...
...
web/app/components/workflow/nodes/template-transform/mock.ts
0 → 100644
View file @
17e8c912
import
type
{
TemplateTransformNodeType
}
from
'./types'
export
const
mockData
:
TemplateTransformNodeType
=
{
title
:
'Test'
,
desc
:
'Test'
,
type
:
'Test'
,
variables
:
[
{
variable
:
'name'
,
value_selector
:
[
'aaa'
,
'name'
],
},
{
variable
:
'age'
,
value_selector
:
[
'bbb'
,
'b'
,
'c'
],
},
],
template
:
'print("hello world")'
,
}
web/app/components/workflow/nodes/template-transform/panel.tsx
View file @
17e8c912
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
useConfig
from
'./use-config'
import
{
mockData
}
from
'./mock'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
import
AddButton
from
'@/app/components/base/button/add-button'
import
Field
from
'@/app/components/workflow/nodes/_base/components/field'
import
Split
from
'@/app/components/workflow/nodes/_base/components/split'
import
CodeEditor
from
'@/app/components/workflow/nodes/_base/components/editor/code-editor'
import
OutputVars
,
{
VarItem
}
from
'@/app/components/workflow/nodes/_base/components/output-vars'
const
i18nPrefix
=
'workflow.nodes.templateTransform'
const
Panel
:
FC
=
()
=>
{
const
Panel
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
readOnly
=
false
const
{
inputs
,
handleVarListChange
,
handleAddVariable
,
handleCodeChange
,
}
=
useConfig
(
mockData
)
return
(
return
(
<
div
>
start panel inputs
</
div
>
<
div
className=
'mt-2 px-4 space-y-4'
>
<
Field
title=
{
t
(
`${i18nPrefix}.inputVars`
)
}
operations=
{
<
AddButton
onClick=
{
handleAddVariable
}
/>
}
>
<
VarList
readonly=
{
readOnly
}
list=
{
inputs
.
variables
}
onChange=
{
handleVarListChange
}
/>
</
Field
>
<
Split
/>
<
CodeEditor
title=
{
<
div
>
{
t
(
`${i18nPrefix}.code`
)
}
</
div
>
}
value=
{
inputs
.
template
}
onChange=
{
handleCodeChange
}
/>
<
Split
/>
<
OutputVars
>
<>
<
VarItem
name=
'output'
type=
'string'
description=
{
t
(
`${i18nPrefix}.outputVars.output`
)
}
/>
</>
</
OutputVars
>
</
div
>
)
)
}
}
...
...
web/app/components/workflow/nodes/template-transform/use-config.ts
0 → 100644
View file @
17e8c912
import
{
useCallback
,
useState
}
from
'react'
import
useVarList
from
'../_base/hooks/use-var-list'
import
type
{
TemplateTransformNodeType
}
from
'./types'
const
useConfig
=
(
initInputs
:
TemplateTransformNodeType
)
=>
{
const
[
inputs
,
setInputs
]
=
useState
<
TemplateTransformNodeType
>
(
initInputs
)
const
{
handleVarListChange
,
handleAddVariable
}
=
useVarList
<
TemplateTransformNodeType
>
({
inputs
,
setInputs
,
})
const
handleCodeChange
=
useCallback
((
template
:
string
)
=>
{
setInputs
(
prev
=>
({
...
prev
,
template
}))
},
[
setInputs
])
return
{
inputs
,
handleVarListChange
,
handleAddVariable
,
handleCodeChange
,
}
}
export
default
useConfig
web/i18n/lang/workflow.en.ts
View file @
17e8c912
...
@@ -22,6 +22,13 @@ const translation = {
...
@@ -22,6 +22,13 @@ const translation = {
code
:
{
code
:
{
inputVars
:
'Input Variables'
,
inputVars
:
'Input Variables'
,
},
},
templateTransform
:
{
inputVars
:
'Input Variables'
,
code
:
'Code'
,
outputVars
:
{
output
:
'Transformed content'
,
},
},
},
},
}
}
...
...
web/i18n/lang/workflow.zh.ts
View file @
17e8c912
...
@@ -21,6 +21,13 @@ const translation = {
...
@@ -21,6 +21,13 @@ const translation = {
code
:
{
code
:
{
inputVars
:
'输入变量'
,
inputVars
:
'输入变量'
,
},
},
templateTransform
:
{
inputVars
:
'输入变量'
,
code
:
'代码'
,
outputVars
:
{
output
:
'转换后内容'
,
},
},
},
},
},
},
}
}
...
...
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