diff --git a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs index feb6bbf03d..8b8ac86e51 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs +++ b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs @@ -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, }) } diff --git a/services/web/app/views/user_membership/group-members-react.pug b/services/web/app/views/user_membership/group-members-react.pug index 6642c47888..b38c118ba7 100644 --- a/services/web/app/views/user_membership/group-members-react.pug +++ b/services/web/app/views/user_membership/group-members-react.pug @@ -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 diff --git a/services/web/frontend/js/features/group-management/components/group-members.tsx b/services/web/frontend/js/features/group-management/components/group-members.tsx index d164684ba9..88f467209a 100644 --- a/services/web/frontend/js/features/group-management/components/group-members.tsx +++ b/services/web/frontend/js/features/group-management/components/group-members.tsx @@ -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, })} - {' '} - - {t('add_more_users')}. - + + {canUseAddSeatsFeature && ( + <> + {' '} + + {t('add_more_users')}. + + + )} ) } diff --git a/services/web/frontend/js/utils/meta.ts b/services/web/frontend/js/utils/meta.ts index 27adcbb39e..8b63bbbe1f 100644 --- a/services/web/frontend/js/utils/meta.ts +++ b/services/web/frontend/js/utils/meta.ts @@ -62,6 +62,7 @@ export interface Meta { 'ol-brandVariation': Record // dynamic keys based on permissions + 'ol-canUseAddSeatsFeature': boolean 'ol-canUseFlexibleLicensing': boolean 'ol-canUseFlexibleLicensingForConsolidatedPlans': boolean 'ol-cannot-add-secondary-email': boolean diff --git a/services/web/test/frontend/features/group-management/components/group-members.spec.tsx b/services/web/test/frontend/features/group-management/components/group-members.spec.tsx index 6cb09560e4..1a31e342ad 100644 --- a/services/web/test/frontend/features/group-management/components/group-members.spec.tsx +++ b/services/web/test/frontend/features/group-management/components/group-members.spec.tsx @@ -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( + + + + + + ) + + 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') + }) + }) }) }) diff --git a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.mjs b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.mjs index 5898735ee8..7363e9309d 100644 --- a/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.mjs +++ b/services/web/test/unit/src/UserMembership/UserMembershipControllerTests.mjs @@ -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 = {