Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix displaying of discarded variants in admin #4148

Conversation

luca-landa
Copy link
Contributor

@luca-landa luca-landa commented Aug 20, 2021

Description

After this, discarded variants are not displayable anymore because Discard#discarded scope now operates on kept scope and finds no result if not prepended with a larger scope, as suggested here.
This prevents the "deleted variants" filter from being displayed in the variants list on the admin panel.

This PR provides a quick fix for displaying the "deleted variants" filter again in the admin variants, which allows to display the deleted variants again.

Two alternative solutions that I considered, with the help of @spaghetticode:

  • removing the default scope: this could be pretty hard to do and could introduce a breaking change, requiring all Solidus users to manually apply the scope that is currently used as default
  • overriding the discarded scope: this implementation would be very dependent on the soft deletion gem in-use, because (as far as I know) there is no way to call the super scope from its override. It would have resulted in something like scope :discarded, -> { with_discarded.where.not(deleted_at: nil) }.

So I thought that the solution I'm proposing was more reasonable, let me know your thoughts if you disagree or I'm missing something.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

Because of the default scope added in
solidusio@466251e,
the `discarded` scope currently operates on the default `kept` scope and
returns an empty set.

This fixes the scope for checking the `discarded` variants as
suggested here https://github.com/jhawthorn/discard#default-scope, to
correctly display the "deleted variants" filter in the admin variants
page.
@luca-landa luca-landa marked this pull request as ready for review August 20, 2021 09:38
@spaghetticode spaghetticode added the type:bug Error, flaw or fault label Aug 20, 2021
Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

@luca-landa thank you for this fix 🛠️

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks Luca!

@kennyadsl kennyadsl added the changelog:solidus_backend Changes to the solidus_backend gem label Sep 1, 2021
@kennyadsl kennyadsl merged commit bac2368 into solidusio:master Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_backend Changes to the solidus_backend gem type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants