Skip to content

refactor(tui): extract LoadState rendering helpers#58

Merged
daisuke8000 merged 1 commit intomainfrom
refactor/pr3-loadstate-helpers
Dec 20, 2025
Merged

refactor(tui): extract LoadState rendering helpers#58
daisuke8000 merged 1 commit intomainfrom
refactor/pr3-loadstate-helpers

Conversation

@daisuke8000
Copy link
Owner

Summary

  • Add state_renderer.rs module with common LoadState rendering patterns
  • Refactor render_collections() and render_databases() to use new helpers
  • Reduce content.rs by ~104 lines

Changes

  • New: crates/mbr-tui/src/components/state_renderer.rs (201 lines)
    • LoadStateConfig for configuring view title and messages
    • render_non_loaded_state() helper for Idle/Loading/Error states
    • render_empty() for empty data state display
  • Modified: content.rs - simplified collections and databases views

Test plan

  • cargo test passes
  • cargo clippy passes (no warnings)
  • TUI functionality preserved

Related

Part 3 of crates refactoring plan (PR 2 was skipped as pagination managers have distinct responsibilities)

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 daisuke8000 merged commit 3dbed2b into main Dec 20, 2025
1 check passed
@daisuke8000 daisuke8000 deleted the refactor/pr3-loadstate-helpers branch December 20, 2025 13:25
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 "► "
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