import type { FC } from 'react' import type { HttpNodeType } from './types' import type { NodePanelProps } from '@/app/components/workflow/types' import { cn } from '@langgenius/dify-ui/cn' import { Switch } from '@langgenius/dify-ui/switch' import { memo } from 'react' import { useTranslation } from 'react-i18next' import { FileArrow01 } from '@/app/components/base/icons/src/vender/line/files' import { Settings01 } from '@/app/components/base/icons/src/vender/line/general' import Field from '@/app/components/workflow/nodes/_base/components/field' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import Split from '@/app/components/workflow/nodes/_base/components/split' import ApiInput from './components/api-input' import AuthorizationModal from './components/authorization' import CurlPanel from './components/curl-panel' import EditBody from './components/edit-body' import KeyValue from './components/key-value' import Timeout from './components/timeout' import useConfig from './use-config' const i18nPrefix = 'nodes.http' const Panel: FC> = ({ id, data }) => { const { t } = useTranslation() const { readOnly, isDataReady, inputs, handleMethodChange, handleUrlChange, headers, setHeaders, addHeader, params, setParams, addParam, setBody, isShowAuthorization, showAuthorization, hideAuthorization, setAuthorization, setTimeout, isShowCurlPanel, showCurlPanel, hideCurlPanel, handleCurlImport, handleSSLVerifyChange, } = useConfig(id, data) // To prevent prompt editor in body not update data. if (!isDataReady) return null return (
$[`${i18nPrefix}.api`], { ns: 'workflow' })} required operations={
{!readOnly && }
{t(($) => $[`${i18nPrefix}.authorization.authorization`], { ns: 'workflow' })} {t(($) => $[`${i18nPrefix}.authorization.${inputs.authorization.type}`], { ns: 'workflow', })}
{!readOnly && }
{t(($) => $[`${i18nPrefix}.curl.title`], { ns: 'workflow' })}
} >
$[`${i18nPrefix}.headers`], { ns: 'workflow' })}> $[`${i18nPrefix}.params`], { ns: 'workflow' })}> $[`${i18nPrefix}.body`], { ns: 'workflow' })} required> $[`${i18nPrefix}.verifySSL.title`], { ns: 'workflow' })} tooltip={t(($) => $[`${i18nPrefix}.verifySSL.warningTooltip`], { ns: 'workflow' })} operations={ } >
{isShowAuthorization && !readOnly && ( )}
<> $[`${i18nPrefix}.outputVars.body`], { ns: 'workflow' })} /> $[`${i18nPrefix}.outputVars.statusCode`], { ns: 'workflow' })} /> $[`${i18nPrefix}.outputVars.headers`], { ns: 'workflow' })} /> $[`${i18nPrefix}.outputVars.files`], { ns: 'workflow' })} />
{isShowCurlPanel && !readOnly && ( )}
) } export default memo(Panel)