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

Issue #3432109: Add new route /my-settings to redirect users to their settings page #3824

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

tregismoreira
Copy link
Contributor

@tregismoreira tregismoreira commented Mar 19, 2024

Problem

Currently, there is no easy way for users to go to their settings page unless they know their User ID, given that the path to the original route is /user/{user}/edit. It makes the UX to be somehow degraded.

Solution

The solution is to create a custom route /my-settings which redirects the users to their settings page, so they don't need to think about it.

The same approach is already applied to other extensions (eg. /my-invites and /my-events).

Issue tracker

Theme issue tracker

N/A

How to test

  • Checkout branch feature/3432109-new-route-my-settings of Open Social
  • As an authenticated user
  • Go to /my-settings page
  • The expected result is that the user is redirected to their /user/{user}/edit page

Definition of done

Before merge

  • Code/peer review is completed
  • All commit messages are clear and clean. If applicable a rebase was performed
  • All automated tests are green
  • Functional/manual tests of the acceptance criteria are approved
  • All acceptance criteria were met
  • New features or changes to existing features are covered by tests, either unit (preferably) or behat
  • Update path is tested. New hook_updates should respect update order, right naming convention and consider hook_post_update code
  • Module can be safely uninstalled. Update/implement hook_uninstall and make sure that removed configuration or dependencies are removed/uninstalled
  • This pull request has all required labels (team/type/priority)
  • This pull request has a milestone
  • This pull request has an assignee (if applicable)
  • Any front end changes are tested on all major browsers
  • New UI elements, or changes on UI elements are approved by the design team
  • New features, or feature changes are approved by the product owner

After merge

  • Code is tested on all branches that it has been cherry-picked
  • Update hook number might need adjustment, make sure they have the correct order
  • The Drupal.org ticket(s) are updated according to this pull request status

Screenshots

N/A

Release notes

N/A

Change Record

N/A

Translations

N/A

Copy link

mergeable bot commented Mar 19, 2024

Thanks for contributing towards Open Social! A maintainer from the @goalgorilla/maintainers group might not review all changes from all teams/contributors. Please don't be discouraged if it takes a while. In the meantime, we have some automated checks running and it might be that you will see our comments with some tips or requests to speed up the review process. 😊

@tregismoreira tregismoreira added team: enterprise This PR originates from the ECI team type: feature Adds a new feature to Open Social prio: low labels Mar 19, 2024
@tregismoreira tregismoreira force-pushed the feature/3432109-new-route-my-settings branch from 2d3cfb1 to ff9270b Compare March 19, 2024 15:17
Copy link
Member

@Kingdutch Kingdutch left a comment

Choose a reason for hiding this comment

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

Hey Thiago,

This looks like a good improvement to add consistency to the set of /my-* routes we already have! :D

To make sure this keeps working (since people may bookmark it for example) I think we might benefit from a Behat test that ensures that when you're logged in and you go to /my-settings you end up on your settings edit page.

With that test we can also do some refactoring and remove the need for a custom route in social_user.routing.yml and the method in SocialUserController. The redirect behaviour we have here is provided for us by Drupal Core in the path_alias module which is already enabled in Open Social by default. We could create a path alias in hook_install to let that module take care of it: https://drupal.stackexchange.com/a/291584/2166

Finally, while I'm excited to see code improvements that remove lines from the PHPStan baseline 🎉 it's usually a good idea to pull those out to a separate PR. This makes reviewing the PRs easier because they're more focused on a specific change and don't need to check whether the other change has impact on what's being described in the PR message.

Let me know if you need any help! :D

@tregismoreira
Copy link
Contributor Author

Hi @Kingdutch. Thanks for your feedback :)

As we discussed internally, instead of using a path alias, I've replaced the custom route controller by the core \Drupal\user\Controller\UserController::userEditPage which is the same as used in the user.edit route.

Besides, I've also added a Behat test to make sure the /my-settings path will be redirected to /user/*/edit.

Looking forward to your feedback.

Copy link
Member

@bramtenhove bramtenhove left a comment

Choose a reason for hiding this comment

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

Great! Thanks Thiago 💪

@bramtenhove bramtenhove dismissed Kingdutch’s stale review March 21, 2024 18:45

Final point will be picked up in new PRs.

Copy link
Member

@Kingdutch Kingdutch left a comment

Choose a reason for hiding this comment

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

The only thing left to do before we merge this is to clean up the commits :D We currently rebase all our PRs onto main when merging which causes a linear history. To ensure that history stays readable we try to avoid commits that simply say "Fix " since those commits don't really communicate intention and they're really all part of the work for the first commit :)

You can git rebase the branch locally to squash all commits into a small number of commits that document the intended changes (for this PR that could be just the first one).

Your initial commit "Issue #3432109: Add new route /my-settings to redirect users to their settings page" communicates what we do very well. I think on Slack we've had some discussion on why we ended up choosing to create the route and have it point to the existing controller. Summarising that in the body of the commit message will help developers in the future (which might be us) to see why we choose a certain solution and make an informed decision of whether those reasons have perhaps changed :)

@ribel ribel added the needs work: commit cleanup This change requires a decision record in Slite label Mar 25, 2024
@tregismoreira tregismoreira force-pushed the feature/3432109-new-route-my-settings branch from 0cfda2c to 376564c Compare March 27, 2024 19:04
@ribel ribel added this to the 12.4.0 milestone Mar 28, 2024
@tregismoreira tregismoreira added needs work: commit cleanup This change requires a decision record in Slite and removed needs work: commit cleanup This change requires a decision record in Slite labels Mar 28, 2024
…ir settings page

In order to help users going to their settings page, this commit is adding:

- A new custom route which path is `/my-settings`, using the core controller `\Drupal\user\Controller\UserController::userEditPage` so we don't need to maintain in ourselves;
- A Behat test to check if the route is properly redirection users to `/users/*/edit`.
@tregismoreira tregismoreira force-pushed the feature/3432109-new-route-my-settings branch from 376564c to 39b9720 Compare March 28, 2024 19:30
@tregismoreira
Copy link
Contributor Author

tregismoreira commented Mar 28, 2024

@Kingdutch the PHPStan fix was actually only needed because in my first solution I was creating a custom method to use in the route controller. Now that we are not changing \Drupal\social_user\Controller\SocialUserController anymore, PHPStan won't alert the anymore.

So I've removed the fix from this PR, and squashed the other commits to make it cleaner. We can create a separate PR with this fix later.

Copy link
Member

@Kingdutch Kingdutch left a comment

Choose a reason for hiding this comment

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

Focused and tested PR 🎉

@Kingdutch Kingdutch merged commit a3a3e54 into main Mar 29, 2024
186 of 187 checks passed
@Kingdutch Kingdutch deleted the feature/3432109-new-route-my-settings branch March 29, 2024 08:09
@Kingdutch
Copy link
Member

🍒 picked to 12.4.x as 379c1f3

@Kingdutch Kingdutch added status: no action needed and removed needs work: commit cleanup This change requires a decision record in Slite labels Mar 29, 2024
@ronaldtebrake ronaldtebrake added the backport: verified This pull request has been back ported to an older minor version label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport: verified This pull request has been back ported to an older minor version prio: low team: enterprise This PR originates from the ECI team type: feature Adds a new feature to Open Social
Development

Successfully merging this pull request may close these issues.

5 participants