From 5628b293f8de9bf1f6befdddeae792230f96830c Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 21 Aug 2024 14:54:06 +0800 Subject: [PATCH] feat: sub var if condindion postion --- .../condition-list/condition-item.tsx | 10 +++-- .../components/condition-list/index.tsx | 37 +++++++++++++------ .../if-else/components/condition-wrap.tsx | 2 +- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx index 6f06619c98..02b4f36f85 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx @@ -37,6 +37,7 @@ import { Variable02 } from '@/app/components/base/icons/src/vender/solid/develop const optionNameI18NPrefix = 'workflow.nodes.ifElse.optionName' type ConditionItemProps = { + className?: string disabled?: boolean caseId: string conditionId: string // in isSubVariableKey it's the value of the parent condition's id @@ -55,6 +56,7 @@ type ConditionItemProps = { numberVariables: NodeOutPutVar[] } const ConditionItem = ({ + className, disabled, caseId, conditionId, @@ -151,7 +153,7 @@ const ConditionItem = ({ }, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition]) return ( -
+
( item ?
-
- -
{item?.name}
+
+ +
{item?.name}
:
{t('common.placeholder.select')}
diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx index 4eb95e8749..bc67f807c3 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/index.tsx @@ -1,14 +1,15 @@ import { RiLoopLeftLine } from '@remixicon/react' -import { useCallback } from 'react' -import type { - CaseItem, - HandleAddSubVariableCondition, - HandleRemoveCondition, - HandleToggleConditionLogicalOperator, - HandleToggleSubVariableConditionLogicalOperator, - HandleUpdateCondition, - HandleUpdateSubVariableCondition, - handleRemoveSubVariableCondition, +import { useCallback, useMemo } from 'react' +import { + type CaseItem, + type HandleAddSubVariableCondition, + type HandleRemoveCondition, + type HandleToggleConditionLogicalOperator, + type HandleToggleSubVariableConditionLogicalOperator, + type HandleUpdateCondition, + type HandleUpdateSubVariableCondition, + LogicalOperator, + type handleRemoveSubVariableCondition, } from '../../types' import ConditionItem from './condition-item' import type { @@ -62,15 +63,26 @@ const ConditionList = ({ onToggleConditionLogicalOperator?.(caseId) }, [caseId, conditionId, isSubVariable, onToggleConditionLogicalOperator, onToggleSubVariableConditionLogicalOperator]) + const conditionItemClassName = useMemo(() => { + if (!isSubVariable) + return '' + if (conditions.length < 2) + return '' + return logical_operator === LogicalOperator.and ? 'pl-[51px]' : 'pl-[42px]' + }, [conditions.length, isSubVariable, logical_operator]) return (
{ conditions.length > 1 && ( -
+
{logical_operator.toUpperCase()} @@ -83,6 +95,7 @@ const ConditionList = ({ caseItem.conditions.map(condition => ( = ({ 'group relative rounded-[10px] bg-components-panel-bg', willDeleteCaseId === item.case_id && 'bg-state-destructive-hover', !isSubVariable && 'py-1 px-3 min-h-[40px] ', - isSubVariable && 'p-2 pr-1', + isSubVariable && 'px-1 py-2', )} > {!isSubVariable && (