refactor: split panel.js into menu sections - #18
Merged
Merged
Conversation
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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).modules/panel.jsPanel;subtitleFormodules/menu-items.jsmodules/navigable-section.jsmodules/exit-node-section.jsmodules/device-section.jsmodules/taildrop-section.jspanel.jslands 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 intests/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 runafter every commit: 722 passed.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.