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

Add modal for inviting users to a workspace #3463

Merged
merged 38 commits into from
Jun 15, 2021
Merged

Conversation

Jag96
Copy link
Contributor

@Jag96 Jag96 commented Jun 9, 2021

cc @mountiny

Details

This PR adds the ability to invite a user to a workspace.

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/166040

Tests

  1. Go to expensify.com.dev (or expensify.com if testing on prod) and get the policyID of your testing account. You can find this by going to https://www.expensify.com.dev/admin_policies and clicking on one of the policies and you'll see it in the URL. For example, the one I'm using to test is 4A19DC10B34DC505.
  2. Since the workspace people list page isn't done yet, the easiest way to remove users while testing is to go to the URL mentioned above, choose a policy, choose People and remove that way.
  3. Update InitialPage.js and add the following object to menuItems, this will allow us to easily navigate to the modal on all platforms while testing (replace the policyID with your policyID)
    1. {translationKey: 'common.invite', icon: Profile, action: () => { Navigation.navigate(ROUTES.getWorkspaceInviteRoute('4A19DC10B34DC505')); },},
  4. Run the app and go to settings, and click on the bottom option Invite (the one we added in step 2), and confirm that the modal opens with the Invite button disabled. Confirm that the welcomeNote placeholder value contains the policy name.
  5. Open the Application tab of the Chrome inspector (web is the easiest way to test this) and type in policy_4A19DC10B34DC505 in the filter bar (replace 4A19DC10B34DC505 with your policyID), confirm you see the policy object w/ the employeeList
    image
  6. Add a new user via the invite modal, confirm that after hitting the Invite button the modal disappears.
  7. Refresh the value in the Application tab of the Chrome inspector, confirm that the new email is added
  8. In the Chrome inspector, filter using personalDetails, confirm the invited user's personal details show up
  9. To test the failure case, you can take one of two routes:
  10. Internal to Expensify - update the dev code of the API to throw an Exception inside the Policy_Employees_Merge command of the PHP api
  11. External - update the .then handler of Policy_Employees_Merge in Policy.js so that the data.jsonCode === 200 check is now data.jsonCode !== 200
  12. Invite another user via the modal, confirm that the modal closes and you see an error message
  13. Check the Application tab of the Chrome inspector, confirm that the invited email doesn't show up in the list

QA Steps

N/A, this will be more easily testable by QA in https://github.com/Expensify/Expensify/issues/166468

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

iOS

Android

@Jag96 Jag96 self-assigned this Jun 9, 2021
src/libs/actions/Policy.js Outdated Show resolved Hide resolved
@marcaaron marcaaron self-requested a review June 11, 2021 23:11
@Jag96 Jag96 marked this pull request as ready for review June 15, 2021 04:10
@Jag96 Jag96 requested a review from a team as a code owner June 15, 2021 04:10
@MelvinBot MelvinBot requested review from HorusGoul and removed request for a team June 15, 2021 04:10
@Jag96
Copy link
Contributor Author

Jag96 commented Jun 15, 2021

This is ready for review!

marcaaron
marcaaron previously approved these changes Jun 15, 2021
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

LGTM and overall fine work! Really only had NAB comments.

src/languages/es.js Outdated Show resolved Hide resolved
translateLocal = (phrase, variables) => translate(preferredLocale, phrase, variables);
}
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB but maybe a good follow up. I noticed that we are doing this in every file that needs to use translate(). Perhaps we should just subscribe to the preferred locale in '../translate.js' and then we could export the method that already knows what the locale is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds like a good follow-up to me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created a follow-up PR here: #3716

if (data.jsonCode === 200) {
const policyDataToStore = _.reduce(data.policyList, (memo, policy) => ({
...memo,
[`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`]: getSimplifiedMemberList(policy),
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, I wonder if it would be more clear that this is doing a merge on an object if we instead did this...

[`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`]: {employeeList: getSimplifiedMemberList(policy)},

also seems like getSimplifiedMemberList() would return a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the name of the function to getSimplifiedEmployeeListObject, let me know if that's more clear or if you think it'd still be better to return just the array from that function instead.

src/libs/actions/Policy.js Show resolved Hide resolved
src/libs/actions/Policy.js Outdated Show resolved Hide resolved
src/libs/actions/Policy.js Show resolved Hide resolved
src/pages/workspace/WorkspaceInvitePage.js Outdated Show resolved Hide resolved
src/pages/workspace/WorkspaceInvitePage.js Outdated Show resolved Hide resolved
Comment on lines 105 to 106
const policy = _.clone(allPolicies[key]);
policy.employeeList.push(login);
Copy link
Contributor

@kidroca kidroca Jun 15, 2021

Choose a reason for hiding this comment

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

If it's a shallow copy - you are pushing to the original allPolicies[key].employeeList
It' probably won't make a difference here, but mutating your source data is bad

See: #3463 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

agree it doesn't really matter in this case, but should be avoided.

@marcaaron marcaaron merged commit 2863305 into main Jun 15, 2021
@marcaaron marcaaron deleted the joe-invite-to-workspace branch June 15, 2021 23:23
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging in version: 1.0.69-1🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.73-3🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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.

4 participants