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(ui): enable super user ID editing #663

Merged
merged 46 commits into from
Jul 26, 2024
Merged

fix(ui): enable super user ID editing #663

merged 46 commits into from
Jul 26, 2024

Conversation

asharonbaltazar
Copy link
Collaborator

@asharonbaltazar asharonbaltazar commented Jul 19, 2024

Purpose

This PR addresses a critical bug which prevented super users from submitting ID edits.

However, since I've changed the way the user is routed to /details in #644, this meant that redirecting the super user back to the /details/:authority/:updatedId needed to be addressed as well.
After studying the logic, I realized that it can be simplified to a single function called getOriginForm. It will determine where the action originated from and append the appropriate tab if needed. This new direction required me to change the origin params and update multiple forms.

Linked Issues to Close

https://qmacbis.atlassian.net/browse/OY2-29122

Approach

  • give the useOrigin hook a new identity – introducing getFormOrigin:
    • First, it made no sense it was a hook since it didn't interact with the component's lifecycle. Calling new URLSearchParams(window.location.search) in any submit function would serve the present URL params. The old code had to deal with hook limitations (can't call in other functions, cannot be conditional, etc.) for no reason.
    • Second, the ORIGIN param had to be mapped to a route. This decision added another complexity since the ORIGIN param itself could just be a route, circumventing the mapping entirely.
    • Third, since :authority wasn't a param and thus inaccessible in some cases, useOrigin wasn't equipped to redirect the user to the appropriate route.
    • All in all, redirecting a user meant each form component had four or five imports dedicated to determining the correct destination. getFormOrigin, thanks to ORIGIN param changes and improvements from fix(ui): waivers tab fix #644, can now determine where to redirect the user. Redirecting a user to /details means we have to provide the correct :authority and :id params. Redirecting a user to the correct dashboard tab means we have to provide the correct authority. The function isn't that intelligent, but it's a small price to pay, IMO, for simplicity and maintainability.
  • update all forms previously using useOrigin to use getFormOrigin
  • update CheckDocumentFunction for updated IDs to poll until a new timestamp is detected
  • lift some arguments from submitActionForm into onSubmit in ActionForm for separation of concerns
  • fix the ID editing form by including the missing id property

asharonbaltazar and others added 30 commits July 11, 2024 15:33
Copy link

codeclimate bot commented Jul 26, 2024

Code Climate has analyzed commit 6109b46 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 16.8% (50% is the threshold).

This pull request will bring the total coverage in the repository to 39.9% (0.1% change).

View more on Code Climate.

Copy link
Collaborator

@benjaminpaige benjaminpaige left a comment

Choose a reason for hiding this comment

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

Looks a lot cleaner to me. just make sure it gets tested before merging. and then please do not start any more tickets today.

src/services/data/handlers/sinkMain.ts Show resolved Hide resolved
@asharonbaltazar asharonbaltazar merged commit 24fe0c8 into master Jul 26, 2024
24 checks passed
@asharonbaltazar asharonbaltazar deleted the super-user-id branch July 26, 2024 14:55
Copy link
Contributor

🎉 This PR is included in version 1.5.0-val.66 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @val status: READY PR is ready for review type: FIX Submit bug fixes type: REFACTOR Restructure existing code while preserving its external behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants