mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-18 02:55:00 +03:00
refactor(frontend): read the panel's navigation from one route manifest (#6922)
The router, the sidebar, the page titles and the command palette each kept their own list of the panel's pages, so a page added to one could go missing from another without any test noticing. They all read src/routes/panelRoutes.tsx now, and a contract test holds the manifest to the router, the translation bundle and the palette keywords. The unused useZodForm helper goes, and CONTRIBUTING, frontend/CLAUDE.md and the frontend README describe the useForm + rhfZodValidate pattern the panel's forms actually use.
This commit is contained in:
+9
-6
@@ -33,11 +33,12 @@ The `@` import alias maps to `src/`.
|
||||
- Function components + hooks only; no class components.
|
||||
- Comments in committed TS/TSX: 2 lines MAX per comment block, spent on the
|
||||
*why* a name cannot hold (same rule as root CLAUDE.md). HTML comments are fine.
|
||||
- TS strict; oxlint's `typescript/no-explicit-any` is an error. Build forms with `useZodForm` +
|
||||
`FormField` from `@/components/form/rhf` (wrap the tree in `FormProvider`);
|
||||
validate through the `zodResolver` or per-field
|
||||
- TS strict; oxlint's `typescript/no-explicit-any` is an error. Build forms with React Hook
|
||||
Form's `useForm` + `FormField` from `@/components/form/rhf` (wrap the tree in
|
||||
`FormProvider`) and validate each field with
|
||||
`rules={{ validate: rhfZodValidate(Schema.shape.field) }}` — messages are Zod
|
||||
issue keys resolved via `t()`, never inline `z.string()`. AntD `<Form>` stays
|
||||
issue keys resolved via `t()`, never inline `z.string()`. A whole-form
|
||||
`zodResolver` is only for a form that submits one schema. AntD `<Form>` stays
|
||||
only as a layout wrapper. Complex shared config editors (FinalMask / Sniffing /
|
||||
Sockopt) remain AntD-`Form` islands wrapped as value/onChange adapters in
|
||||
`src/lib/xray/forms/fields/`, bound via a `Controller`.
|
||||
@@ -54,8 +55,10 @@ The `@` import alias maps to `src/`.
|
||||
|
||||
## Adding a panel route
|
||||
1. `src/pages/<page>/<Page>.tsx` (kebab folder, PascalCase component).
|
||||
2. Register in `src/routes.tsx` under `/panel` (lazy import).
|
||||
3. Add a sidebar link in `src/layouts/AppSidebar.tsx` if it needs nav.
|
||||
2. Add it to `src/routes/panelRoutes.tsx`. The router, the sidebar, the page
|
||||
title and the command palette all read that one list;
|
||||
`src/test/navigation-contract.test.tsx` holds it to the router and to the
|
||||
translation bundle.
|
||||
Only standalone bundles (login/subpage) need a new `.html` + `src/entries/*` +
|
||||
`rollupOptions.input` (in `vite.config.js`) + a Go controller route.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user