Skip to content

Conversation

@cpfergus1
Copy link
Contributor

@cpfergus1 cpfergus1 commented Aug 30, 2022

Summary

Rails introduced redirect_back in rails 5+ and redirect_back_or_to in rails 7+. The naming of Solidus method #redirect_back_or_default lead to some confusion between the two methods and it appeared that it could be replaced by the included Rails methods to eliminate redundancy and simplify the code. After further investigation, the two functions create different results and cannot be used interchangeably. Devise, however, already contains a similar function to #redirect_back_or_default, so the functionality would be best moved to solidus_auth_devise.

This will affect the following gems

solidus_frontend - solidusio/solidus_frontend#9
solidus_starter_frontend - solidusio/solidus_starter_frontend#241
solidus_auth_devise - solidusio/solidus_auth_devise#228
solidus_social - solidusio-contrib/solidus_social#109
solidus_active_shipping - archived, No plans to update
solidus_paypal_marketplace - solidusio-contrib/solidus_paypal_marketplace#103

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

  • I have written a thorough PR description.
  • I have kept my commits small and atomic.
  • I have used clear, explanatory commit messages.

The following are not always needed (cross them out if they are not):

  • I have added automated tests to cover my changes.
  • I have attached screenshots to demo visual changes.
  • I have opened a PR to update the guides.
  • I have updated the readme to account for my changes.

@cpfergus1 cpfergus1 marked this pull request as draft August 30, 2022 19:05
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch from 159765d to 3af4a82 Compare August 31, 2022 19:23
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Aug 31, 2022
@cpfergus1 cpfergus1 changed the title Deprecate #redirect_to_or_default Rename method #redirect_back_or_default Aug 31, 2022
@cpfergus1 cpfergus1 marked this pull request as ready for review August 31, 2022 19:30
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch from 3af4a82 to 76c1adf Compare August 31, 2022 19:38

def redirect_back_or_default(default)
redirect_to(session["spree_user_return_to"] || default)
def stored_location_or(fallback_location)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably implement it in solidus_auth_devise

@waiting-for-dev waiting-for-dev added the type:enhancement Proposed or newly added feature label Sep 1, 2022
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch from 76c1adf to d07e8a3 Compare September 2, 2022 19:51
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

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

Thanks, @cpfergus1! Putting it on hold until the PRs on the extensions are ready.

@waiting-for-dev waiting-for-dev added the release:major Breaking change on hold until next major release label Sep 5, 2022
@cpfergus1 cpfergus1 changed the title Rename method #redirect_back_or_default Deprecate method #redirect_back_or_default Sep 12, 2022
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch from dbc4f8c to 4f139c9 Compare September 12, 2022 12:21
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 Connor, I just left a question.

# or its subclasses. The controller will be passed to each rule for matching.
def initialize(controller)
@controller = controller
Spree::Deprecation.warn("This class will be removed without replacement on the realease of Solidus 4.0")
Copy link
Member

Choose a reason for hiding this comment

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

But are we still using this in core here? If it's not called anymore, that method should be deprecated as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!
I also removed that method from solidus_starter_frontend and solidus_auth_devise!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Devise has a nearly identical method for storing a user's location and
returning a path to navigate to. Deprecating to simplify the code base.
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch 2 times, most recently from 856f5f8 to 57fb533 Compare September 14, 2022 18:34
@cpfergus1 cpfergus1 requested a review from kennyadsl September 15, 2022 11:26
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch from 57fb533 to 16bc67a Compare September 15, 2022 12:14
We can safely eliminate the class when #redirect_back_or_default is
removed. This commit also deprecates #store_location which is the only
method that utilizes this class.
@cpfergus1 cpfergus1 force-pushed the nebulab/deprecate_redirect_to_or_default branch from 16bc67a to a6de90e Compare September 15, 2022 12:31
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 Connor, excellent work!

@kennyadsl kennyadsl merged commit 6eba6ed into solidusio:master Sep 15, 2022
waiting-for-dev added a commit to nebulab/solidus that referenced this pull request Jan 16, 2023
We deprecated `#redirect_back_or_default` method in solidusio#4533 [1]. However,
the original plan was halted because of auth problems in
solidus_auth_devise. See solidusio/solidus_auth_devise/232 for details.

[1] - solidusio#4533
[2] - solidusio/solidus_auth_devise#232
waiting-for-dev added a commit to nebulab/solidus that referenced this pull request Jan 16, 2023
We deprecated `#redirect_back_or_default` method in solidusio#4533 [1]. However,
the original plan was halted because of auth problems in
solidus_auth_devise. See solidusio/solidus_auth_devise/232 [2] for details.

[1] - solidusio#4533
[2] - solidusio/solidus_auth_devise#232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_core Changes to the solidus_core gem release:major Breaking change on hold until next major release type:enhancement Proposed or newly added feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants