Skip to content

Add form components for preference fields - #6713

Closed
benjaminwil wants to merge 1 commit into
solidusio:mainfrom
benjaminwil:preference-fields-components
Closed

benjaminwil wants to merge 1 commit into
solidusio:mainfrom
benjaminwil:preference-fields-components

Conversation

@benjaminwil

Copy link
Copy Markdown
Contributor

Summary

I have extracted this commit from #6706 to propose it be merged independently. The existence of these preference field components is required to do further admin work on payment method, calculator, and promotions UIs.

From the commit message:

Preference-enabled models (like Spree::PaymentMethod subclasses and Spree::Calculator subclasses) allow admin users to configure preferences on records from the admin interface. To support this in the new admin, we can add preference field components for each form-enabled preference type that has been historically supported in solidus_core and solidus_backend.

The component previews are rendering in tests and via Lookbook right now. In a subsequent commit I will wire up these components to work dynamically with payment method admin forms.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.49%. Comparing base (6f5b2b9) to head (4b2ad0b).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...lidus_admin/ui/preference_fields/base/component.rb 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6713      +/-   ##
==========================================
+ Coverage   92.47%   92.49%   +0.01%     
==========================================
  Files        1065     1073       +8     
  Lines       21541    21592      +51     
==========================================
+ Hits        19921    19971      +50     
- Misses       1620     1621       +1     

☔ View full report in Codecov by Harness.
📢 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.

@benjaminwil
benjaminwil marked this pull request as ready for review October 28, 2026 00:25
@benjaminwil
benjaminwil requested a review from a team as a code owner October 28, 2026 00:25
end

def label
@type.constantize.human_attribute_name("preferred_#{@preference_name}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a change from backend's t(name, scope: "spree", default: name.humanize). While probably more correct, also kind of a regression because we're missing so many of the translations for doing it your way. Something for your to-do list?

@benjaminwil benjaminwil Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added to my to-do list. 👍

@jarednorman jarednorman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think the error stuff is right yet.

Comment on lines +37 to +39
# Forwards the error so that input component templates have access to
# error context.
@args[:error] = @error if @error.blank?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We want to pass the error to the input when there is no error? Wat.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Meant nil. Thanks!

Preference-enabled models (like `Spree::PaymentMethod` subclasses and
`Spree::Calculator` subclasses) allow admin users to configure
preferences on records from the admin interface. To support this in the
new admin, we can add preference field components for each form-enabled
preference type that has been historically supported in `solidus_core`
and `solidus_backend`.

The component previews are rendering in tests and via Lookbook right
now. In a subsequent commit I will wire up these components to work
dynamically with payment method admin forms.
@benjaminwil
benjaminwil force-pushed the preference-fields-components branch from cb672fd to 4b2ad0b Compare October 29, 2026 21:47
@benjaminwil

Copy link
Copy Markdown
Contributor Author

#6706 has been approved by one core team member. It includes this commit. So I will just wait on additional approvals there and not muck around with this extracted commit anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants