From 66953d57a2848f245fae715d77e3ee39233fcf89 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 24 Sep 2024 11:59:33 +0800 Subject: [PATCH] chore: use new add sub variables --- web/app/components/base/select/index.tsx | 37 ++++++++++++------- .../if-else/components/condition-wrap.tsx | 31 ++++++++++++---- .../workflow/nodes/if-else/types.ts | 2 +- .../workflow/nodes/if-else/use-config.ts | 4 +- 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx index aa83d06a43..d701f47cd0 100644 --- a/web/app/components/base/select/index.tsx +++ b/web/app/components/base/select/index.tsx @@ -289,20 +289,26 @@ type PortalSelectProps = { onSelect: (value: Item) => void items: Item[] placeholder?: string + renderTrigger?: (value?: Item) => JSX.Element | null triggerClassName?: string triggerClassNameFn?: (open: boolean) => string popupClassName?: string + popupInnerClassName?: string readonly?: boolean + hideChecked?: boolean } const PortalSelect: FC = ({ value, onSelect, items, placeholder, + renderTrigger, triggerClassName, triggerClassNameFn, popupClassName, + popupInnerClassName, readonly, + hideChecked, }) => { const { t } = useTranslation() const [open, setOpen] = useState(false) @@ -317,26 +323,31 @@ const PortalSelect: FC = ({ offset={4} > !readonly && setOpen(v => !v)} className='w-full'> -
- + - {selectedItem?.name ?? localPlaceholder} - - -
+ > + {selectedItem?.name ?? localPlaceholder} + + + + )} +
{items.map((item: Item) => (
= ({ > {item.name} - {item.value === value && ( + {!hideChecked && item.value === value && ( )}
diff --git a/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx b/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx index 3d7a2475ce..39c03c9b38 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-wrap.tsx @@ -12,10 +12,12 @@ import type { CaseItem, HandleAddCondition, HandleAddSubVariableCondition, Handl import type { Node, NodeOutPutVar, Var } from '../../../types' import { VarType } from '../../../types' import { useGetAvailableVars } from '../../variable-assigner/hooks' +import { SUB_VARIABLES } from '../default' import ConditionList from './condition-list' import ConditionAdd from './condition-add' import cn from '@/utils/classnames' import Button from '@/app/components/base/button' +import { PortalSelect as Select } from '@/app/components/base/select' type Props = { isSubVariable?: boolean @@ -73,6 +75,11 @@ const ConditionWrap: FC = ({ return varPayload.type === VarType.number }, []) + const subVarOptions = SUB_VARIABLES.map(item => ({ + name: item, + value: item, + })) + return ( <> = ({ )}> {isSubVariable ? ( - +