refactor(tui): extract LoadState rendering helpers#58
Merged
daisuke8000 merged 1 commit intomainfrom Dec 20, 2025
Merged
Conversation
Add state_renderer.rs module with common LoadState rendering patterns: - LoadStateConfig for configuring view title and messages - render_non_loaded_state() helper for Idle/Loading/Error states - render_empty() for empty data state display Refactor collections and databases views to use new helpers, reducing code duplication and improving maintainability. Changes: - Add crates/mbr-tui/src/components/state_renderer.rs (201 lines) - Simplify render_collections() and render_databases() - Reduce content.rs by ~104 lines (4427 → 4323)
daisuke8000
added a commit
that referenced
this pull request
Dec 20, 2025
Apply the extracted helpers from PR #58 and #59 to three render functions in content.rs: - render_collection_questions: Use LoadStateConfig for non-loaded states, header_style(), row_highlight_style(), HIGHLIGHT_SYMBOL - render_database_schemas: Same pattern applied - render_schema_tables: Same pattern applied This reduces content.rs from 4,427 to 4,112 lines (~315 lines removed) by eliminating duplicated LoadState pattern matching and inline style definitions across these functions. Changes: - Replace manual LoadState match arms with render_non_loaded_state() - Replace manual empty state rendering with render_empty_with_hint() - Use shared style functions instead of inline Style definitions - Use HIGHLIGHT_SYMBOL constant instead of hardcoded "► "
3 tasks
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.
Summary
state_renderer.rsmodule with common LoadState rendering patternsrender_collections()andrender_databases()to use new helpersChanges
crates/mbr-tui/src/components/state_renderer.rs(201 lines)LoadStateConfigfor configuring view title and messagesrender_non_loaded_state()helper for Idle/Loading/Error statesrender_empty()for empty data state displaycontent.rs- simplified collections and databases viewsTest plan
cargo testpassescargo clippypasses (no warnings)Related
Part 3 of crates refactoring plan (PR 2 was skipped as pagination managers have distinct responsibilities)