From afd44ed687e1b91b5f7e7769903e0a8f4225f8f9 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 30 May 2026 18:18:44 +0200 Subject: [PATCH] refactor(frontend): split inbound-only protocol forms (tun, tunnel) into per-file Extract the tun and tunnel protocol blocks from InboundFormModal into inbounds/form/protocols/{tun,tunnel}.tsx (presentational, declarative). First inbound-side per-protocol split. Verbatim relocation; inbound snapshots unchanged -> no behavior change. typecheck/lint/build green. --- .../pages/inbounds/form/InboundFormModal.tsx | 118 +----------------- .../pages/inbounds/form/protocols/index.ts | 2 + .../src/pages/inbounds/form/protocols/tun.tsx | 93 ++++++++++++++ .../pages/inbounds/form/protocols/tunnel.tsx | 37 ++++++ 4 files changed, 135 insertions(+), 115 deletions(-) create mode 100644 frontend/src/pages/inbounds/form/protocols/index.ts create mode 100644 frontend/src/pages/inbounds/form/protocols/tun.tsx create mode 100644 frontend/src/pages/inbounds/form/protocols/tunnel.tsx diff --git a/frontend/src/pages/inbounds/form/InboundFormModal.tsx b/frontend/src/pages/inbounds/form/InboundFormModal.tsx index 79dcaf8d..fe602d29 100644 --- a/frontend/src/pages/inbounds/form/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/form/InboundFormModal.tsx @@ -84,6 +84,7 @@ import { InputAddon } from '@/components/ui'; import './InboundFormModal.css'; import { AdvancedAllEditor, AdvancedSliceEditor } from './advanced-editors'; +import { TunFields, TunnelFields } from './protocols'; const { TextArea } = Input; import { coerceInboundJsonField, type DBInbound } from '@/models/dbinbound'; @@ -1053,122 +1054,9 @@ export default function InboundFormModal({ )} - {protocol === Protocols.TUN && ( - <> - - - - - - - - {(fields, { add, remove }) => ( - - - {fields.map((field, j) => ( - - - - - - - ))} - - )} - - - {(fields, { add, remove }) => ( - - - {fields.map((field, j) => ( - - - - - - - ))} - - )} - - - - - - {(fields, { add, remove }) => ( - - {t('pages.inbounds.info.autoSystemRoutes')} - - } - > - - {fields.map((field, j) => ( - - - - - - - ))} - - )} - - - {t('pages.inbounds.form.autoOutboundsInterface')} - - } - > - - - - )} + {protocol === Protocols.TUN && } - {protocol === Protocols.TUNNEL && ( - <> - - - - - - - - + + + + + + {(fields, { add, remove }) => ( + + + {fields.map((field, j) => ( + + + + + + + ))} + + )} + + + {(fields, { add, remove }) => ( + + + {fields.map((field, j) => ( + + + + + + + ))} + + )} + + + + + + {(fields, { add, remove }) => ( + + {t('pages.inbounds.info.autoSystemRoutes')} + + } + > + + {fields.map((field, j) => ( + + + + + + + ))} + + )} + + + {t('pages.inbounds.form.autoOutboundsInterface')} + + } + > + + + + ); +} diff --git a/frontend/src/pages/inbounds/form/protocols/tunnel.tsx b/frontend/src/pages/inbounds/form/protocols/tunnel.tsx new file mode 100644 index 00000000..5cfbec15 --- /dev/null +++ b/frontend/src/pages/inbounds/form/protocols/tunnel.tsx @@ -0,0 +1,37 @@ +import { useTranslation } from 'react-i18next'; +import { Form, Input, InputNumber, Select, Switch } from 'antd'; + +import { HeaderMapEditor } from '@/components/form'; + +export default function TunnelFields() { + const { t } = useTranslation(); + return ( + <> + + + + + + + +