diff --git a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs index cad4f4a02e..feb6bbf03d 100644 --- a/services/web/app/src/Features/UserMembership/UserMembershipController.mjs +++ b/services/web/app/src/Features/UserMembership/UserMembershipController.mjs @@ -12,6 +12,7 @@ import { SSOConfig } from '../../models/SSOConfig.js' import { Parser as CSVParser } from 'json2csv' import { expressify } from '@overleaf/promise-utils' import SplitTestHandler from '../SplitTests/SplitTestHandler.js' +import PlansLocator from '../Subscription/PlansLocator.js' async function manageGroupMembers(req, res, next) { const { entity: subscription, entityConfig } = req @@ -36,6 +37,8 @@ async function manageGroupMembers(req, res, next) { 'flexible-group-licensing' ) + const plan = PlansLocator.findLocalPlanInSettings(subscription.planCode) + res.render('user_membership/group-members-react', { name: entityName, groupId: entityPrimaryKey, @@ -43,6 +46,7 @@ async function manageGroupMembers(req, res, next) { groupSize: subscription.membersLimit, managedUsersActive: subscription.managedUsersEnabled, groupSSOActive: ssoConfig?.enabled, + canUseFlexibleLicensing: plan?.canUseFlexibleLicensing, }) } 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 d76382161b..6642c47888 100644 --- a/services/web/app/views/user_membership/group-members-react.pug +++ b/services/web/app/views/user_membership/group-members-react.pug @@ -10,6 +10,7 @@ block append meta meta(name="ol-groupSize", data-type="json", content=groupSize) 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) 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 9db6742792..d164684ba9 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 @@ -24,13 +24,16 @@ export default function GroupMembers() { paths, } = useGroupMembersContext() const [emailString, setEmailString] = useState('') - const flexibleGroupLicensingEnabled = useFeatureFlag( + const isFlexibleGroupLicensingFeatureFlagEnabled = useFeatureFlag( 'flexible-group-licensing' ) const groupId = getMeta('ol-groupId') const groupName = getMeta('ol-groupName') const groupSize = getMeta('ol-groupSize') + const canUseFlexibleLicensing = getMeta('ol-canUseFlexibleLicensing') + const isFlexibleGroupLicensing = + canUseFlexibleLicensing && isFlexibleGroupLicensingFeatureFlagEnabled const handleEmailsChange = useCallback( e => { @@ -49,7 +52,7 @@ export default function GroupMembers() { } const groupSizeDetails = () => { - if (flexibleGroupLicensingEnabled) { + if (isFlexibleGroupLicensing) { return ( @@ -129,7 +132,7 @@ export default function GroupMembers() { data-testid="add-more-members-form" >

- {flexibleGroupLicensingEnabled + {isFlexibleGroupLicensing ? t('invite_more_members') : t('add_more_members')}

@@ -148,16 +151,14 @@ export default function GroupMembers() { {inviteMemberLoading ? ( ) : ( )} diff --git a/services/web/frontend/js/utils/meta.ts b/services/web/frontend/js/utils/meta.ts index 13a3a6fa54..3516969ece 100644 --- a/services/web/frontend/js/utils/meta.ts +++ b/services/web/frontend/js/utils/meta.ts @@ -61,6 +61,7 @@ export interface Meta { 'ol-brandVariation': Record // dynamic keys based on permissions + 'ol-canUseFlexibleLicensing': boolean 'ol-cannot-add-secondary-email': boolean 'ol-cannot-change-password': boolean 'ol-cannot-delete-own-account': 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 b01194654c..6cb09560e4 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 @@ -463,32 +463,40 @@ describe('GroupMembers', function () { }) describe('with flexible group licensing enabled', function () { - const JOHN_DOE = { - _id: 'abc123def456', - first_name: 'John', - last_name: 'Doe', - email: 'john.doe@test.com', - last_active_at: new Date('2023-01-15'), - invite: false, - } - const BOBBY_LAPOINTE = { - _id: 'bcd234efa567', - first_name: 'Bobby', - last_name: 'Lapointe', - email: 'bobby.lapointe@test.com', - last_active_at: new Date('2023-01-02'), - invite: false, - } - - it('renders the group members page with the new text', function () { + beforeEach(function () { + this.JOHN_DOE = { + _id: 'abc123def456', + first_name: 'John', + last_name: 'Doe', + email: 'john.doe@test.com', + last_active_at: new Date('2023-01-15'), + invite: false, + } + this.BOBBY_LAPOINTE = { + _id: 'bcd234efa567', + first_name: 'Bobby', + last_name: 'Lapointe', + email: 'bobby.lapointe@test.com', + last_active_at: new Date('2023-01-02'), + invite: false, + } cy.window().then(win => { win.metaAttributesCache.set('ol-groupId', GROUP_ID) win.metaAttributesCache.set('ol-groupName', 'My Awesome Team') win.metaAttributesCache.set('ol-groupSize', 10) - win.metaAttributesCache.set('ol-users', [JOHN_DOE, BOBBY_LAPOINTE]) win.metaAttributesCache.set('ol-splitTestVariants', { 'flexible-group-licensing': 'enabled', }) + win.metaAttributesCache.set('ol-canUseFlexibleLicensing', true) + }) + }) + + it('renders the group members page with the new text', function () { + cy.window().then(win => { + win.metaAttributesCache.set('ol-users', [ + this.JOHN_DOE, + this.BOBBY_LAPOINTE, + ]) }) cy.mount( @@ -510,13 +518,7 @@ describe('GroupMembers', function () { it('renders the group members page with new text when only has one group member', function () { cy.window().then(win => { - win.metaAttributesCache.set('ol-groupId', GROUP_ID) - win.metaAttributesCache.set('ol-groupName', 'My Awesome Team') - win.metaAttributesCache.set('ol-groupSize', 10) - win.metaAttributesCache.set('ol-users', [JOHN_DOE]) - win.metaAttributesCache.set('ol-splitTestVariants', { - 'flexible-group-licensing': 'enabled', - }) + win.metaAttributesCache.set('ol-users', [this.JOHN_DOE]) }) cy.mount(