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

Sync single user picker with Address Book in award/smite dialogs #3684

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

willm30
Copy link
Collaborator

@willm30 willm30 commented Jul 26, 2022

Description

This PR ensures that when the Address Book is enabled, the single user picker in the Award/Smite dialogs shows verified members instead of all members. When the Address Book is inactive, or no members have been added, the single user picker in both components should show all colony members.

Note: this was already happening in the Create Payment dialog. I have extracted this logic for reuse in the Award/Smite components.

To test:

  1. With no members added, verify that the SingleUserPicker in the Award/Smite show all users in the colony.
  2. Add a member or two to the address book. Now verify the SingleUserPicker only shows those members.
  3. Turn off the address book. Now verify that the SingleUserPicker is showing all users again.

Changes 🏗

CreatePaymentDialog.tsx: Extracted the verifiedUsers logic for reuse in award/smite.
ManageReputationContainer.tsx: Added the ColonyMembers prop so that when the component loads, ColonyMembers is defined. This ensures that the selected user doesn't rerender after the component has been opened and therefore avoids a "flashing" in the ui. Also added the verifiedUsers logic.
ColonyHomeActions.tsx: I moved the ColonyMembers query here because this contains the loading component nearest to the ManageReputation Container.
useSelectedUser.ts: updated to take an array of AnyUser (making it compatible with an array of verified or subscribed users)

Additions

verifiedRecipients.ts: Extracted logic for filtering subscribed (i.e. all) users by whether they're verified or not.

Resolves #3641

Note: The issue says that this should apply to all SingleUserPicker instances however after checking this with Arren we agreed that it should only apply to the Payments and Award/Smite dialogs for now (see issue comments).

@willm30 willm30 self-assigned this Jul 26, 2022
@willm30 willm30 force-pushed the fix/3641-single-user-picker-filter branch from 9f2277b to ab66da3 Compare July 26, 2022 18:43
@willm30 willm30 marked this pull request as ready for review July 26, 2022 20:09
@willm30 willm30 requested a review from a team July 26, 2022 20:09
@willm30 willm30 force-pushed the fix/3641-single-user-picker-filter branch from 737355f to 4128ea7 Compare July 27, 2022 06:20
@danbr danbr force-pushed the refactor/3532-remove-whitelist-coinmachine branch from 2662619 to 94aa383 Compare August 1, 2022 10:38
Base automatically changed from refactor/3532-remove-whitelist-coinmachine to master August 1, 2022 11:09
@willm30 willm30 marked this pull request as draft August 11, 2022 11:55
@willm30 willm30 force-pushed the fix/3641-single-user-picker-filter branch from 4128ea7 to a741d5c Compare August 14, 2022 16:03
@willm30 willm30 changed the title Fix: single user picker in award/smite Sync single user picker with address picker in award/smite & payments dialog Aug 14, 2022
@willm30 willm30 changed the title Sync single user picker with address picker in award/smite & payments dialog Sync single user picker with Address Book in award/smite & payments dialogs Aug 14, 2022
@willm30 willm30 force-pushed the fix/3641-single-user-picker-filter branch from 2d2aafd to 8bf7e4d Compare August 15, 2022 09:34
@willm30 willm30 marked this pull request as ready for review August 15, 2022 09:44
@willm30 willm30 changed the title Sync single user picker with Address Book in award/smite & payments dialogs Sync single user picker with Address Book in award/smite dialogs Aug 15, 2022
@danbr
Copy link
Contributor

danbr commented Aug 15, 2022

@willm30 Maybe my expectation is wrong?
The updates seem to be working except when I deactivate the address book. The list of potential awardees are still restricted.

Empty address book, with 1 contributor & 1 watcher
Screenshot 2022-08-15 at 15 11 22
With User2 added to address book & deactivated
Screenshot 2022-08-15 at 15 10 22
User options, expecting Dan & User2 to be displayed
Screenshot 2022-08-15 at 15 18 25

@willm30
Copy link
Collaborator Author

willm30 commented Aug 15, 2022

@willm30 Maybe my expectation is wrong? The updates seem to be working except when I deactivate the address book. The list of potential awardees are still restricted.

@danbr Did you refresh the browser after deactivating the address book? For me, I need to do this first, then the updates propagate and the form shows all users. (Incidentally, I would like to open an issue to update the fetch-policies of the relevant queries so a browser refresh isn't needed after adding a member to the address book to see the updated address book).

@danbr
Copy link
Contributor

danbr commented Aug 15, 2022

@willm30 Maybe my expectation is wrong? The updates seem to be working except when I deactivate the address book. The list of potential awardees are still restricted.

@danbr Did you refresh the browser after deactivating the address book? For me, I need to do this first, then the updates propagate and the form shows all users. (Incidentally, I would like to open an issue to update the fetch-policies of the relevant queries so a browser refresh isn't needed after adding a member to the address book to see the updated address book).

@willm30 Thanks for the suggestion. I re-setup, and did several page refreshes and the behaviour remained the same with only 1 address shown. When she is available, i will ask @chinins to test, perhaps it will work for her.

Comment on lines 172 to 177
verifiedUsers={
(isWhitelistActivated && verifiedUsers) || subscribedUsers
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@danbr Hmm, interesting. I am unable to reproduce. With a contributor and a watcher, I add the watcher to the address book, then deactivate the address book via the toggle switch, and after a browser refresh on the ColonyHome page I can see both users in the Award/Smite and CreatePayment dialogs.

This is where I implement the check for whether the whitelist is activated. It should pass the form (and therefore the Single User Picker) all users (i.e subscribedUsers) if isWhitelistActivated is false (even if there is a member added to the address book). Maybe you can spot something I'm overlooking?

Copy link
Contributor

Choose a reason for hiding this comment

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

@willm30 Finally, I deleted my local branch and now its behaving as expected, thankfully!! I'll review the code next....

Copy link
Contributor

@danbr danbr 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. Working well..... Nice job.

Copy link
Contributor

@chinins chinins left a comment

Choose a reason for hiding this comment

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

As per my direct comments.

@willm30 willm30 force-pushed the fix/3641-single-user-picker-filter branch 2 times, most recently from d2f0ff6 to cbbef22 Compare August 17, 2022 20:32
@willm30 willm30 requested a review from chinins August 17, 2022 20:33
@willm30
Copy link
Collaborator Author

willm30 commented Aug 17, 2022

As per my direct comments.

@chinins Have updated and restored the Memebrs Query to the component. Please review when you get a moment.

Copy link
Contributor

@Julianahlk Julianahlk left a comment

Choose a reason for hiding this comment

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

It works well for me!

Copy link
Contributor

@ArmandoGraterol ArmandoGraterol left a comment

Choose a reason for hiding this comment

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

Working as expected! Nice job

Copy link
Contributor

@chinins chinins left a comment

Choose a reason for hiding this comment

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

Very nice - much cleaner, I prefer it this way.

@willm30 willm30 force-pushed the fix/3641-single-user-picker-filter branch from cbbef22 to 422cd5a Compare August 24, 2022 06:11
@willm30 willm30 merged commit 12d3c67 into master Aug 24, 2022
@willm30 willm30 deleted the fix/3641-single-user-picker-filter branch August 24, 2022 06:20
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.

With Address Book enabled, all SingleUserPicker fields should filter members
5 participants