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
e39d7021
Commit
e39d7021
authored
Feb 21, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: if else node
parent
cffaf307
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
1 deletion
+72
-1
node.tsx
web/app/components/workflow/nodes/if-else/node.tsx
+33
-1
utils.ts
web/app/components/workflow/nodes/if-else/utils.ts
+5
-0
workflow.en.ts
web/i18n/lang/workflow.en.ts
+17
-0
workflow.zh.ts
web/i18n/lang/workflow.zh.ts
+17
-0
No files found.
web/app/components/workflow/nodes/if-else/node.tsx
View file @
e39d7021
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
mockData
}
from
'./mock'
import
{
ComparisonOperator
}
from
'./types'
import
{
isEmptyRelatedOperator
}
from
'./utils'
import
{
Variable02
}
from
'@/app/components/base/icons/src/vender/solid/development'
const
i18nPrefix
=
'workflow.nodes.ifElse'
const
notTranslateKey
=
[
ComparisonOperator
.
equal
,
ComparisonOperator
.
notEqual
,
ComparisonOperator
.
largerThan
,
ComparisonOperator
.
largerThanOrEqual
,
ComparisonOperator
.
lessThan
,
ComparisonOperator
.
lessThanOrEqual
,
]
const
Node
:
FC
=
()
=>
{
const
Node
:
FC
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
conditions
,
logical_operator
}
=
mockData
return
(
return
(
<
div
>
if else
</
div
>
<
div
className=
'px-3'
>
<
div
className=
'mb-0.5 leading-4 text-[10px] font-medium text-gray-500 uppercase'
>
{
t
(
`${i18nPrefix}.conditions`
)
}
</
div
>
<
div
className=
'space-y-0.5'
>
{
conditions
.
map
((
condition
,
i
)
=>
(
<
div
key=
{
condition
.
id
}
className=
'relative'
>
<
div
className=
'flex items-center h-6 bg-gray-100 rounded-md px-1 space-x-1 text-xs font-normal text-gray-700'
>
<
Variable02
className=
'w-3.5 h-3.5 text-primary-500'
/>
<
span
>
{
condition
.
variable_selector
.
slice
(
-
1
)[
0
]
}
</
span
>
<
span
className=
'text-gray-500'
>
{
notTranslateKey
.
includes
(
condition
.
comparison_operator
)
?
condition
.
comparison_operator
:
t
(
`${i18nPrefix}.comparisonOperator.${condition.comparison_operator}`
)
}
</
span
>
{
!
isEmptyRelatedOperator
(
condition
.
comparison_operator
)
&&
<
span
>
{
condition
.
value
}
</
span
>
}
</
div
>
{
i
!==
conditions
.
length
-
1
&&
(
<
div
className=
'absolute z-10 right-0 bottom-[-10px] leading-4 text-[10px] font-medium text-primary-600 uppercase'
>
{
t
(
`${i18nPrefix}.${logical_operator}`
)
}
</
div
>
)
}
</
div
>
))
}
</
div
>
</
div
>
)
)
}
}
...
...
web/app/components/workflow/nodes/if-else/utils.ts
0 → 100644
View file @
e39d7021
import
{
ComparisonOperator
}
from
'./types'
export
const
isEmptyRelatedOperator
=
(
operator
:
ComparisonOperator
)
=>
{
return
[
ComparisonOperator
.
empty
,
ComparisonOperator
.
notEmpty
,
ComparisonOperator
.
isNull
,
ComparisonOperator
.
isNotNull
].
includes
(
operator
)
}
web/i18n/lang/workflow.en.ts
View file @
e39d7021
...
@@ -43,6 +43,23 @@ const translation = {
...
@@ -43,6 +43,23 @@ const translation = {
output
:
'Transformed content'
,
output
:
'Transformed content'
,
},
},
},
},
ifElse
:
{
conditions
:
'Conditions'
,
and
:
'and'
,
or
:
'or'
,
comparisonOperator
:
{
'contains'
:
'contains'
,
'not contains'
:
'not contains'
,
'start with'
:
'start with'
,
'end with'
:
'end with'
,
'is'
:
'is'
,
'is not'
:
'is not'
,
'empty'
:
'empty'
,
'not empty'
:
'not empty'
,
'null'
:
'is null'
,
'not null'
:
'is not null'
,
},
},
},
},
}
}
...
...
web/i18n/lang/workflow.zh.ts
View file @
e39d7021
...
@@ -43,6 +43,23 @@ const translation = {
...
@@ -43,6 +43,23 @@ const translation = {
output
:
'转换后内容'
,
output
:
'转换后内容'
,
},
},
},
},
ifElse
:
{
conditions
:
'条件'
,
and
:
'且'
,
or
:
'或'
,
comparisonOperator
:
{
'contains'
:
'包含'
,
'not contains'
:
'不包含'
,
'start with'
:
'开始是'
,
'end with'
:
'结束是'
,
'is'
:
'是'
,
'is not'
:
'不是'
,
'empty'
:
'为空'
,
'not empty'
:
'不为空'
,
'null'
:
'空'
,
'not null'
:
'不为空'
,
},
},
},
},
}
}
...
...
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