Repository navigation
Commit 30ded9f
authored
refactor(app): split ServicesDashboardPage into smaller sibling files (#2626)
## Summary
`ServicesDashboardPage.tsx` had grown to **1,759 lines** in a single file — the page shell, three tab views, an endpoint latency chart, a service selector, and shared filter/query helpers all interleaved. This splits it into a `ServicesDashboardPage/` directory of smaller, cohesive files so the tabs and helpers can be read and edited in isolation.
**This is a pure file-move refactor: no behavior, logic, JSX, or effects changed.** Code was relocated verbatim and relative imports rewired.
## Line count
| | Lines |
|---|---:|
| Before — `ServicesDashboardPage.tsx` (monolith) | **1,759** |
| After — largest file (`HttpTab.tsx`) | **699** |
## New structure
```
packages/app/src/ServicesDashboardPage/
index.ts (3) barrel — re-exports the original public API only
types.ts (12) AppliedConfig type
helpers.ts (78) pickSourceConfigFields, buildInFilterCondition,
getScopedFilters, MAX_NUM_SERIES
ServicesDashboardPage.tsx (446) page shell, ServiceSelectControlled, dynamic wrapper
HttpTab.tsx (699) HttpTab + EndpointLatencyChart (colocated)
DatabaseTab.tsx (517) DatabaseTab
ErrorsTab.tsx (76) ErrorsTab
__tests__/ServicesDashboardPage.test.tsx (171) new smoke test
```
## Drop-in barrel
`index.ts` re-exports exactly the original public API — the default page (with `getLayout`), `EndpointLatencyChart`, and `buildInFilterCondition` — so every external consumer keeps importing `@/ServicesDashboardPage` unchanged:
- `pages/services.tsx` (default export)
- `components/ServiceDashboardEndpointSidePanel.tsx` (`EndpointLatencyChart`)
- `src/__tests__/ServicesDashboardPage.test.ts` (`buildInFilterCondition`)
## Decisions
- **`EndpointLatencyChart` colocated with `HttpTab`** rather than its own file — `HttpTab` renders it directly, so splitting them would introduce a cross-file cycle. The barrel still re-exports it for the side panel.
- **Relative imports rewritten to `@/` absolute** in the moved files (they now sit one level deeper); sibling imports within the directory use `./`.
- **One essential smoke test added** — the existing `buildInFilterCondition` unit test does not render the component, so a minimal "it mounts" test was added (heavy children/hooks stubbed). No per-sub-component tests.
## Verification
- `npx tsc --noEmit` — clean
- `make ci-lint` — clean across all 5 projects
- Unit tests — 4 passed (existing `buildInFilterCondition` + new smoke test)
- E2E `services-dashboard.spec.ts` — **3 passed** (page load, HTTP tab charts, Lucene filtering)
## Follow-ups (intentionally not done here)
- Each tab independently calls `useSource` + `useServiceDashboardExpressions` with identical args; could be lifted to a shared hook later (behavior-adjacent, out of scope for a pure move).
- Two pre-existing lint warnings (`as [Date, Date]` assertion; a setter-naming warning) were carried over verbatim.1 parent 2f76920 commit 30ded9f
9 files changed
Lines changed: 2018 additions & 1759 deletions
File tree
- packages/app/src
- ServicesDashboardPage
- __tests__
This file was deleted.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
0 commit comments