feat: support var remove in code node

This commit is contained in:
Joel
2024-03-22 15:20:09 +08:00
parent 340ae3c52f
commit 5843b30a13
3 changed files with 45 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import RemoveEffectVarConfirm from '../_base/components/remove-effect-var-confirm'
import useConfig from './use-config'
import type { CodeNodeType } from './types'
import { CodeLanguage } from './types'
@ -14,6 +15,7 @@ import TypeSelector from '@/app/components/workflow/nodes/_base/components/selec
import type { NodePanelProps } from '@/app/components/workflow/types'
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.code'
const codeLanguages = [
@ -44,6 +46,9 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
handleVarsChange,
handleAddOutputVariable,
filterVar,
isShowRemoveVarConfirm,
hideRemoveVarConfirm,
onRemoveVarConfirm,
// single run
isShowSingleRun,
hideSingleRun,
@ -125,6 +130,11 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
/>
)
}
<RemoveEffectVarConfirm
isShow={isShowRemoveVarConfirm}
onCancel={hideRemoveVarConfirm}
onConfirm={onRemoveVarConfirm}
/>
</div >
)
}

View File

@ -85,7 +85,14 @@ const useConfig = (id: string, payload: CodeNodeType) => {
setInputs(newInputs)
}, [allLanguageDefault, inputs, setInputs])
const { handleVarsChange, handleAddVariable: handleAddOutputVariable, handleRemoveVariable } = useOutputVarList<CodeNodeType>({
const {
handleVarsChange,
handleAddVariable: handleAddOutputVariable,
handleRemoveVariable,
isShowRemoveVarConfirm,
hideRemoveVarConfirm,
onRemoveVarConfirm,
} = useOutputVarList<CodeNodeType>({
id,
inputs,
setInputs,
@ -142,6 +149,9 @@ const useConfig = (id: string, payload: CodeNodeType) => {
handleVarsChange,
filterVar,
handleAddOutputVariable,
isShowRemoveVarConfirm,
hideRemoveVarConfirm,
onRemoveVarConfirm,
// single run
isShowSingleRun,
hideSingleRun,