Split the grown component modules by family #652

Closed
opened 2026-11-09 17:45:14 +01:00 by simon · 0 comments
Owner

Why

The UI unification collected the shared components in two modules on purpose. Since then they have grown to 1196 and 1097 lines, and each holds one component family that is large and stands apart from the rest. The filter-builder component from #641 also ended at 653 lines instead of the 600 that issue aimed for. Measured on main 777fc938.

File Lines Block to move Approx. lines moved
lib/mv_web/components/form.ex 1196 combobox/1 + combobox_* helpers (l. 553–970) ~420
lib/mv_web/components/overlay.ex 1097 modal/1, confirm_dialog/1, confirm_match?/2 (l. 675–1083) ~400
lib/mv_web/components/add_filter_builder_component.ex 653 chip-row order: remember_row_order/1, assign_row_chips/1, put_row/4, insert_after/3, pending_chip_id/1 (l. 316–396) ~80

Scope

  1. MvWeb.Components.Combobox: move combobox/1 with its private helpers out of form.ex. The server side already lives in lib/mv_web/combobox.ex; update its moduledoc reference.
    • combobox/1 renders the private help/1 component of form.ex (5 uses). Share it deliberately (a public, @doc false function component or a small shared module); do not duplicate it.
  2. MvWeb.Components.Dialog: move modal/1, confirm_dialog/1 and confirm_match?/2 out of overlay.ex. Overlay keeps everything anchored to a trigger (tooltip, popover, menu). Update the aliases and doc references in live_helpers.ex, member_deletion.ex and group_deletion.ex.
  3. Filter-builder row order: move the pure part of the chip-row ordering out of add_filter_builder_component.ex into a pure module next to filter_chips.ex (e.g. MemberLive.Index.FilterRowOrder) with unit tests on lists; the component keeps only the socket assigns.
  4. Import both new modules in MvWeb.html_helpers/0 (lib/mv_web.ex) and add them to @component_modules in test/mv_web/components/import_surface_test.exs. The @surface list stays unchanged — that test is the guard that no caller notices the move.
  5. Move or rename the matching tests (form_combobox_test.exs, overlay_modal_test.exs, overlay_confirm_dialog_test.exs, confirm_match_property_test.exs) so each test file names the module it tests. No behavior test is deleted.

Risk

Low: no visible change, and the imported surface stays the same.

Out of scope

  • Any visible or behavioral change, any attr API change.
  • Splitting input/1 further: form.ex keeps the input family (~780 lines after the move). A component module may be large when it holds one family.

Acceptance criteria

  • form.ex ≤ ~800, overlay.ex ≤ ~700, add_filter_builder_component.ex ≤ 600 lines.
  • import_surface_test.exs green with an unchanged @surface; no caller outside lib/mv_web.ex, the helper aliases and the tests changes.
  • just ci-dev, just typecheck and just test-all (incl. :ui) green; one commit per family.

Note for #541 (Credo ratchet)

Do not set a hard line limit for lib/mv_web/components/: count per component family, or exempt attr/@doc lines. Otherwise form.ex crosses the limit again with the input family alone.

## Why The UI unification collected the shared components in two modules on purpose. Since then they have grown to 1196 and 1097 lines, and each holds one component family that is large and stands apart from the rest. The filter-builder component from #641 also ended at 653 lines instead of the 600 that issue aimed for. Measured on `main` 777fc938. | File | Lines | Block to move | Approx. lines moved | |---|---|---|---| | `lib/mv_web/components/form.ex` | 1196 | `combobox/1` + `combobox_*` helpers (l. 553–970) | ~420 | | `lib/mv_web/components/overlay.ex` | 1097 | `modal/1`, `confirm_dialog/1`, `confirm_match?/2` (l. 675–1083) | ~400 | | `lib/mv_web/components/add_filter_builder_component.ex` | 653 | chip-row order: `remember_row_order/1`, `assign_row_chips/1`, `put_row/4`, `insert_after/3`, `pending_chip_id/1` (l. 316–396) | ~80 | ## Scope 1. **`MvWeb.Components.Combobox`**: move `combobox/1` with its private helpers out of `form.ex`. The server side already lives in `lib/mv_web/combobox.ex`; update its moduledoc reference. - `combobox/1` renders the private `help/1` component of `form.ex` (5 uses). Share it deliberately (a public, `@doc false` function component or a small shared module); do not duplicate it. 2. **`MvWeb.Components.Dialog`**: move `modal/1`, `confirm_dialog/1` and `confirm_match?/2` out of `overlay.ex`. `Overlay` keeps everything anchored to a trigger (tooltip, popover, menu). Update the aliases and doc references in `live_helpers.ex`, `member_deletion.ex` and `group_deletion.ex`. 3. **Filter-builder row order**: move the pure part of the chip-row ordering out of `add_filter_builder_component.ex` into a pure module next to `filter_chips.ex` (e.g. `MemberLive.Index.FilterRowOrder`) with unit tests on lists; the component keeps only the socket assigns. 4. Import both new modules in `MvWeb.html_helpers/0` (`lib/mv_web.ex`) and add them to `@component_modules` in `test/mv_web/components/import_surface_test.exs`. The `@surface` list stays unchanged — that test is the guard that no caller notices the move. 5. Move or rename the matching tests (`form_combobox_test.exs`, `overlay_modal_test.exs`, `overlay_confirm_dialog_test.exs`, `confirm_match_property_test.exs`) so each test file names the module it tests. No behavior test is deleted. ## Risk Low: no visible change, and the imported surface stays the same. ## Out of scope - Any visible or behavioral change, any attr API change. - Splitting `input/1` further: `form.ex` keeps the input family (~780 lines after the move). A component module may be large when it holds one family. ## Acceptance criteria - `form.ex` ≤ ~800, `overlay.ex` ≤ ~700, `add_filter_builder_component.ex` ≤ 600 lines. - `import_surface_test.exs` green with an unchanged `@surface`; no caller outside `lib/mv_web.ex`, the helper aliases and the tests changes. - `just ci-dev`, `just typecheck` and `just test-all` (incl. `:ui`) green; one commit per family. ## Note for #541 (Credo ratchet) Do not set a hard line limit for `lib/mv_web/components/`: count per component family, or exempt `attr`/`@doc` lines. Otherwise `form.ex` crosses the limit again with the input family alone.
simon closed this issue 2026-11-12 08:10:41 +01:00
Sign in to join this conversation.
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
local-it/mitgliederverwaltung#652
No description provided.