Merge pull request #23366 from overleaf/ii-flexible-licensing-add-seats-for-all-legacy-plans

[web] Add seats feature for smaller groups

GitOrigin-RevId: 7b0d1ea61eaaf603610d5fd8df399c00d328be70
This commit is contained in:
ilkin-overleaf
2025-02-05 09:05:32 +00:00
committed by Copybot
parent 098d91f0bb
commit 667b97664c
7 changed files with 641 additions and 260 deletions
@@ -42,7 +42,7 @@ for (const [usage, planData] of Object.entries(groups)) {
// Generate plans in settings
for (const size of sizes) {
let plan = {
const plan = {
planCode: `group_${planCode}_${size}_${usage}`,
name: `${
Settings.appName
@@ -55,18 +55,12 @@ for (const [usage, planData] of Object.entries(groups)) {
features: Settings.features[planCode],
groupPlan: true,
membersLimit: parseInt(size),
// Unlock flexible licensing for all plans
// Add the `membersLimitAddOn` to all group plans
membersLimitAddOn: 'additional-license',
// Unlock flexible licensing for all group plans
canUseFlexibleLicensing: true,
}
// Add the `membersLimitAddOn` only to group plans of 5 or greater size
if (size >= 5) {
plan = {
...plan,
membersLimitAddOn: 'additional-license',
}
}
Settings.plans.push(plan)
}
}
@@ -128,7 +128,6 @@ async function addSeatsToGroupSubscription(req, res) {
req
)
await SubscriptionGroupHandler.promises.ensureFlexibleLicensingEnabled(plan)
await SubscriptionGroupHandler.promises.ensureAddSeatsEnabled(plan)
res.render('subscriptions/add-seats', {
subscriptionId: subscription._id,
@@ -63,12 +63,6 @@ async function ensureFlexibleLicensingEnabled(plan) {
}
}
async function ensureAddSeatsEnabled(plan) {
if (!plan?.membersLimitAddOn) {
throw new Error('The group plan does not support adding seats')
}
}
async function getUsersGroupSubscriptionDetails(req) {
const userId = SessionManager.getLoggedInUserId(req.session)
const subscription =
@@ -96,7 +90,6 @@ async function _addSeatsSubscriptionChange(req) {
const { recurlySubscription, plan } =
await getUsersGroupSubscriptionDetails(req)
await ensureFlexibleLicensingEnabled(plan)
await ensureAddSeatsEnabled(plan)
const userId = SessionManager.getLoggedInUserId(req.session)
const currentAddonQuantity =
recurlySubscription.addOns.find(
@@ -121,7 +114,7 @@ async function _addSeatsSubscriptionChange(req) {
if (isLegacyPriceApplicable) {
const pattern =
/^group_(collaborator|professional)_(5|10|20|50)_(educational|enterprise)$/
/^group_(collaborator|professional)_(2|3|4|5|10|20|50)_(educational|enterprise)$/
const [, planCode, size, usage] = plan.planCode.match(pattern)
const currency = recurlySubscription.currency
const legacyPriceInCents =
@@ -255,7 +248,6 @@ module.exports = {
removeUserFromGroup: callbackify(removeUserFromGroup),
replaceUserReferencesInGroups: callbackify(replaceUserReferencesInGroups),
ensureFlexibleLicensingEnabled: callbackify(ensureFlexibleLicensingEnabled),
ensureAddSeatsEnabled: callbackify(ensureAddSeatsEnabled),
getTotalConfirmedUsersInGroup: callbackify(getTotalConfirmedUsersInGroup),
isUserPartOfGroup: callbackify(isUserPartOfGroup),
getGroupPlanUpgradePreview: callbackify(getGroupPlanUpgradePreview),
@@ -264,7 +256,6 @@ module.exports = {
removeUserFromGroup,
replaceUserReferencesInGroups,
ensureFlexibleLicensingEnabled,
ensureAddSeatsEnabled,
getTotalConfirmedUsersInGroup,
isUserPartOfGroup,
getUsersGroupSubscriptionDetails,
File diff suppressed because it is too large Load Diff