dify/web/app/components/workflow/nodes/end/panel.tsx
yyh e1bbe57f9c
refactor(web): re-design button api (#35166)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-14 13:22:23 +00:00

56 lines
1.5 KiB
TypeScript

import type { FC } from 'react'
import type { EndNodeType } from './types'
import type { NodePanelProps } from '@/app/components/workflow/types'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import Field from '@/app/components/workflow/nodes/_base/components/field'
import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list'
import useConfig from './use-config'
const i18nPrefix = 'nodes.end'
const Panel: FC<NodePanelProps<EndNodeType>> = ({
id,
data,
}) => {
const { t } = useTranslation()
const {
readOnly,
inputs,
handleVarListChange,
handleAddVariable,
} = useConfig(id, data)
const outputs = inputs.outputs
return (
<div className="mt-2">
<div className="space-y-4 px-4 pb-4">
<Field
title={t(`${i18nPrefix}.output.variable`, { ns: 'workflow' })}
required
operations={
!readOnly
? (
<div className="cursor-pointer rounded-md p-1 select-none hover:bg-state-base-hover" onClick={handleAddVariable} data-testid="add-button">
<span className="i-ri-add-line h-4 w-4 text-text-tertiary" />
</div>
)
: undefined
}
>
<VarList
nodeId={id}
readonly={readOnly}
list={outputs}
onChange={handleVarListChange}
/>
</Field>
</div>
</div>
)
}
export default React.memo(Panel)