[PR #4698] [MERGED] refactor(frontend): reorganize source tree & break down oversized modals/tabs #5733

Closed
opened 2026-11-02 04:03:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4698
Author: @MHSanaei
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @MHSanaei

Base: main ← Head: refactor


📝 Commits (10+)

  • 06d0ae9 refactor(frontend): reorganize components & pages into feature folders
  • 1645664 refactor(frontend): move shared protocol enums to schemas/protocols/shared
  • a32fe94 refactor(frontend): break InboundList into helpers/types/RowActions/columns hook/stats modal
  • f116b09 refactor(frontend): extract InboundInfoModal helpers, types & buildInboundInfo
  • 0b130d2 test(frontend): add React Testing Library + jsdom render-test harness
  • c24b7d9 test(frontend): per-protocol field-structure coverage for both form modals
  • 1ca0e10 refactor(frontend): extract OutboundFormModal constants & stream helpers
  • 42f943d refactor(frontend): extract InboundFormModal advanced JSON editors
  • cf99205 refactor(frontend): extract OutboundFormModal loopback/blackhole/dns field blocks
  • 2b02f1b refactor(frontend): extract OutboundFormModal freedom field block

📊 Changes

188 files changed (+10471 additions, -7812 deletions)

View changed files

📝 frontend/package-lock.json (+662 -0)
📝 frontend/package.json (+3 -0)
📝 frontend/src/components/feedback/PromptModal.tsx (+0 -0)
📝 frontend/src/components/feedback/TextModal.tsx (+0 -0)
➕ frontend/src/components/feedback/index.ts (+2 -0)
📝 frontend/src/components/form/DateTimePicker.css (+0 -0)
📝 frontend/src/components/form/DateTimePicker.tsx (+0 -0)
📝 frontend/src/components/form/HeaderMapEditor.tsx (+1 -1)
📝 frontend/src/components/form/JsonEditor.css (+0 -0)
📝 frontend/src/components/form/JsonEditor.tsx (+0 -0)
➕ frontend/src/components/form/index.ts (+3 -0)
📝 frontend/src/components/ui/InfinityIcon.tsx (+0 -0)
📝 frontend/src/components/ui/InputAddon.css (+0 -0)
📝 frontend/src/components/ui/InputAddon.tsx (+0 -0)
📝 frontend/src/components/ui/SettingListItem.css (+0 -0)
📝 frontend/src/components/ui/SettingListItem.tsx (+0 -0)
➕ frontend/src/components/ui/index.ts (+3 -0)
📝 frontend/src/components/utility/LazyMount.tsx (+0 -0)
➕ frontend/src/components/utility/index.ts (+1 -0)
📝 frontend/src/components/viz/Sparkline.css (+0 -0)

...and 80 more files

📄 Description

Summary

Pure structural refactor of the frontend/ source tree (React + TS + Vite + AntD). Goal: a professional layout where every file sits in its correct place, and the oversized modals/tabs are broken into small, focused, easy-to-read units. No behavior change — all tests, golden fixtures and form field-structure snapshots stay green.

Done in small, reviewable commits; after each one npm run typecheck, npm run lint, npm run test, npm run build were all green.

What changed

1. Reorganization (zero behavior change)

  • components/ grouped into ui/ · form/ · feedback/ · viz/ · utility/ with barrels.
  • AppSidebar → layouts/; FinalMaskForm → lib/xray/forms/transport/.
  • pages/xray/ split into feature folders (basics/ · outbounds/ · routing/ · dns/ · balancers/ · overrides/); pages/inbounds/ into form/ · info/ · clients/ · qr/ · list/.
  • Fixed a cross-import smell: shared protocol enums (e.g. SSMethodSchema) moved to schemas/protocols/shared/, so outbound no longer reaches into the inbound shadowsocks schema.

2. Broke down the oversized files (per-modal presentational components receiving form/handlers as props; inbound vs outbound forms differ by direction, so they are kept per-modal rather than force-shared):

File Before After
inbounds/form/InboundFormModal.tsx 3129 868
xray/outbounds/OutboundFormModal.tsx 2238 621
inbounds/info/InboundInfoModal.tsx 1081 836
inbounds/list/InboundList.tsx 781 203
xray/routing/RoutingTab.tsx 550 291
xray/basics/BasicsTab.tsx 550 447
xray/dns/DnsTab.tsx 539 424
xray/outbounds/OutboundsTab.tsx 516 238
  • Each modal now has protocols/, transport/, security/ folders (one file per protocol/transport), plus extracted hooks (useSecurityActions, useInboundFallbacks) and presentational sections (FallbacksCard, SniffingTab).
  • Tabs broken into helpers/types/columns-hooks/card-list sections.

3. Test net added to guard the refactor

  • React Testing Library + jsdom harness (new components vitest project).
  • Per-protocol field-label snapshots for both modals + isolated per-component snapshots for the extracted inbound transport/security forms. These verify each extraction is byte-identical at the render level.

Verification

  • npm run typecheck — clean
  • npm run lint — 0 errors (4 pre-existing warnings, unchanged)
  • npm run test — 351 passing (21 files)
  • npm run build — green

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/4698 **Author:** [@MHSanaei](https://github.com/MHSanaei) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `refactor` --- ### 📝 Commits (10+) - [`06d0ae9`](https://github.com/MHSanaei/3x-ui/commit/06d0ae947d6749c9ba071a9f5e73cbaf2ba7d057) refactor(frontend): reorganize components & pages into feature folders - [`1645664`](https://github.com/MHSanaei/3x-ui/commit/1645664f0354b46a718d81b6757c0ce79b3d95b9) refactor(frontend): move shared protocol enums to schemas/protocols/shared - [`a32fe94`](https://github.com/MHSanaei/3x-ui/commit/a32fe948728b31db8f99b0b8340480e6d55120b1) refactor(frontend): break InboundList into helpers/types/RowActions/columns hook/stats modal - [`f116b09`](https://github.com/MHSanaei/3x-ui/commit/f116b09f7c76a8f114f8ff17d6b98a712ec138b3) refactor(frontend): extract InboundInfoModal helpers, types & buildInboundInfo - [`0b130d2`](https://github.com/MHSanaei/3x-ui/commit/0b130d24ac0ec7a8c20e5619ef356bc2fca2dd29) test(frontend): add React Testing Library + jsdom render-test harness - [`c24b7d9`](https://github.com/MHSanaei/3x-ui/commit/c24b7d9da3a7699c22861c0ff7efb446d7e44c15) test(frontend): per-protocol field-structure coverage for both form modals - [`1ca0e10`](https://github.com/MHSanaei/3x-ui/commit/1ca0e101514038d13499a84334299c8e20be4e73) refactor(frontend): extract OutboundFormModal constants & stream helpers - [`42f943d`](https://github.com/MHSanaei/3x-ui/commit/42f943ddc8f0b53436241fedee0278ccff0c39a9) refactor(frontend): extract InboundFormModal advanced JSON editors - [`cf99205`](https://github.com/MHSanaei/3x-ui/commit/cf9920593ed472c3a889215271ef5d2b37d07a98) refactor(frontend): extract OutboundFormModal loopback/blackhole/dns field blocks - [`2b02f1b`](https://github.com/MHSanaei/3x-ui/commit/2b02f1b7453abc6d043890ade823e30ed7f55c78) refactor(frontend): extract OutboundFormModal freedom field block ### 📊 Changes **188 files changed** (+10471 additions, -7812 deletions) <details> <summary>View changed files</summary> 📝 `frontend/package-lock.json` (+662 -0) 📝 `frontend/package.json` (+3 -0) 📝 `frontend/src/components/feedback/PromptModal.tsx` (+0 -0) 📝 `frontend/src/components/feedback/TextModal.tsx` (+0 -0) ➕ `frontend/src/components/feedback/index.ts` (+2 -0) 📝 `frontend/src/components/form/DateTimePicker.css` (+0 -0) 📝 `frontend/src/components/form/DateTimePicker.tsx` (+0 -0) 📝 `frontend/src/components/form/HeaderMapEditor.tsx` (+1 -1) 📝 `frontend/src/components/form/JsonEditor.css` (+0 -0) 📝 `frontend/src/components/form/JsonEditor.tsx` (+0 -0) ➕ `frontend/src/components/form/index.ts` (+3 -0) 📝 `frontend/src/components/ui/InfinityIcon.tsx` (+0 -0) 📝 `frontend/src/components/ui/InputAddon.css` (+0 -0) 📝 `frontend/src/components/ui/InputAddon.tsx` (+0 -0) 📝 `frontend/src/components/ui/SettingListItem.css` (+0 -0) 📝 `frontend/src/components/ui/SettingListItem.tsx` (+0 -0) ➕ `frontend/src/components/ui/index.ts` (+3 -0) 📝 `frontend/src/components/utility/LazyMount.tsx` (+0 -0) ➕ `frontend/src/components/utility/index.ts` (+1 -0) 📝 `frontend/src/components/viz/Sparkline.css` (+0 -0) _...and 80 more files_ </details> ### 📄 Description ## Summary Pure structural refactor of the `frontend/` source tree (React + TS + Vite + AntD). Goal: a professional layout where every file sits in its correct place, and the oversized modals/tabs are broken into small, focused, easy-to-read units. **No behavior change** — all tests, golden fixtures and form field-structure snapshots stay green. Done in small, reviewable commits; after each one `npm run typecheck`, `npm run lint`, `npm run test`, `npm run build` were all green. ## What changed **1. Reorganization (zero behavior change)** - `components/` grouped into `ui/ · form/ · feedback/ · viz/ · utility/` with barrels. - `AppSidebar` → `layouts/`; `FinalMaskForm` → `lib/xray/forms/transport/`. - `pages/xray/` split into feature folders (`basics/ · outbounds/ · routing/ · dns/ · balancers/ · overrides/`); `pages/inbounds/` into `form/ · info/ · clients/ · qr/ · list/`. - Fixed a cross-import smell: shared protocol enums (e.g. `SSMethodSchema`) moved to `schemas/protocols/shared/`, so outbound no longer reaches into the inbound shadowsocks schema. **2. Broke down the oversized files** (per-modal presentational components receiving form/handlers as props; inbound vs outbound forms differ by direction, so they are kept per-modal rather than force-shared): | File | Before | After | |---|---|---| | `inbounds/form/InboundFormModal.tsx` | 3129 | 868 | | `xray/outbounds/OutboundFormModal.tsx` | 2238 | 621 | | `inbounds/info/InboundInfoModal.tsx` | 1081 | 836 | | `inbounds/list/InboundList.tsx` | 781 | 203 | | `xray/routing/RoutingTab.tsx` | 550 | 291 | | `xray/basics/BasicsTab.tsx` | 550 | 447 | | `xray/dns/DnsTab.tsx` | 539 | 424 | | `xray/outbounds/OutboundsTab.tsx` | 516 | 238 | - Each modal now has `protocols/`, `transport/`, `security/` folders (one file per protocol/transport), plus extracted hooks (`useSecurityActions`, `useInboundFallbacks`) and presentational sections (`FallbacksCard`, `SniffingTab`). - Tabs broken into `helpers/types/columns-hooks/card-list` sections. **3. Test net added to guard the refactor** - React Testing Library + jsdom harness (new `components` vitest project). - Per-protocol field-label snapshots for both modals + isolated per-component snapshots for the extracted inbound transport/security forms. These verify each extraction is byte-identical at the render level. ## Verification - `npm run typecheck` — clean - `npm run lint` — 0 errors (4 pre-existing warnings, unchanged) - `npm run test` — 351 passing (21 files) - `npm run build` — green --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:03:41 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5733
No description provided.