Skip to content

Conversation

@lodewiges
Copy link
Contributor

@lodewiges lodewiges commented Dec 12, 2025

Summary
Adds sub_provider field to Users for storing additional provider metadata.

Database changes:

New indexed sub_provider string column on users table (migration 20251209160709_add_user_subprovider.rb)
UI changes:

Added to new Sofia account user creation modal
Added to user settings edit modal under account data section
Input auto-uppercases via inline JavaScript
Controller changes:

Permitted in users_controller.rb for both create and update actions
Other information
Field appears in forms at:

app/views/users/_new_sofia_account_user_modal.html.erb (line 16)
app/views/users/_edit_sofia_account_modal.html.erb (line 24)

Summary by CodeRabbit

  • New Features

    • Added SubProvider field to user account editing forms. The field automatically transforms input to uppercase and is conditionally displayed based on configuration settings.
  • Chores

    • Updated parameter whitelisting to support additional user attributes and nested account properties.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The pull request adds support for a new sub_provider field across the user management system. Changes include permitting the sub_provider parameter in the controller, adding conditional form inputs in two view partials when a subprovider_label configuration is present, and exposing the label configuration from an environment variable.

Changes

Cohort / File(s) Summary
Parameter Whitelisting
app/controllers/users_controller.rb
Added sub_provider to permitted parameters in user update action and nested sofia_account_attributes with id and username for the update_with_sofia_account path.
View Form Updates
app/views/users/_edit_sofia_account_modal.html.erb, app/views/users/_modal.html.erb
Added conditional sub_provider input fields in both modals that render only when Rails.application.config.x.subprovider_label is present, with required validation and uppercase transformation (CSS + JavaScript).
Configuration
config/application.rb
Exposed new configuration key config.x.subprovider_label loaded from the SUBPROVIDER_LABEL environment variable with a default value of nil.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10-15 minutes

  • Consistent pattern applied across multiple view files (configuration-driven conditional rendering)
  • No complex logic; straightforward parameter whitelisting and form field additions
  • Homogeneous changes reduce per-file cognitive load

Possibly related PRs

Poem

🐰 A sub-provider hops into view,
Config-driven, fresh and new,
Forms transform with UPPERCASE gleam,
Parameters flow like a data stream,
Sofia's account, now complete!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description covers the key changes (database migration, UI additions, controller updates) and lists file locations, but omits testing steps and related issue references required by the template. Complete the description by including the database migration testing checklist steps and any related issues using 'fixes #xyz' format to fully comply with the template.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: adding a sub_provider field to the user interface, which aligns with the changeset's primary objective.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/make-subprovider-configerable-ui

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.62%. Comparing base (c24e5dd) to head (40443e2).
⚠️ Report is 1 commits behind head on staging.

Additional details and impacted files
@@           Coverage Diff            @@
##           staging    #1173   +/-   ##
========================================
  Coverage    77.62%   77.62%           
========================================
  Files           54       54           
  Lines         1341     1341           
========================================
  Hits          1041     1041           
  Misses         300      300           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lodewiges
Copy link
Contributor Author

@copilot write a pr description

Copy link
Contributor

Copilot AI commented Dec 12, 2025

@lodewiges I've opened a new pull request, #1174, to work on those changes. Once the pull request is ready, I'll request review from you.

@lodewiges lodewiges marked this pull request as ready for review December 18, 2025 14:55
Copilot AI review requested due to automatic review settings December 18, 2025 14:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a sub_provider field to the Users model for storing additional provider metadata. The field is conditionally displayed in Sofia account user forms based on a configurable label environment variable.

Key Changes:

  • Added indexed sub_provider string column to users table via migration
  • Added configurable SUBPROVIDER_LABEL environment variable for customizing the field label
  • Updated controller permitted parameters to allow sub_provider in create and update actions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
config/application.rb Adds subprovider_label configuration fetched from SUBPROVIDER_LABEL environment variable with default value
app/views/users/_new_sofia_account_user_modal.html.erb Adds conditional sub_provider input field with client-side uppercase transformation
app/views/users/_edit_sofia_account_modal.html.erb Adds conditional sub_provider input field with client-side uppercase transformation
app/controllers/users_controller.rb Permits sub_provider parameter in both permitted_attributes method (for create) and update_with_sofia_account action

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<% end %>
<%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres', required: true %>
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: "SubProvider", placeholder: Rails.application.config.x.subprovider_label, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The uppercase transformation is only applied on the client-side using inline JavaScript. This means if JavaScript is disabled or the user bypasses the client-side transformation, lowercase values could be saved to the database. Consider adding a server-side transformation in the User model using a before_save callback or before_validation callback to ensure the sub_provider value is always uppercase regardless of how it's submitted.

Suggested change
<%= f.input :sub_provider, label: "SubProvider", placeholder: Rails.application.config.x.subprovider_label, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<%= f.input :sub_provider, label: "SubProvider", placeholder: Rails.application.config.x.subprovider_label, input_html: { style: 'text-transform: uppercase;' } %>

Copilot uses AI. Check for mistakes.
config.x.site_short_name = ENV.fetch('SITE_SHORT_NAME', 'SOFIA')
config.x.site_long_name = ENV.fetch('SITE_LONG_NAME', 'Streepsysteem voor de Ordentelijke Festiviteiten van Inleggend Alpha')
config.x.site_association = ENV.fetch('SITE_ASSOCIATION', 'C.S.V. Alpha')

Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new SUBPROVIDER_LABEL environment variable is not documented in the .env.example file. This file should include all available environment variables with example values to help developers configure the application correctly. Consider adding a line like 'SUBPROVIDER_LABEL=Subprovider' to document this new configuration option.

Copilot uses AI. Check for mistakes.
<%= f.input :name, label: 'Naam', placeholder: 'Naam', required: true %>
<%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres', required: true %>
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: "SubProvider", placeholder: Rails.application.config.x.subprovider_label, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The uppercase transformation is only applied on the client-side using inline JavaScript. This means if JavaScript is disabled or the user bypasses the client-side transformation, lowercase values could be saved to the database. Consider adding a server-side transformation in the User model using a before_save callback or before_validation callback to ensure the sub_provider value is always uppercase regardless of how it's submitted.

Suggested change
<%= f.input :sub_provider, label: "SubProvider", placeholder: Rails.application.config.x.subprovider_label, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<%= f.input :sub_provider, label: "SubProvider", placeholder: Rails.application.config.x.subprovider_label, input_html: { style: 'text-transform: uppercase;' } %>

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/controllers/users_controller.rb (1)

170-170: Consider using symbols for consistency.

The parameter list uses strings (%w[...]) while the update_with_sofia_account method uses symbols (%i[...]) on line 143. While both work in Rails, using symbols consistently throughout the controller improves code uniformity.

🔎 Optional refactor for consistency:
-    params.require(:user).permit(%w[name email provider sub_provider])
+    params.require(:user).permit(%i[name email provider sub_provider])
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c24e5dd and 40443e2.

📒 Files selected for processing (4)
  • app/controllers/users_controller.rb (2 hunks)
  • app/views/users/_edit_sofia_account_modal.html.erb (1 hunks)
  • app/views/users/_modal.html.erb (1 hunks)
  • config/application.rb (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/controllers/users_controller.rb (1)
app/models/user.rb (1)
  • treasurer? (86-88)
⏰ 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 (3)
config/application.rb (1)

78-79: LGTM!

The configuration approach using ENV.fetch with a nil default is appropriate, enabling optional feature activation via environment variables. The conditional rendering in the views correctly checks for the presence of this config value.

Note: A previous review comment already flagged that this environment variable should be documented in .env.example.

app/views/users/_edit_sofia_account_modal.html.erb (1)

24-26: Conditional rendering logic is correct.

The conditional check ensures the SubProvider field only appears when the feature is enabled via environment configuration, which is the appropriate approach.

Note: A previous review comment already flagged that uppercase transformation should be implemented server-side to handle cases where JavaScript is disabled or bypassed.

app/controllers/users_controller.rb (1)

143-144: Parameter whitelisting is correct.

The sub_provider parameter is appropriately permitted for updates alongside other user attributes. The nested sofia_account_attributes whitelisting also correctly supports updating the associated Sofia account.

Note: As flagged in previous review comments, consider adding server-side uppercase transformation (e.g., before_save callback in the User model) to ensure data consistency regardless of client-side behavior.

Comment on lines +16 to +18
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<% end %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Standardize the label capitalization.

The label 'Subprovider' here differs from 'SubProvider' used in _edit_sofia_account_modal.html.erb (line 25). For consistency, use the same capitalization across both modals.

Note: A previous review comment already flagged that uppercase transformation should be implemented server-side.

🔎 Suggested fix to match the edit modal's capitalization:
-            <%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
+            <%= f.input :sub_provider, label: 'SubProvider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<% end %>
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: 'SubProvider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<% end %>
🤖 Prompt for AI Agents
In app/views/users/_modal.html.erb around lines 16 to 18, the input label reads
'Subprovider' but should match the capitalization used in
_edit_sofia_account_modal.html.erb ('SubProvider'); update the f.input label to
'SubProvider' for consistency and ensure the form still relies on server-side
normalization for uppercase (do not remove existing client-side transform).

@lodewiges lodewiges merged commit 8cc7816 into staging Dec 18, 2025
6 checks passed
@lodewiges lodewiges deleted the feature/make-subprovider-configerable-ui branch December 18, 2025 15:55
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.

2 participants