From 66348db37d1ee0dad82596562585d474c179ecce Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 30 May 2026 20:29:18 +0200 Subject: [PATCH] refactor(frontend): extract inbound security forms into security/ folder Move the inbound TLS and Reality stream-security blocks out of InboundFormModal into presentational components under inbounds/form/security/. The Radio.Group security selector stays in the modal; TlsForm and RealityForm receive their cert/key/ECH generation handlers and the saving flag as props. InboundFormModal drops from 2105 to 1708 lines. Add inbound-form-blocks.test.tsx: render-snapshot coverage for each extracted transport (raw/ws/grpc/kcp/httpupgrade/xhttp) and security (tls/reality) component in isolation inside a minimal Form. The full modal cannot exercise the stream/security tabs in jsdom because they are gated behind Form.useWatch values that do not propagate in the test harness, so component-level snapshots are the regression net for these blocks. No behavior change. --- .../pages/inbounds/form/InboundFormModal.tsx | 441 +----------------- .../src/pages/inbounds/form/security/index.ts | 2 + .../pages/inbounds/form/security/reality.tsx | 143 ++++++ .../src/pages/inbounds/form/security/tls.tsx | 309 ++++++++++++ .../inbound-form-blocks.test.tsx.snap | 98 ++++ .../src/test/inbound-form-blocks.test.tsx | 89 ++++ 6 files changed, 663 insertions(+), 419 deletions(-) create mode 100644 frontend/src/pages/inbounds/form/security/index.ts create mode 100644 frontend/src/pages/inbounds/form/security/reality.tsx create mode 100644 frontend/src/pages/inbounds/form/security/tls.tsx create mode 100644 frontend/src/test/__snapshots__/inbound-form-blocks.test.tsx.snap create mode 100644 frontend/src/test/inbound-form-blocks.test.tsx diff --git a/frontend/src/pages/inbounds/form/InboundFormModal.tsx b/frontend/src/pages/inbounds/form/InboundFormModal.tsx index 8e2fc459..f8364ff9 100644 --- a/frontend/src/pages/inbounds/form/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/form/InboundFormModal.tsx @@ -24,7 +24,6 @@ import { DeleteOutlined, MinusOutlined, PlusOutlined, - ReloadOutlined, } from '@ant-design/icons'; import { HttpUtil, NumberFormatter, RandomUtil, SizeFormatter, Wireguard } from '@/utils'; @@ -54,9 +53,6 @@ import { Protocols, SNIFFING_OPTION, TCP_CONGESTION_OPTION, - TLS_CIPHER_OPTION, - TLS_VERSION_OPTION, - USAGE_OPTION, UTLS_FINGERPRINT, } from '@/schemas/primitives'; import { @@ -97,8 +93,8 @@ import { WsForm, XhttpForm, } from './transport'; +import { RealityForm, TlsForm } from './security'; -const { TextArea } = Input; import { coerceInboundJsonField, type DBInbound } from '@/models/dbinbound'; import type { NodeRecord } from '@/api/queries/useNodesQuery'; @@ -1481,421 +1477,28 @@ export default function InboundFormModal({ - - prev.streamSettings?.security !== curr.streamSettings?.security - } - > - {({ getFieldValue }) => { - const sec = getFieldValue(['streamSettings', 'security']); - if (sec !== 'tls') return null; - return ( - <> - - - - - ({ value: v, label: v }))} - /> - - - ({ value: fp, label: fp })), - ]} - /> - - - - - - - - - - - - - - - ) : ( - <> - typeof v === 'string' - ? v.split('\n') - : v} - getValueProps={(v) => ({ - value: Array.isArray(v) ? v.join('\n') : v, - })} - > -