Просмотр исходного кода

Merge pull request #27894 from overleaf/ii-domain-capture-join-button

[web] Domain capture join button

GitOrigin-RevId: aec6033f6776e9384c77fe0ef609c65b13a90f87
Jessica Lawshe 11 месяцев назад
Родитель
Сommit
2389674cca

+ 6 - 2
services/web/app/src/Features/Project/ProjectController.js

@@ -333,13 +333,17 @@ const _ProjectController = {
       if (domainCaptureRedirect === 'enabled') {
         const subscription = (
           await Modules.promises.hooks.fire(
-            'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf',
+            'findDomainCaptureGroupUserCouldBePartOf',
             userId
           )
         )?.[0]
 
         if (subscription) {
-          return res.redirect('/domain-capture')
+          if (subscription.managedUsersEnabled) {
+            return res.redirect('/domain-capture')
+          } else {
+            // TODO show notification or anything else
+          }
         }
       }
     }

+ 6 - 2
services/web/app/src/Features/Project/ProjectListController.mjs

@@ -124,13 +124,17 @@ async function projectListPage(req, res, next) {
     if (domainCaptureRedirect === 'enabled') {
       const subscription = (
         await Modules.promises.hooks.fire(
-          'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf',
+          'findDomainCaptureGroupUserCouldBePartOf',
           userId
         )
       )?.[0]
 
       if (subscription) {
-        return res.redirect('/domain-capture')
+        if (subscription.managedUsersEnabled) {
+          return res.redirect('/domain-capture')
+        } else {
+          // TODO show notification or anything else
+        }
       }
     }
   }

+ 1 - 0
services/web/frontend/js/utils/meta.ts

@@ -255,6 +255,7 @@ export interface Meta {
   'ol-splitTestVariants': { [name: string]: string }
   'ol-ssoDisabled': boolean
   'ol-ssoErrorMessage': string
+  'ol-ssoInitPath': string
   'ol-stripeAccountId': string
   'ol-stripeSubscriptionData': {
     customerId: string

+ 7 - 1
services/web/test/frontend/features/group-management/components/domain-capture.spec.tsx

@@ -4,6 +4,7 @@ describe('<DomainCapture />', function () {
   beforeEach(function () {
     this.email = 'user@example.com'
     this.groupName = 'test-group'
+    this.ssoInitPath = '/sso/init/path'
 
     cy.window().then(win => {
       win.metaAttributesCache.set('ol-user', {
@@ -13,6 +14,7 @@ describe('<DomainCapture />', function () {
       })
       win.metaAttributesCache.set('ol-email', this.email)
       win.metaAttributesCache.set('ol-groupName', this.groupName)
+      win.metaAttributesCache.set('ol-ssoInitPath', this.ssoInitPath)
     })
 
     cy.mount(<DomainCapture />)
@@ -51,7 +53,11 @@ describe('<DomainCapture />', function () {
         /get access to enterprise features and benefits provided by your organization/i
       )
       cy.findByText(/you’ll continue to have access to all of your projects/i)
-      cy.findByRole('button', { name: /join/i })
+      cy.findByRole('link', { name: /join/i }).should(
+        'have.attr',
+        'href',
+        this.ssoInitPath
+      )
     })
   })
 

+ 2 - 5
services/web/test/unit/src/Project/ProjectControllerTests.js

@@ -600,11 +600,8 @@ describe('ProjectController', function () {
         .withArgs(this.req, this.res, 'domain-capture-redirect')
         .resolves({ variant: 'enabled' })
       this.Modules.promises.hooks.fire
-        .withArgs(
-          'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf',
-          this.user._id
-        )
-        .resolves([{ _id: new ObjectId() }])
+        .withArgs('findDomainCaptureGroupUserCouldBePartOf', this.user._id)
+        .resolves([{ _id: new ObjectId(), managedUsersEnabled: true }])
       this.res.redirect = url => {
         url.should.equal('/domain-capture')
         done()

+ 2 - 5
services/web/test/unit/src/Project/ProjectListController.test.mjs

@@ -500,11 +500,8 @@ describe('ProjectListController', function () {
           .withArgs(ctx.req, ctx.res, 'domain-capture-redirect')
           .resolves({ variant: 'enabled' })
         ctx.Modules.promises.hooks.fire
-          .withArgs(
-            'findDomainCaptureAndManagedUsersGroupUserShouldBePartOf',
-            ctx.user._id
-          )
-          .resolves([{ _id: new ObjectId() }])
+          .withArgs('findDomainCaptureGroupUserCouldBePartOf', ctx.user._id)
+          .resolves([{ _id: new ObjectId(), managedUsersEnabled: true }])
         ctx.res.redirect = url => {
           url.should.equal('/domain-capture')
           resolve()