refactor(statmodel): consolidate submit and clear comparison matrix button to one namespace#132
refactor(statmodel): consolidate submit and clear comparison matrix button to one namespace#132tonywu1999 merged 2 commits intodevelfrom
Conversation
…utton to one namespace
WalkthroughThis pull request consolidates multiple per-mode submit and clear button IDs into unified global IDs across the statmodel comparison panels. Constants, server logic, UI definitions, styling, and tests are updated to reference Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as Comparison Panels
participant Server
participant Handler as Submit/Clear Handler
participant Matrix as matrix_build()
rect rgb(220, 240, 255)
note over User,Matrix: Old Flow (Per-Mode Buttons)
User->>UI: Click custom_pairwise_submit
UI->>Server: Trigger custom_pairwise_submit input
Server->>Handler: observeEvent(custom_pairwise_submit)
Handler->>Matrix: Call matrix_build(mode="custom_pairwise")
end
rect rgb(240, 255, 240)
note over User,Matrix: New Flow (Unified Submit Button)
User->>UI: Click comparisons_submit
UI->>Server: Trigger comparisons_submit input
Server->>Handler: observeEvent(comparisons_submit)
Handler->>Matrix: Call matrix_build() with per-mode branching
Matrix->>Matrix: Route to mode-specific logic internally
end
rect rgb(255, 245, 220)
note over User,Matrix: Reset Flow (Unified Clear Button)
User->>UI: Click comparisons_clear
UI->>Server: Trigger comparisons_clear input
Server->>Handler: observeEvent(comparisons_clear)
Handler->>Handler: Reset all UI elements
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
R/statmodel-ui-comparisons.R (1)
45-46: LGTM! UI panels successfully consolidated to unified button IDs.All four comparison panel builders now use the same
comparisons_submitandcomparisons_clearbutton IDs, enabling the single-trigger model in the server logic.The button labels vary between "Add" and "Submit" for the submit action. While this may reflect different user interactions (adding to a list vs. submitting the full matrix), consider standardizing for consistency if the underlying behavior is identical.
Also applies to: 56-57, 65-66, 78-79
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
R/constants.R(1 hunks)R/module-statmodel-server.R(3 hunks)R/statmodel-ui-comparisons.R(3 hunks)R/statmodel-ui-headers.R(1 hunks)tests/testthat/test-module-statmodel-server.R(9 hunks)tests/testthat/test-statmodel-ui-options-contrasts.R(4 hunks)tests/testthat/test-utils-statmodel-server.R(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (6)
tests/testthat/test-statmodel-ui-options-contrasts.R (1)
8-9: LGTM! Tests correctly updated for unified button IDs.All four test cases now consistently verify the presence of the consolidated
comparisons_submitandcomparisons_clearbutton IDs instead of mode-specific variants. This aligns with the PR's objective to consolidate UI controls.Also applies to: 22-23, 34-35, 49-50
tests/testthat/test-module-statmodel-server.R (1)
194-194: LGTM! Server tests updated consistently.All test cases now trigger matrix building and validation through the unified
NAMESPACE_STATMODEL$comparisons_submitinput. The incremental counter pattern on lines 502 and 506 correctly tests duplicate submission handling.Also applies to: 241-241, 284-284, 330-330, 379-379, 419-419, 457-457, 502-502, 506-506, 543-543
R/statmodel-ui-headers.R (1)
10-17: LGTM! CSS styling consolidated correctly.The styling now targets the unified
comparisons_submitandcomparisons_clearbuttons, eliminating redundant per-mode button styles. This aligns with the UI consolidation across all comparison panels.tests/testthat/test-utils-statmodel-server.R (1)
348-348: LGTM! UI helper tests updated correctly.The
get_contrast_panel_uitests now verify that all comparison modes return UI containing the unifiedcomparisons_submitandcomparisons_clearidentifiers, confirming consistent button IDs across all panels.Also applies to: 350-350, 356-356, 364-364
R/module-statmodel-server.R (1)
471-475: LGTM! Server logic correctly consolidated to unified triggers.All reactive expressions (
Rownames,check_cond,matrix_build) now respond to the singlecomparisons_submittrigger, while the clear observer usescomparisons_clear. Since the UI renders only one comparison panel at a time via conditional rendering (line 462-464), there are no conflicts from shared button IDs.Also applies to: 488-492, 496-516, 519-523
R/constants.R (1)
2-12: LGTM! Constants correctly updated for consolidated button model.The
NAMESPACE_STATMODELnow includes the unifiedcomparisons_submitandcomparisons_clearkeys while retaining mode-specific input identifiers (choice fields, names, weights) that remain distinct across comparison types. TheCONSTANTS_STATMODELcomparison mode values are appropriately preserved.
…utton to one namespace (#132)
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.