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

[To Main] DESENG-656 - Add user management to engagement authoring wizard #2556

Merged
merged 12 commits into from
Jul 18, 2024

Conversation

NatSquared
Copy link
Contributor

@NatSquared NatSquared commented Jul 16, 2024

Issue #: 🎟️ DESENG-656

⚠️ NOTE: PR #2555 should be merged first - this will decrease the number of changed files to 11

Description of changes:

  • Feature Add user management to engagement authoring wizard
    • Added new UI component to handle searching, selecting, and displaying users
    • Minor tweaks to existing wizard functionality
      • Minor backend change: don't throw error when setting an engagement's slug to its current value

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the met-public license (Apache 2.0).

@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.96%. Comparing base (9ce14ff) to head (f10e241).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2556   +/-   ##
=======================================
  Coverage   75.96%   75.96%           
=======================================
  Files         609      609           
  Lines       21959    21960    +1     
  Branches     1711     1711           
=======================================
+ Hits        16681    16682    +1     
  Misses       5015     5015           
  Partials      263      263           
Flag Coverage Δ
metapi 87.74% <100.00%> (ø)
metweb 64.72% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...pi/src/met_api/services/engagement_slug_service.py 94.28% <100.00%> (ø)
met-api/src/met_api/services/membership_service.py 88.97% <100.00%> (ø)
met-web/src/components/common/Input/TextInput.tsx 100.00% <100.00%> (ø)
met-web/src/services/userService/api/index.tsx 28.12% <ø> (ø)

@NatSquared NatSquared marked this pull request as ready for review July 16, 2024 19:25
@NatSquared NatSquared changed the title DESENG-656 - Add user management to engagement authoring wizard [To Main] DESENG-656 - Add user management to engagement authoring wizard Jul 16, 2024
is_reviewer = CompositeRoles.REVIEWER.value in user_details.get('main_role')
is_team_member = CompositeRoles.TEAM_MEMBER.value in user_details.get('main_role')
is_reviewer = user_details.get('main_role') == CompositeRoles.REVIEWER.value
is_team_member = user_details.get('main_role') == CompositeRoles.TEAM_MEMBER.value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was to fix a 500 error - main_role is a single string so it doesn't make much sense to ask if a role is "in" it

Copy link
Collaborator

@Baelx Baelx 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! Just one ask, I wanted to make sure the autocomplete field was labelled in some way. Let me know if I missed it.

// Remove ourselves from the list
user.id !== currentUser.userDetail.user?.id &&
// Remove admins from the list - they can already see everything and will cause an error if specified
user.main_role !== USER_COMPOSITE_ROLE.ADMIN.label,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this trailing comma necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, according to Prettier:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

😵‍💫

>
<Grid item>
<BodyText bold color="primary.light">
Team Member{selectedUsers.length > 1 && 's'} Added
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice touch :). I probably would have just done "team member(s) added"


return (
<Box width="100%">
<BodyText bold size="small">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this meant to be the label for the autocomplete field?

formData
.get('users')
?.toString()
.split(',')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this converting an array to a string and back again? Is this a way to copy an array or something?

.get('users')
?.toString()
.split(',')
.forEach(async (user_id) => {
Copy link
Collaborator

@Baelx Baelx Jul 17, 2024

Choose a reason for hiding this comment

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

I don't think async/await works with forEach loops. https://stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop

If you want to wait for the calls to finish before returning, you could use promise.all, for example. Otherwise you could just remove the async/await keywords and the execution would be the same.

Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

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

Thanks for the label!

Copy link

sonarcloud bot commented Jul 18, 2024

@NatSquared NatSquared merged commit 085451b into main Jul 18, 2024
15 checks passed
@NatSquared NatSquared deleted the feature/DESENG-656-engagement-wizard-add-users branch July 18, 2024 21:34
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