Skip to content

refactor: split panel.js into menu sections - #18

Merged
napalm255 merged 7 commits into
mainfrom
refactor/split-panel
Sep 25, 2026
Merged

napalm255 merged 7 commits into
mainfrom
refactor/split-panel

Conversation

@napalm255

Copy link
Copy Markdown
Collaborator

Splits modules/panel.js (1,492 lines) into menu sections. Behavior-preserving: no behavior change, no reworded strings, no new features.

Structure

Each section is a plain JS class that builds its submenu into the toggle's menu, with its own generation counter and explicit dependencies (model, settings, i18n, gicon, chooseFiles).

Module Lines Holds
modules/panel.js 724 Indicator; toggle (header, problems/warnings, settings switches, profiles, click/login, open-state delegation, max height, sync dispatch, teardown); Panel; subtitleFor
modules/menu-items.js 192 Shared menu items and helpers
modules/navigable-section.js 95 List ↔ detail swap inside one submenu
modules/exit-node-section.js 229 Exit nodes, Mullvad drill-down, suggestion
modules/device-section.js 224 Devices, detail view, ping
modules/taildrop-section.js 255 Send files and received files

panel.js lands at 724 rather than ~500: what stays there (problems/warnings, switches, profiles, open-state and height handling) is tied to the tile, and moving it would scatter the toggle.

Tests are split the same way (tests/{exit-node,device,taildrop}-section.test.js, shared setup in tests/support/panel.js) as a pure move: identical test count, no assertion changes. README and the docs site's Architecture section name the new modules.

Verification

  • npx vitest run after every commit: 722 passed.
  • Coverage of the panel code as a whole: lines 99.77% → 99.78%, branches 93.8% → 93.8%, functions 100%.
  • just ci: lint clean, 722 unit + 50 docs-site tests, osv/gitleaks/zizmor clean, build OK.
  • just test-live: headless GNOME Shell PASS; pack-check PASS with 32 files (the new modules included); localapi-check PASS.

ActionMenuItem, StayOpenSwitchMenuItem and the row, clipboard, OSD and URI helpers move out of modules/panel.js unchanged, so the section modules that follow can build rows the same way. The toggle's _addRow becomes addRow() and takes the owner of its connection explicitly, since it no longer has a `this` to borrow.
The list-or-detail submenu the exit node and device sections share moves out of modules/panel.js unchanged.
The exit node submenu — None, the suggestion, the tailnet's candidates and the Mullvad drill-down, with the choices memo — moves to modules/exit-node-section.js as a plain class. It builds its submenu into the toggle's menu, owns its own generation counter and is driven through sync(), menuOpened(), reset() and destroy(). The toggle keeps a handle on the submenu item and passes what the section needs in one deps object.
The device submenu — the list, one device's actions, ping and its label — moves to modules/device-section.js as a plain class with its own generation counter. "Send files…" reaches the send through a sendFiles dependency rather than a method on the toggle.
The "Send files" submenu and every send, and the received-files inbox with its saves, move to modules/taildrop-section.js as two plain classes, each with its own generation counter. The toggle now only builds the sections, dispatches sync() and the menu-open refreshes to them, and destroys them in the order it did before. The one test that reached the toggle's _chooseFiles reads it from the send section instead.
A pure move. The describe blocks for the exit node picker and its suggestion, the devices, and Taildrop's send and inbox go into their own files beside the section modules they now test; the rest stay in tests/panel.test.js. The shared setup, handles and stub resets move to tests/support/panel.js. The same 722 tests run, and no line inside a describe block changed.
README and the docs site's Architecture section name the menu section modules panel.js now builds, and the one comment that pointed at panel.js for Taildrop's gettext points at taildrop-section.js.
@sonarqubecloud

Copy link
Copy Markdown

@napalm255
napalm255 merged commit 839181b into main Sep 25, 2026
6 checks passed
@napalm255
napalm255 deleted the refactor/split-panel branch September 25, 2026 03:20
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