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

DCJ-619: Simplify/fix useEffect infinite reload problem #2651

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

rushtong
Copy link
Contributor

@rushtong rushtong commented Aug 19, 2024

Addresses

https://broadworkbench.atlassian.net/browse/DCJ-619

Summary

This PR does a few of things that hopefully clarify and simplify the intended functionality behind this page.

  1. Move all initialization logic into a single method
  2. Load DACs based on the user role. Here, we check state to see if the user is Admin before loading all DACs on the page. This prevents a flash of seeing all DACs before they get filtered by role and instead, only become visible once state has loaded and we know which role the user is accessing DACs for.
  3. Clean up usages of lodash to use native javascript filter/map/includes functionality
  4. Reduce the useEffect dependencies to an empty array

Have you read Terra's Contributing Guide lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@rushtong rushtong marked this pull request as ready for review August 19, 2024 15:10
@rushtong rushtong requested a review from a team as a code owner August 19, 2024 15:10
@rushtong rushtong requested review from fboulnois and okotsopoulos and removed request for a team August 19, 2024 15:10
Copy link
Contributor

@fboulnois fboulnois left a comment

Choose a reason for hiding this comment

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

good catch 👍

Copy link
Member

@pshapiro4broad pshapiro4broad left a comment

Choose a reason for hiding this comment

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

The change looks OK but client side filtering based on role always makes me nervous. I assume that it's OK that a user can see all DACs even if they can't operate on them? So the filtering isn't for security, but to hide elements in the UI that would otherwise be disabled?

@rushtong
Copy link
Contributor Author

The change looks OK but client side filtering based on role always makes me nervous. I assume that it's OK that a user can see all DACs even if they can't operate on them? So the filtering isn't for security, but to hide elements in the UI that would otherwise be disabled?

Yes exactly, all DACs are visible to all users. The APIs, of course, enforce role based restrictions as well.

@rushtong rushtong merged commit c3e19de into develop Aug 19, 2024
9 checks passed
@rushtong rushtong deleted the gr-DCJ-619-refactor-use-effect branch August 19, 2024 17:54
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.

3 participants