Repository navigation
refactor(ui): move per-panel key handling into the panel modules - #604
Merged
Merged
Conversation
Each panel's handle_*_key method (and the free key-map helpers only it uses) now lives beside the panel's rendering under ui/pages/main/components/. Panels whose component file was already large (identity, vetting, repos, communities) get a keys submodule instead. Global routing, the dispatch-by-menu match, the overlays and paste handling stay in ui/pages/main/mod.rs. Pure move: no logic changes. Only imports, visibility (pub(super) / pub(in crate::ui::pages::main)) and two misplaced doc comments reattached to the items they describe. Closes #533 Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
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 #533
Moves each main-page panel's key handling out of
openvtc/src/ui/pages/main/mod.rsand puts it next to that panel's rendering. This is a mechanical move. No behaviour changes. Review it withgit show --color-moved=zebra --color-moved-ws=allow-indentation-change.What moved where
handle_vta_keycomponents/vta_panel.rshandle_personas_keycomponents/identity_panel/keys.rs(new)handle_capabilities_keycomponents/capabilities_panel.rshandle_communities_key,handle_context_delete_key,handle_device_access_key,personhood_evidence_key(+personhood_evidence_key_tests)components/communities_panel/keys.rs(new)repos_key,repos_copy_pathcomponents/repos_panel/keys.rs(new)rooms_keycomponents/rooms_panel.rselections_keycomponents/elections_panel.rshandle_inbox_keycomponents/inbox_panel.rshandle_relationships_keycomponents/relationships_panel.rshandle_credentials_keycomponents/credentials_panel.rshandle_settings_key,handle_config_form_key,passphrase_problemcomponents/settings_panel.rshandle_logs_keycomponents/logs_panel.rshandle_help_keycomponents/content_panel.rs(where Help is rendered)handle_vetting_keycomponents/vetting_panel/keys.rs(new)Four component files were already large: identity (3,962 lines), vetting (3,059), repos (2,397) and communities (1,634). Each of these gets a
keyssubmodule (<panel>.rs+<panel>/keys.rs) instead of growing further. The smaller panels take their handler at the end of the component file, before its tests.The methods stay
impl MainPageblocks, becauseimplblocks can live in any module of the crate. Child modules ofmaincan already seeMainPage's private fields andmod.rs's private helpers. Because of that, the only edits are:uselines.pub(in crate::ui::pages::main)wheremod.rscalls the item,pub(super)where only a sibling undercomponentscalls it, and private otherwise.repos_panel::keysispub(in crate::ui::pages::main)because the communities keys and themod.rstests reach into it.//!headers on the files that lacked one.Staying in
mod.rshandle_key_event: the overlays, Ctrl+K, F10, Tab/←/→, and ↑/↓/Enter on the menu.handle_content_key_eventscroll keys and the dispatch-by-menu match.mod.rstoo.handle_paste_eventwithrepos_pasteandgrant_form_text.edit_text,copy_to_clipboard.key_handler_tests. It drives the publichandle_key_evententry point across every panel and shares one set of fixtures, so splitting it per panel would mean restructuring it rather than moving it. That is left for a follow-up.Layout (lines)
main/mod.rskey_handler_tests)components/capabilities_panel.rscomponents/communities_panel.rscomponents/communities_panel/keys.rscomponents/content_panel.rscomponents/credentials_panel.rscomponents/elections_panel.rscomponents/identity_panel.rscomponents/identity_panel/keys.rscomponents/inbox_panel.rscomponents/logs_panel.rscomponents/relationships_panel.rscomponents/repos_panel.rscomponents/repos_panel/keys.rscomponents/rooms_panel.rscomponents/settings_panel.rscomponents/vetting_panel.rscomponents/vetting_panel/keys.rscomponents/vta_panel.rsVerification
cargo fmt --all --checkpasses.cargo clippy --workspace --all-targets --locked -- -D warningspasses, with and without--no-default-features.cargo clippy -p openvtc --all-targets --features dev-overrides -- -D warningspasses.RUSTDOCFLAGS='-D warnings' cargo doc --workspace --no-depspasses.cargo test --workspace --lockedpasses, with and without--no-default-features.openvtcbin unit tests: 1051 before → 1051 after, with default features and with--no-default-features.vti-stack-development-guide.mdnetworking checklist doesn't apply.Key-handling problems noticed but not fixed (input for the UX PR)
handle_capabilities_key, andedit_text's doc sat on the vettingimpl MainPageblock. Both are reattached in this PR because a move would otherwise carry them to the wrong file.view_id's doc comment is still attached towrap_textinmod.rs(not touched).d/Del removes the selected community".d/Del only arms a delete for inactive rows; for an Active row you leave withlfirst. The doc lists 3 of the roughly 20 verbs.yor Enter. Repos, workspace, elections cast/disclose and the personhood "include all" accept onlyy, on purpose, so a held Enter can't confirm. Pick one rule.j/kmean different things. In Communities,jstarts a join. In the sub-views opened from it (capabilities, rooms, elections list and ballot),j/kmove down/up. Repos, VTA, inbox, relationships, logs and the switcher have noj/kat all.rchanges meaning between levels. On the Communities listropens Repos; inside every sub-view (capabilities, rooms, elections, repos)rrefreshes.chas two jobs on the Communities list. It opens capabilities on an Active row and arms withdraw on a Pending row. The row state decides which one fires.ureturns "handled" even when the selected VIC is neither Archived nor Deleted. Help3/4return "handled" when no did-git-sign info exists. Nothing is shown to the user in either case.MainPanelSwitch(MainMenu). Sub-views send their own Back/Close. Logs detail closes on Esc or Enter.logs_selectedandlogs_detail_viewlive onMainPage, not inState, unlike every other panel. Nothing clampslogs_selectedwhen the log shrinks.handle_paste_eventroutes paste for relationships, credentials, vetting, settings and communities only. The create-persona and agent-name-manager overlays have text inputs but ignore paste with no indication.ui/pages/main/mod.rs(7k lines) into the panel components #533's suggested shape is not done yet. That shape is pureKeyEvent -> Option<Action>per panel, with footer text generated from the same table. Onlyrooms_key,elections_key,repos_keyandpersonhood_evidence_keyalready work that way. The rest still callaction_tx.senddirectly (about 200 call sites).