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

SSO: Add invite user button option #88369

Merged
merged 13 commits into from
Mar 14, 2024
Merged

SSO: Add invite user button option #88369

merged 13 commits into from
Mar 14, 2024

Conversation

renancarvalho
Copy link
Contributor

@renancarvalho renancarvalho commented Mar 11, 2024

Related to #

Proposed Changes

  • We want to align as much as possible wp-admin and calypso feature, this PR makes it possible to invite not connected users to join your site by adding an invite button to the user list
image

Testing Instructions

  • Pull and run this branch or use live link
  • Navigate to {LIVE_LINK}/people/team/{YOUR_SITE}
  • There you should be able to invite not connected users to join your site
  • You should also be allowed to revoke invited users from the pending list users
  • You should not see the same users in both lists
  • Invite users from wp-admin and check if both lists are persistent, you should see them as pending in Calypso

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@renancarvalho renancarvalho self-assigned this Mar 11, 2024
@matticbot
Copy link
Contributor

matticbot commented Mar 11, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~1375 bytes added 📈 [gzipped])

name                     parsed_size           gzip_size
people                       +3346 B  (+0.6%)    +1293 B  (+0.7%)
import-hosted-site-flow       +508 B  (+0.1%)      +82 B  (+0.0%)
import-flow                   +508 B  (+0.0%)      +82 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@renancarvalho renancarvalho changed the title Add invite button option - Draft SSO: Add invite user button option — Draft Mar 11, 2024
components: {
a: (
<a
href="https://jetpack.com/support/sso/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use localizeUrl here

@escapemanuele
Copy link
Contributor

Let's fix smaller viewports 👍

image

@escapemanuele
Copy link
Contributor

We're so close with the flow, great!

If I add someone, the team members list gets refreshed, but not the pending invite one. I see that there is 1 pending invite, but they are not showed until I refresh

image

image

@renancarvalho renancarvalho added this to In progress in Vertex Team Board via automation Mar 12, 2024
{ email_or_username: email as string, role: userRoles },
] ) ) as [ sendInvitesResponse ];

const success = response && response[ 0 ].success;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can add safety checks here?
Also we need to manage errors, and maybe log the invite error event. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure! It is coming in the next commit. :)

Addressed 👍

@renancarvalho renancarvalho changed the title SSO: Add invite user button option — Draft SSO: Add invite user button option Mar 13, 2024
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 13, 2024
deletingInvite,
} ) => {
const translate = useTranslate();
const { isPending } = invite;

if ( invite && inviteWasDeleted ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @agrullon95 To keep the pending list up to date, I had to remove this logic added by you in #86927. Could you please help me to test and make sure it is still working well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't recall why I added that there, but I didn't notice any issues with invitations/revokes when testing.

requestingResend,
resendSuccess,
inviteWasDeleted,
deletingInvite,
} = this.props;

if ( ! site || ! site.ID || deleteSuccess ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@agrullon95 same here

@renancarvalho renancarvalho marked this pull request as ready for review March 13, 2024 14:09
@renancarvalho renancarvalho moved this from In progress to Needs review in Vertex Team Board Mar 13, 2024
)
);
}
const success = response && response[ 0 ]?.success;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work if we do

const success = response?.[0]?.success; 

?

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, wouldn't it be the same? Personally, I read better like it is now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Your call 👍

const siteId = site?.ID as number;

const pendingInvites = useSelector( ( state ) => getPendingInvitesForSite( state, siteId ) );
const pendingInvitesMails = pendingInvites?.map( ( invite ) => invite.user?.email );
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets rename to pendingInvitesEmails

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks

@agrullon95 agrullon95 self-requested a review March 13, 2024 16:15
Copy link
Contributor

@agrullon95 agrullon95 left a comment

Choose a reason for hiding this comment

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

Tested inviting a new user via Calypso and accepting the invitation.
Also tested inviting a new user via Calypso, creating the same user via /wp-admin and accepting the invite.

@escapemanuele escapemanuele removed this from Needs review in Vertex Team Board Mar 13, 2024
@escapemanuele
Copy link
Contributor

Cool, let's fix the unit test and then this should be good to go 👍

@@ -150,11 +150,6 @@ describe( 'PeopleInviteDetails', () => {
expect( mockGoBack ).toHaveBeenCalledTimes( 1 );
expect( mockGoBack ).toHaveBeenCalledWith( '/people/invites/' + siteObject.slug );

// Verify that a placeholder is rendered while waiting for `page.back`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we are refreshing the list again after revoking or inviting, we don't need this placeholder anymore.
The Placeholder was causing issues when revoking and inviting again the same user.

@renancarvalho renancarvalho merged commit 157f8df into trunk Mar 14, 2024
11 checks passed
Hosting Friendly User Management automation moved this from Needs Review to Done Mar 14, 2024
@renancarvalho renancarvalho deleted the add/sso-send-invite branch March 14, 2024 11:52
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 14, 2024
@a8ci18n
Copy link

a8ci18n commented Mar 14, 2024

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/11603794

Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday.

Thank you @renancarvalho for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Mar 18, 2024

Translation for this Pull Request has now been finished.

billrobbins pushed a commit that referenced this pull request Mar 20, 2024
* Add invite button option

* Fix type

* Remove unnecessary comment

* Add notice and style

* Use LocalizeUrl

* Fix small viewport message style

* Fix pending invites not being shown sometimes

* Add error handling

* Use correct icon

* Rename variable

* Remove unnecessary test expectation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

6 participants