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 solidus4 compatibility #172

Merged

Conversation

shahmayur001
Copy link
Contributor

Summary

This pull request introduces structural changes and enhancements to support the integration of the Solidus starter frontend with multi-domain functionality. It includes updates to controllers, test suite scripts, and test cases to ensure seamless compatibility with the starter frontend.

Key Changes

  1. Structural Changes to Support the Starter Frontend:

    • Removed Spree namespacing from controller decorators to align with the starter frontend controllers.
    • Ensured compatibility by adapting multi-domain logic to work seamlessly with the new frontend structure.
  2. Add Scripts to Run Test Suites:

    • Introduced scripts to automate the creation of the dummy-app required for running test suites.
    • Ensured that the testing environment aligns with the starter frontend's requirements.
  3. Fix Test Cases:

    • Updated test cases to prevent failures when executed alongside the starter frontend.
    • Improved test reliability by addressing issues related to multi-domain configurations and starter frontend dependencies.

Copy link

@ikraamg ikraamg left a comment

Choose a reason for hiding this comment

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

Hi @shahmayur001. Thank you so much for modernizing this codebase. It was very outdated!

I just left one requested change to modernize the search override.

An additional thought is that since the new solidus starter frontend functions by copying over all the controller and views into the app that is utilizing the gem,
I would recommend we find a solution to have the overrides you have created here also be copied be over to the app.

My rough idea is to leave them as decorators but instead convert them to templates that are copied over when running the install generator. In this way we can still test the functionality here via the spec generated app whilst handing the code over to the main application that uses this gem.

Let me know what you think!

app/models/spree/search/multi_domain.rb Outdated Show resolved Hide resolved
@shahmayur001
Copy link
Contributor Author

Hi @shahmayur001. Thank you so much for modernizing this codebase. It was very outdated!

I just left one requested change to modernize the search override.

An additional thought is that since the new solidus starter frontend functions by copying over all the controller and views into the app that is utilizing the gem, I would recommend we find a solution to have the overrides you have created here also be copied be over to the app.

My rough idea is to leave them as decorators but instead convert them to templates that are copied over when running the install generator. In this way we can still test the functionality here via the spec generated app whilst handing the code over to the main application that uses this gem.

Let me know what you think!

@ikraamg Thanks for the feedback and the suggestion!

I believe the starter frontend is developed differently, as you mentioned. It seems to be more of a template where files are copied into the main application. If we were to copy additional files, don’t you think it could lead to a lot of unnecessary clutter in the main application?

I noticed that other extensions are also handling things in a similar way to what we’ve done with this current extension.

Let me know your thoughts!

@ikraamg
Copy link

ikraamg commented Jan 22, 2025

I noticed that other extensions are also handling things in a similar way to what we’ve done with this current extension.

If this is the case with how other extensions deal with the new starter frontend, then that is okay 👍
It feels like this goes against the ethos of the template-like approach to the new starter but I won't position myself against it just for this work.

If we were to copy additional files, don’t you think it could lead to a lot of unnecessary clutter in the main application?

That is precisely what my vision was. For it to be an "in-your-face" installation so you can integrate the changes into your (assumably) already customized controllers/views from the starter 😄

@shahmayur001
Copy link
Contributor Author

That is precisely what my vision was. For it to be an "in-your-face" installation so you can integrate the changes into your (assumably) already customized controllers/views from the starter 😄

Maybe in that case, we can introduce a new generator command or propose the question later on to users, giving them the option to include it in the main application. That way, it becomes a choice

@shahmayur001 shahmayur001 force-pushed the fix-solidus4-compatibility branch from dcb4cdf to e40485a Compare January 27, 2025 08:42
@shahmayur001
Copy link
Contributor Author

@kennyadsl You were right about this change, it is affecting the PR as well

solidusio/solidus#6062

@shahmayur001 shahmayur001 force-pushed the fix-solidus4-compatibility branch from 11daf38 to aac1289 Compare January 28, 2025 12:03
@shahmayur001 shahmayur001 force-pushed the fix-solidus4-compatibility branch from aac1289 to bb655e7 Compare January 28, 2025 13:58
@shahmayur001
Copy link
Contributor Author

@kennyadsl You were right about this change, it is affecting the PR as well

solidusio/solidus#6062

@kennyadsl I’ve fixed the issue. Feel free to review it.

@fthobe
Copy link

fthobe commented Jan 30, 2025

@ikraamg Can you review the changes?

@ikraamg
Copy link

ikraamg commented Jan 30, 2025

@fthobe Sure. The PR will still need a write-access reviewer before merging but my review can add to the confidence of that final review.

@fthobe
Copy link

fthobe commented Jan 30, 2025

@ikraamg so you are just a poser having us do your work 😂

Copy link

@ikraamg ikraamg left a comment

Choose a reason for hiding this comment

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

This looks great!

The comments are not related to functional blockers but general improvements to further modernize this codebase and also reduce the amount of decorators/overrides.

Copy link

Choose a reason for hiding this comment

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

This controller turns out to be mostly a duplicate as it was probably implemented before solidus_backend had it own stores controller/UI. It can pretty much be ripped out a long with its permission sets etc. The view looks slightly different but does not seem to be missing anything essential aside from perhaps the @payment_methods and @shipping_methods

def index
@searcher = build_searcher(params)
@products = @searcher.retrieve_products
@taxonomies = get_taxonomies
Copy link

Choose a reason for hiding this comment

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

I believe the only change to this is get_taxonomies to store the @taxons.
It would be more ideal to not override this file but instead override: https://github.com/solidusio/solidus_starter_frontend/blob/main/templates/app/controllers/concerns/taxonomies.rb

which is made available in the store controller (parent of this one): https://github.com/solidusio/solidus_starter_frontend/blob/652caa6355253c969248fb66f1703bfe9879e927/templates/app/controllers/store_controller.rb#L6

Copy link
Member

Choose a reason for hiding this comment

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

Right, there's an helper method called taxonomies now, which should return the same thing. If we want to keep backward compatibility we can still set the instance variables in a before_action. By the way, why are we overwriting this controller? It doesn't seem like it's doing anything around multi stores.

display_includes.
with_prices(current_pricing_options).
includes([:option_values, :images])
@taxonomies = get_taxonomies
Copy link

Choose a reason for hiding this comment

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

@taxonomies = get_taxonomies
@product_properties = @product.product_properties.includes(:property)
@taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id]
@similar_products = @product.similar_products.select { |product| product.stores.include?(current_store) }
Copy link

Choose a reason for hiding this comment

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

In this case, it would be better to override the similar products method in the product model. Making both changes would mean that this override is not needed AFAIK.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, that's the place! @shahmayur001 what do you think about changing similar_products instead?

module SolidusMultiDomain
module TaxonsControllerDecorator
def show
@taxon = ::Spree::Taxon.find_by_store_id_and_permalink!(current_store.id, params[:id])
Copy link

Choose a reason for hiding this comment

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

This change can be implemented on the load_taxon method to avoid overriding the show method.

return unless @taxon
@searcher = build_searcher(params.merge(taxon: @taxon.id))
@products = @searcher.retrieve_products
@taxonomies = get_taxonomies
Copy link

Choose a reason for hiding this comment

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

This would be solved in the same way as the previous comments regarding taxonomy loading.

Copy link

Choose a reason for hiding this comment

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

This file can be removed as the get_taxons method was removed: solidusio/solidus@fc491a7

Comment on lines +18 to 26
@taxonomies ||= if current_store.present?
::Spree::Taxonomy.where(["store_id = ?",
current_store.id])
else
::Spree::Taxonomy
end
@taxonomies = @taxonomies.includes(root: :children)
@taxonomies
end
Copy link

@ikraamg ikraamg Jan 30, 2025

Choose a reason for hiding this comment

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

I think this is the method that is available in the new starter frontend through the taxon helper so not required here anymore.

@fthobe
Copy link

fthobe commented Jan 30, 2025

hey @ikraamg
thank you very much for your dettailed feedback.

We appreciate the work you put in the comments, but as far as I understood sometimes opinions here vary on what should be removed and what not.

Is the goal here a major release or having the app restored to a working state?
If we rip stuff out we might break things for users of previous versions of solidus and might require a major release which is something very difficult to obtain on solidus as you might see from the last version bump (from I believe 10 years ago).

I am happy to dedicate mayur to do that, but I would like a defined outcome giving that we delegating our company ressources to open source beyond a scope that provides what we need.

Are going for a major release here that will be maintained by somebody or making making cosmetics for the main repo?

@ikraamg
Copy link

ikraamg commented Jan 30, 2025

@fthobe I don't have anything against merging this as is since it contains everything to get this working again.

I can perhaps find some time in the upcoming weeks to make the remaining improvements in a seperate PR.

@fthobe
Copy link

fthobe commented Jan 30, 2025

@ikraamg that would be absolutely great!

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.

I agree about all of the @ikraamg improvement proposals, but yes, most of them were already there before, and might be out of scope for this PR. Still, it would be great to leave the extension in a better place and remove some technical debt if anyone has will to do it.

def index
@searcher = build_searcher(params)
@products = @searcher.retrieve_products
@taxonomies = get_taxonomies
Copy link
Member

Choose a reason for hiding this comment

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

Right, there's an helper method called taxonomies now, which should return the same thing. If we want to keep backward compatibility we can still set the instance variables in a before_action. By the way, why are we overwriting this controller? It doesn't seem like it's doing anything around multi stores.

def tree(root_taxon:, item_classes:, current_item_classes:, max_level:)
return if max_level < 1 || root_taxon.children.empty?

filtered_taxons = root_taxon.children.joins(:taxonomy).where("spree_taxonomies.store_id = ?",
Copy link
Member

Choose a reason for hiding this comment

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

is this the only change made in this class?

@taxonomies = get_taxonomies
@product_properties = @product.product_properties.includes(:property)
@taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id]
@similar_products = @product.similar_products.select { |product| product.stores.include?(current_store) }
Copy link
Member

Choose a reason for hiding this comment

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

Agree, that's the place! @shahmayur001 what do you think about changing similar_products instead?

@kennyadsl kennyadsl merged commit b174409 into solidusio-contrib:main Jan 31, 2025
6 checks passed
@fthobe
Copy link

fthobe commented Jan 31, 2025

@kennyadsl we can do that in a second run by end of march. We are currently giving priority to a Running System.

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.

4 participants