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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract the state machines into replaceable modules #3356

Merged
merged 2 commits into from Oct 3, 2019

Conversation

@cedum
Copy link
Contributor

cedum commented Sep 27, 2019

This PR extracts the existing state machines into replaceable modules.

A while ago I took ownership of some PRs that completely removes the state machines from a few models (#3038, #3039, #3040, #3041).
While I fully agree with the rationale behind those PRs, I think that rewriting manually each dynamically generated state_machines's method might not be ideal.

AFAIK, the state machines in these models don't need to be customized for the majority of the shops (please correct me). Also, having different state-related logic implementations for different models could be confusing.

By discussing this a bit with @kennyadsl, we thought that it might be worth introducing first an intermediary step that lets developers tinker more easily with the existing state machines instead of removing them completely.
This will enable the (few?) shops which require a custom state-related logic to provide their own while keeping a standard implementation for the rest. Hopefully, it could also lead to more ideas 馃挕addressing the concerns in the original PR (#3038).

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)
core/lib/spree/core/state_machines/shipment.rb Outdated Show resolved Hide resolved
core/lib/spree/core/state_machines/return_item/reception_status.rb Outdated Show resolved Hide resolved
core/lib/spree/core/state_machines/return_item/acceptance_status.rb Outdated Show resolved Hide resolved
core/lib/spree/core/state_machines/return_item/acceptance_status.rb Outdated Show resolved Hide resolved
core/lib/spree/core/state_machines/payment.rb Outdated Show resolved Hide resolved
core/lib/spree/core/state_machines/inventory_unit.rb Outdated Show resolved Hide resolved
Allow replacing the existing state machines with custom ones.
This would allow easier customization in stores.
@cedum cedum force-pushed the nebulab:extract-state-machines branch to 7c4f82c Sep 27, 2019
@BenMorganIO

This comment has been minimized.

Copy link
Contributor

BenMorganIO commented Sep 27, 2019

This is a really good idea 馃憤

Copy link
Member

kennyadsl left a comment

I really like how this allows customizing the state machine but keeps it simple for stores that do not need to change these things. I'd love to also see some Guides pages update with some simple examples, but it's not blocking. Just let me know if you plan to do so and I'll add a WIP tag to the PR. Thanks, @cedum!

Copy link
Member

spaghetticode left a comment

@cedum this is a very useful change IMHO, thank you 馃憤

@cedum

This comment has been minimized.

Copy link
Contributor Author

cedum commented Oct 1, 2019

I'd love to also see some Guides pages update with some simple examples, but it's not blocking. Just let me know if you plan to do so and I'll add a WIP tag to the PR

@kennyadsl 馃憤I'll work on it in this PR

@cedum

This comment has been minimized.

Copy link
Contributor Author

cedum commented Oct 1, 2019

I've pushed a draft for the documentation (here's the preview).

Instead of describing it for each model, I preferred to add a generic guide under Customizations.
It would be awesome to have some feedback 馃檹

@kennyadsl

This comment has been minimized.

Copy link
Member

kennyadsl commented Oct 2, 2019

I think it's a perfect starting point, thanks!

@cedum cedum force-pushed the nebulab:extract-state-machines branch to 2f370ef Oct 2, 2019
@kennyadsl kennyadsl merged commit 7a64194 into solidusio:master Oct 3, 2019
17 checks passed
17 checks passed
Header rules - solidus-docs No header rules processed
Details
Header rules - solidus-guides No header rules processed
Details
Pages changed - solidus-docs 308 new files uploaded
Details
Pages changed - solidus-guides 1 new file uploaded
Details
Redirect rules - solidus-docs No redirect rules processed
Details
Redirect rules - solidus-guides No redirect rules processed
Details
Hound No violations found. Woof!
Mixed content - solidus-docs No mixed content detected
Details
Mixed content - solidus-guides No mixed content detected
Details
ci/circleci: mysql Your tests passed on CircleCI!
Details
ci/circleci: mysql_rails51 Your tests passed on CircleCI!
Details
ci/circleci: mysql_rails52 Your tests passed on CircleCI!
Details
ci/circleci: postgres Your tests passed on CircleCI!
Details
ci/circleci: postgres_rails51 Your tests passed on CircleCI!
Details
ci/circleci: postgres_rails52 Your tests passed on CircleCI!
Details
netlify/solidus-docs/deploy-preview Deploy preview ready!
Details
netlify/solidus-guides/deploy-preview Deploy preview ready!
Details
@kennyadsl kennyadsl deleted the nebulab:extract-state-machines branch Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can鈥檛 perform that action at this time.