Merge pull request #23435 from overleaf/ii-flexible-group-licensing-add-seats-links

[web] Add seats links handling

GitOrigin-RevId: d53264277c24ec64b6ff7744b4d7e10a4234ac86
This commit is contained in:
Liangjun Song
2025-02-06 12:29:12 +00:00
committed by Copybot
parent 4bba1437a0
commit 68f9e7bbf8
6 changed files with 41 additions and 7 deletions

View File

@@ -38,6 +38,9 @@ async function manageGroupMembers(req, res, next) {
)
const plan = PlansLocator.findLocalPlanInSettings(subscription.planCode)
const userId = SessionManager.getLoggedInUserId(req.session)
const isAdmin = subscription.admin_id.toString() === userId
const canUseAddSeatsFeature = plan?.canUseFlexibleLicensing && isAdmin
res.render('user_membership/group-members-react', {
name: entityName,
@@ -47,6 +50,7 @@ async function manageGroupMembers(req, res, next) {
managedUsersActive: subscription.managedUsersEnabled,
groupSSOActive: ssoConfig?.enabled,
canUseFlexibleLicensing: plan?.canUseFlexibleLicensing,
canUseAddSeatsFeature,
})
}

View File

@@ -11,6 +11,7 @@ block append meta
meta(name="ol-managedUsersActive", data-type="boolean", content=managedUsersActive)
meta(name="ol-groupSSOActive", data-type="boolean", content=groupSSOActive)
meta(name="ol-canUseFlexibleLicensing", data-type="boolean", content=canUseFlexibleLicensing)
meta(name="ol-canUseAddSeatsFeature", data-type="boolean", content=canUseAddSeatsFeature)
block content
main.content.content-alt#subscription-manage-group-root

View File

@@ -32,6 +32,7 @@ export default function GroupMembers() {
const groupName = getMeta('ol-groupName')
const groupSize = getMeta('ol-groupSize')
const canUseFlexibleLicensing = getMeta('ol-canUseFlexibleLicensing')
const canUseAddSeatsFeature = getMeta('ol-canUseAddSeatsFeature')
const isFlexibleGroupLicensing =
canUseFlexibleLicensing && isFlexibleGroupLicensingFeatureFlagEnabled
@@ -64,13 +65,18 @@ export default function GroupMembers() {
addedUsersSize: users.length,
groupSize,
})}
</strong>{' '}
<a
href="/user/subscription/group/add-users"
rel="noreferrer noopener"
>
{t('add_more_users')}.
</a>
</strong>
{canUseAddSeatsFeature && (
<>
{' '}
<a
href="/user/subscription/group/add-users"
rel="noreferrer noopener"
>
{t('add_more_users')}.
</a>
</>
)}
</small>
)
}

View File

@@ -62,6 +62,7 @@ export interface Meta {
'ol-brandVariation': Record<string, any>
// dynamic keys based on permissions
'ol-canUseAddSeatsFeature': boolean
'ol-canUseFlexibleLicensing': boolean
'ol-canUseFlexibleLicensingForConsolidatedPlans': boolean
'ol-cannot-add-secondary-email': boolean

View File

@@ -488,6 +488,7 @@ describe('GroupMembers', function () {
'flexible-group-licensing': 'enabled',
})
win.metaAttributesCache.set('ol-canUseFlexibleLicensing', true)
win.metaAttributesCache.set('ol-canUseAddSeatsFeature', true)
})
})
@@ -533,5 +534,25 @@ describe('GroupMembers', function () {
'You have 1 user and your plan supports up to 10. Add more users.'
)
})
it('renders the group members page without "add more users" link when not admin', function () {
cy.window().then(win => {
win.metaAttributesCache.set('ol-users', [this.JOHN_DOE])
win.metaAttributesCache.set('ol-canUseAddSeatsFeature', false)
})
cy.mount(
<SplitTestProvider>
<GroupMembersProvider>
<GroupMembers />
</GroupMembersProvider>
</SplitTestProvider>
)
cy.findByTestId('group-size-details').within(() => {
cy.findByText(/you have \d+ user and your plan supports up to \d+/i)
cy.findByText(/add more users/i).should('not.exist')
})
})
})
})

View File

@@ -23,6 +23,7 @@ describe('UserMembershipController', function () {
this.newUser = { _id: 'mock-new-user-id', email: 'new-user-email@foo.bar' }
this.subscription = {
_id: 'mock-subscription-id',
admin_id: 'mock-admin-id',
fetchV1Data: callback => callback(null, this.subscription),
}
this.institution = {