Skip to content

refactor: decompose ConnectionManager (#115)#129

Merged
nkcoder merged 2 commits into
mainfrom
refactor/115-connectionmanager-decompose
Jul 4, 2026
Merged

refactor: decompose ConnectionManager (#115)#129
nkcoder merged 2 commits into
mainfrom
refactor/115-connectionmanager-decompose

Conversation

@nkcoder

@nkcoder nkcoder commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

Second slice of #115 (M2 — oversized components). Decomposes ConnectionManager.tsx (1464 → 514 lines) into focused, independently-testable modules. No behavior change.

New modules

  • lib/connectionForm.ts (34) — makeEmptyForm + the pure getConnectionFormValidity helper (field-presence validation for save/test), lifted out of the inline canSave/canTest booleans.
  • components/ConnectionFormFields.tsx (159) — shared presentational primitives: FieldLabel, FieldInput, SelectInput, FormRow, ElephantIcon.
  • components/ConnectionDialogs.tsx (185) — UnsavedChangesDialog + ConfirmDialog.
  • components/ConnectionForm.tsx (604) — the ConnectionForm component and its TestResult type.

ConnectionManager.tsx now owns only the manager shell (datasource list, CRUD handlers, form/dialog orchestration).

Tests split to match the modules

  • lib/connectionForm.test.tsmakeEmptyForm + 7 new getConnectionFormValidity tests
  • components/ConnectionFormFields.test.tsxFieldInput / SelectInput
  • components/ConnectionForm.test.tsx — the ConnectionForm tests (no GoApp mock needed — onTest is a prop)
  • ConnectionManager.test.tsx — keeps the manager + double-click tests

Acceptance criteria

  • File meaningfully reduced by extracting sub-components/helpers (1464 → 514)
  • Connection-form validation lives in a separately unit-tested module
  • No behavior change — design tokens (T.*) and patterns preserved
  • Suites pass: 456 unit (+7 new) + 91 e2e, tsc, biome clean

Notes

  • FieldLabel (exported) and _SectionLabel (internal) were already dead code before this change — no call sites anywhere. Preserved untouched per the repo's "don't delete pre-existing dead code" convention; flagging here in case you'd like a follow-up to remove them.
  • Sidebar is the remaining slice of Decompose oversized components (Sidebar / ConnectionManager / QueryEditor) #115 and will follow as a separate PR.

nkcoder added 2 commits July 4, 2026 16:57
…tion modules (#115)

Split the 1464-line ConnectionManager.tsx into focused modules:
- lib/connectionForm.ts — makeEmptyForm + pure getConnectionFormValidity
- components/ConnectionFormFields.tsx — FieldLabel/FieldInput/SelectInput/FormRow/ElephantIcon
- components/ConnectionDialogs.tsx — UnsavedChangesDialog/ConfirmDialog
- components/ConnectionForm.tsx — the ConnectionForm component (+ TestResult)
ConnectionManager.tsx (514 lines) now owns only the manager shell.

Inline field-presence validation is lifted into getConnectionFormValidity
and unit-tested. Tests split to match the new modules. No behavior change;
456 unit + 91 e2e pass.

Note: FieldLabel and _SectionLabel were already dead code before this change
and are preserved untouched (per repo convention).

Part of M2 code-review finding.
…tion (#115)

- Split ConnectionForm General tab into ConnectionGeneralTab (604→420 lines)
- Extract DatasourceListItem from ConnectionManager (514→453 lines); both now <500
- Dedupe dialog scaffolding via a shared ModalShell; rename ConfirmDialog to
  DeleteConfirmDialog to end the name collision with the unused Dialog.tsx
- Collapse the duplicated form/cleanValues initializer into one initialForm
- Remove pre-existing dead code (FieldLabel, _SectionLabel)
- Drop the unrelated package.json.md5 churn

No behavior change; 456 unit + 91 e2e pass, tsc + biome clean.
@nkcoder nkcoder merged commit b7c82d2 into main Jul 4, 2026
2 checks passed
@nkcoder nkcoder deleted the refactor/115-connectionmanager-decompose branch July 4, 2026 21:58
nkcoder added a commit that referenced this pull request Jul 4, 2026
…131)

* test: cover Find, ConnectionGeneralTab, and session-hook error paths

Fills gaps surfaced while regression-testing the #127#130 refactor:

- e2e/query-editor-find.spec.ts: in-editor Find (Cmd+F) had no e2e
  coverage after the #128 QueryEditor/FindBar split — open/focus/close,
  match count, next/prev navigation, clear-resets.
- ConnectionGeneralTab.test.tsx: the #129-extracted tab had no test
  (40% func) — field edits, port numeric coercion, password
  mask/reveal, isEdit placeholder, derived URL.
- useDatasourceSession: GetCompletions failure during connect/refresh;
  disconnect no-op when nothing is connected.
- useQueryHistory: null history result coerces to [].

* test: raise hooks branch coverage + set two-tier coverage thresholds

Adds the missing hooks-branch tests and turns the flat #51 threshold into
a two-tier gate:

- useSidebarTree.test.ts (new): the hook had no direct test — covers the
  live-load error branches (columns/sub-folder load failures), the
  toggleColumnsFolder guard + toggle, and each sub-folder loader.
- useQueryExecution: non-result-set (DDL) rows-affected path; error leaves
  a pinned tab intact; double-pin preserves the first; close a non-active tab.
- useDatasourceSession: successful refresh clears a same-ds warning; a
  refresh for one ds leaves another ds's warning intact.

hooks branch coverage 78.6% -> 82.7%; overall 89.8% -> 90.6% stmt.

vitest.config.ts: global ratchet floor (90/82/90/91) as a regression gate,
plus higher per-dir floors for pure logic (lib/ 97/90/100/99, hooks/
95/82/95/97). Verified the glob thresholds are enforced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant