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: Updates user segment tab when a segment is created/updated #4950

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

tiagoapolo
Copy link
Contributor

@tiagoapolo tiagoapolo commented Jan 3, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Ref: #4859

  • Replaced the inline form and user tab content with the new CreateSegmentRulesTabForm and CreateSegmentUsersTabContent components.
  • Adds refresh button to refetch users list
  • Updates user identity list after segment update/creation

How did you test this code?

  1. In segments page create/update a segment rule adding a user to that segment
  2. Go to users tab and make sure an environment is selected
  3. Check if user/identity is in that segment
  4. If not try clicking refresh and verify if user is now in that segment
Screenshot 2025-01-08 at 08 51 31

@tiagoapolo tiagoapolo requested a review from a team as a code owner January 3, 2025 03:35
@tiagoapolo tiagoapolo requested review from kyle-ssg and removed request for a team January 3, 2025 03:35
Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2025 0:40am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2025 0:40am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jan 8, 2025 0:40am

@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label Jan 3, 2025
@tiagoapolo tiagoapolo self-assigned this Jan 3, 2025
@github-actions github-actions bot added the fix label Jan 3, 2025
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-4950 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-4950 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-4950 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4950 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4950 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-4950 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Uffizzi Preview deployment-59461 was deleted.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

Hmm... @tiagoapolo this still doesn't seem to work correctly. It seems like it doesn't update each time, only after you update the segment twice? See recording here:

4950_202501071057.mov

@matthewelwell
Copy link
Contributor

As discussed on the standup with @tiagoapolo, this is actually caused by the fact that the logic to get the segments for a given identity uses the environment document, which is updated asynchronously by the task processor. See the code here, and subsequently here.

Thus, the issue raised by myself above actually requires an improvement to be implemented in the API. Some options for this are:

  1. Allow certain endpoints to rebuild the environment document synchronously
  2. Add a new endpoint to rebuild the environment document synchronously
  3. Update the logic linked above to use ORM models, mapped accordingly and passed into the engine

My preference would likely be (3) but will probably require changes to the engine as well.

Another, simpler issue would be to add a 'reload' option to the 'Users' tab so that users can manually reload the list which would allow them to reload after making a change to the segment. What do you think about this approach @tiagoapolo ?

@tiagoapolo
Copy link
Contributor Author

As discussed on the standup with @tiagoapolo, this is actually caused by the fact that the logic to get the segments for a given identity uses the environment document, which is updated asynchronously by the task processor. See the code here, and subsequently here.

Thus, the issue raised by myself above actually requires an improvement to be implemented in the API. Some options for this are:

  1. Allow certain endpoints to rebuild the environment document synchronously
  2. Add a new endpoint to rebuild the environment document synchronously
  3. Update the logic linked above to use ORM models, mapped accordingly and passed into the engine

My preference would likely be (3) but will probably require changes to the engine as well.

Another, simpler issue would be to add a 'reload' option to the 'Users' tab so that users can manually reload the list which would allow them to reload after making a change to the segment. What do you think about this approach @tiagoapolo ?

Makes sense! Also by having a refresh btn we don't need to refetch the list when the tab is loaded.

2. updates user identity list after segment update/creation
Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

Looks good to me now

@tiagoapolo tiagoapolo merged commit 6c9ad03 into main Jan 9, 2025
31 checks passed
@tiagoapolo tiagoapolo deleted the fix/4859--update-user-segment-tab branch January 9, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants