From e8381564a6a54360d6647791721b06adf1a975b5 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 30 May 2026 18:26:56 +0200 Subject: [PATCH] refactor(frontend): split inbound wireguard & shadowsocks protocol forms Extract the wireguard and shadowsocks protocol blocks from InboundFormModal into inbounds/form/protocols/{wireguard,shadowsocks}.tsx (presentational; form + regen handlers / isSSWith2022 passed as props). Drop now-unused Divider + SSMethodSchema imports. Verbatim relocation; inbound snapshots unchanged -> no behavior change. typecheck/lint/build green. --- .../pages/inbounds/form/InboundFormModal.tsx | 162 +----------------- .../pages/inbounds/form/protocols/index.ts | 2 + .../inbounds/form/protocols/shadowsocks.tsx | 67 ++++++++ .../inbounds/form/protocols/wireguard.tsx | 120 +++++++++++++ 4 files changed, 192 insertions(+), 159 deletions(-) create mode 100644 frontend/src/pages/inbounds/form/protocols/shadowsocks.tsx create mode 100644 frontend/src/pages/inbounds/form/protocols/wireguard.tsx diff --git a/frontend/src/pages/inbounds/form/InboundFormModal.tsx b/frontend/src/pages/inbounds/form/InboundFormModal.tsx index fe602d29..571a7286 100644 --- a/frontend/src/pages/inbounds/form/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/form/InboundFormModal.tsx @@ -5,7 +5,6 @@ import { Button, Card, Checkbox, - Divider, Empty, Form, Input, @@ -41,7 +40,6 @@ import { canEnableTls, isSS2022, } from '@/lib/xray/protocol-capabilities'; -import { SSMethodSchema } from '@/schemas/protocols/shared/shadowsocks'; import { getRandomRealityTarget } from '@/models/reality-targets'; import { InboundFormBaseSchema, @@ -84,7 +82,7 @@ import { InputAddon } from '@/components/ui'; import './InboundFormModal.css'; import { AdvancedAllEditor, AdvancedSliceEditor } from './advanced-editors'; -import { TunFields, TunnelFields } from './protocols'; +import { ShadowsocksFields, TunFields, TunnelFields, WireguardFields } from './protocols'; const { TextArea } = Input; import { coerceInboundJsonField, type DBInbound } from '@/models/dbinbound'; @@ -948,111 +946,7 @@ export default function InboundFormModal({ const protocolTab = ( <> - {protocol === Protocols.WIREGUARD && ( - <> - - - - - - - - {fields.map((field, idx) => ( -
- - - {t('pages.inbounds.info.peerNumber', { n: idx + 1 })} - {fields.length > 1 && ( - - {ipFields.map((ipField) => ( - - - - - {ipFields.length > 1 && ( - - )} - - ))} - - )} - - - - -
- ))} - - )} - - - )} + {protocol === Protocols.WIREGUARD && } {protocol === Protocols.TUN && } @@ -1131,57 +1025,7 @@ export default function InboundFormModal({ )} - {protocol === Protocols.SHADOWSOCKS && ( - <> - - - - + + {fields.map((field, idx) => ( +
+ + + {t('pages.inbounds.info.peerNumber', { n: idx + 1 })} + {fields.length > 1 && ( + + {ipFields.map((ipField) => ( + + + + + {ipFields.length > 1 && ( + + )} + + ))} + + )} + + + + +
+ ))} + + )} + + + ); +}