Repository navigation
refactor(layout): move the dialog hub out of AppLayout - #612
Merged
Merged
Conversation
AppLayout was the layout shell, the menu dispatcher and the dialog hub at once (#450). Seven useState pairs held which dialog was open and what it was opened against, so every route that wanted to open one — the menu switch, the sidebar's context menus, the toolbar — had to reach into this component, and adding a dialog meant editing the layout shell. The backup and restore pre-select state was copy-pasted between the two. dialogStore holds it instead. AppLayout still renders the dialogs; anything that wants one open says so from where it is. 369 lines to 345, and eleven useState calls to four. The target is replaced rather than merged when a dialog opens. Two separate copy-pasted preselect states could not get this wrong; one shared one can, and inheriting the connection a previous context-menu open selected is how you back up the wrong database. There is a test. The ConfirmDialog half of this issue was already closed by #588: the production gate is a general, awaitable confirm now rather than one hardcoded to destructive-query copy, and four features use it. AppLayout's own tests gained a reset for the new module-level state. They pass without it today, but a test that opens a dialog would otherwise leave it open for the next one. Closes #450 Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Closes #450. Last of the cross-cutting audit.
AppLayout was the layout shell, the menu dispatcher and the dialog hub at once. Seven
useStatepairs held which dialog was open and what it was opened against, so every route that wanted to open one — the menu switch, the sidebar's context menus, the toolbar — had to reach into this component, and adding a dialog meant editing the layout shell. The backup and restore pre-select state was copy-pasted between the two.dialogStoreholds it instead. AppLayout still renders the dialogs; anything that wants one open says so from where it is.369 → 345 lines, 11
useState→ 4.One thing the shared state makes possible to get wrong
The target is replaced rather than merged when a dialog opens. Two separate copy-pasted preselect states couldn't get this wrong; one shared one can — and inheriting the connection a previous context-menu open selected is how you back up the wrong database. There's a test.
The ConfirmDialog half was already closed
#588 replaced the hardcoded destructive-query confirm with a general, awaitable gate that four features now use. Recording that here rather than leaving it to be rediscovered.
A test-isolation note
AppLayout's tests gained a reset for the new module-level state. They pass without it today, but a test that opens a dialog would otherwise leave it open for the next.
Verification
9 new store tests. The existing AppLayout tests exercise the event→dialog path end-to-end and still pass, which is what says the extraction preserved behaviour. Unit 2035, browser 297, 0 lint errors.