Ver Fonte

Merge pull request #15922 from overleaf/ab-hide-resend-managed-users-invite-pending-user

[web] Hide the Resend managed user invite for pending group members

GitOrigin-RevId: 2ba360c12982a515e7c5402d944ba9cbf16ddb2a
ilkin-overleaf há 2 anos atrás
pai
commit
6c1308e250

+ 2 - 2
services/web/frontend/js/features/group-management/components/members-table/dropdown-button.tsx

@@ -194,7 +194,7 @@ export default function DropdownButton({
       </MenuItemButton>
     )
   }
-  if (managedUsersActive && !isUserManaged) {
+  if (managedUsersActive && !isUserManaged && !userPending) {
     buttons.push(
       <MenuItemButton
         onClick={onResendManagedUserInviteClick}
@@ -208,7 +208,7 @@ export default function DropdownButton({
       </MenuItemButton>
     )
   }
-  if (groupSSOActive && !isGroupSSOLinked) {
+  if (groupSSOActive && !isGroupSSOLinked && !userPending) {
     buttons.push(
       <MenuItemButton
         onClick={onResendSSOLinkInviteClick}

+ 117 - 1
services/web/test/frontend/features/group-management/components/members-table/dropdown-button.spec.tsx

@@ -34,7 +34,7 @@ describe('DropdownButton', function () {
   const subscriptionId = '123abc123abc'
 
   describe('with a standard group', function () {
-    describe('for a pending user (have not joined group)', function () {
+    describe('for a pending user (has not joined group)', function () {
       const user: User = {
         _id: 'some-user',
         email: 'some.user@example.com',
@@ -66,6 +66,8 @@ describe('DropdownButton', function () {
         cy.findByTestId('resend-group-invite-action').should('be.visible')
         cy.findByTestId('remove-user-action').should('be.visible')
 
+        cy.findByTestId('resend-managed-user-invite-action').should('not.exist')
+        cy.findByTestId('resend-sso-link-invite-action').should('not.exist')
         cy.findByTestId('no-actions-available').should('not.exist')
       })
     })
@@ -114,6 +116,44 @@ describe('DropdownButton', function () {
       })
     })
 
+    describe('for a pending user (has not joined group)', function () {
+      const user: User = {
+        _id: 'some-user',
+        email: 'some.user@example.com',
+        first_name: 'Some',
+        last_name: 'User',
+        invite: true,
+        last_active_at: new Date(),
+        enrollment: {},
+        isEntityAdmin: undefined,
+      }
+
+      beforeEach(function () {
+        cy.window().then(win => {
+          win.metaAttributesCache.set('ol-users', [user])
+        })
+
+        mountDropDownComponent(user, subscriptionId)
+      })
+
+      it('should render dropdown button', function () {
+        cy.get('#managed-user-dropdown-some\\.user\\@example\\.com').should(
+          'exist'
+        )
+        cy.get(`.action-btn`).should('exist')
+      })
+
+      it('should show the correct menu when dropdown button is clicked', function () {
+        cy.get('.action-btn').click()
+        cy.findByTestId('resend-group-invite-action').should('be.visible')
+        cy.findByTestId('remove-user-action').should('be.visible')
+
+        cy.findByTestId('resend-managed-user-invite-action').should('not.exist')
+        cy.findByTestId('resend-sso-link-invite-action').should('not.exist')
+        cy.findByTestId('no-actions-available').should('not.exist')
+      })
+    })
+
     describe('for a managed group member', function () {
       const user: User = {
         _id: 'some-user',
@@ -240,6 +280,44 @@ describe('DropdownButton', function () {
       })
     })
 
+    describe('for a pending user (has not joined group)', function () {
+      const user: User = {
+        _id: 'some-user',
+        email: 'some.user@example.com',
+        first_name: 'Some',
+        last_name: 'User',
+        invite: true,
+        last_active_at: new Date(),
+        enrollment: {},
+        isEntityAdmin: undefined,
+      }
+
+      beforeEach(function () {
+        cy.window().then(win => {
+          win.metaAttributesCache.set('ol-users', [user])
+        })
+
+        mountDropDownComponent(user, subscriptionId)
+      })
+
+      it('should render dropdown button', function () {
+        cy.get('#managed-user-dropdown-some\\.user\\@example\\.com').should(
+          'exist'
+        )
+        cy.get(`.action-btn`).should('exist')
+      })
+
+      it('should show the correct menu when dropdown button is clicked', function () {
+        cy.get('.action-btn').click()
+        cy.findByTestId('resend-group-invite-action').should('be.visible')
+        cy.findByTestId('remove-user-action').should('be.visible')
+
+        cy.findByTestId('resend-managed-user-invite-action').should('not.exist')
+        cy.findByTestId('resend-sso-link-invite-action').should('not.exist')
+        cy.findByTestId('no-actions-available').should('not.exist')
+      })
+    })
+
     describe('for a group member not linked with SSO yet', function () {
       const user: User = {
         _id: 'some-user',
@@ -310,6 +388,44 @@ describe('DropdownButton', function () {
       })
     })
 
+    describe('for a pending user (has not joined group)', function () {
+      const user: User = {
+        _id: 'some-user',
+        email: 'some.user@example.com',
+        first_name: 'Some',
+        last_name: 'User',
+        invite: true,
+        last_active_at: new Date(),
+        enrollment: {},
+        isEntityAdmin: undefined,
+      }
+
+      beforeEach(function () {
+        cy.window().then(win => {
+          win.metaAttributesCache.set('ol-users', [user])
+        })
+
+        mountDropDownComponent(user, subscriptionId)
+      })
+
+      it('should render dropdown button', function () {
+        cy.get('#managed-user-dropdown-some\\.user\\@example\\.com').should(
+          'exist'
+        )
+        cy.get(`.action-btn`).should('exist')
+      })
+
+      it('should show the correct menu when dropdown button is clicked', function () {
+        cy.get('.action-btn').click()
+        cy.findByTestId('resend-group-invite-action').should('be.visible')
+        cy.findByTestId('remove-user-action').should('be.visible')
+
+        cy.findByTestId('resend-managed-user-invite-action').should('not.exist')
+        cy.findByTestId('resend-sso-link-invite-action').should('not.exist')
+        cy.findByTestId('no-actions-available').should('not.exist')
+      })
+    })
+
     describe('for a non-managed group member with SSO linked', function () {
       const user: User = {
         _id: 'some-user',