mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 06:39:01 +02:00
Implement groups & enterprise awareness banner on project dashboard (#10818)
- Implement the banner on both react and non-react project dashboard - Use split test with 4 different variants, `save`, `empower`, `did-you-know`, and `default`, each variant has a different copy, except the `default` which won't show the banner to users GitOrigin-RevId: ee76769dfd38b8e52de8cc0f201c24e41905d016
This commit is contained in:
@@ -20,6 +20,7 @@ const { User } = require('../../models/User')
|
||||
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
|
||||
const UserPrimaryEmailCheckHandler = require('../User/UserPrimaryEmailCheckHandler')
|
||||
const UserController = require('../User/UserController')
|
||||
const LimitationsManager = require('../Subscription/LimitationsManager')
|
||||
|
||||
/** @typedef {import("./types").GetProjectsRequest} GetProjectsRequest */
|
||||
/** @typedef {import("./types").GetProjectsResponse} GetProjectsResponse */
|
||||
@@ -287,6 +288,48 @@ async function projectListReactPage(req, res, next) {
|
||||
status: prefetchedProjectsBlob ? 'success' : 'too-slow',
|
||||
})
|
||||
|
||||
let showGroupsAndEnterpriseBanner = false
|
||||
let groupsAndEnterpriseBannerAssignment
|
||||
|
||||
try {
|
||||
groupsAndEnterpriseBannerAssignment =
|
||||
await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'groups-and-enterprise-banner'
|
||||
)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ err: error },
|
||||
'failed to get "groups-and-enterprise-banner" split test assignment'
|
||||
)
|
||||
}
|
||||
|
||||
let userIsMemberOfGroupSubscription = false
|
||||
|
||||
try {
|
||||
const userIsMemberOfGroupSubscriptionPromise =
|
||||
await LimitationsManager.promises.userIsMemberOfGroupSubscription(user)
|
||||
|
||||
userIsMemberOfGroupSubscription =
|
||||
userIsMemberOfGroupSubscriptionPromise.isMember
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{ err: error },
|
||||
'Failed to check whether user is a member of group subscription'
|
||||
)
|
||||
}
|
||||
|
||||
const hasPaidAffiliation = userAffiliations.some(
|
||||
affiliation => affiliation.licence && affiliation.licence !== 'free'
|
||||
)
|
||||
|
||||
showGroupsAndEnterpriseBanner =
|
||||
(groupsAndEnterpriseBannerAssignment?.variant ?? 'default') !== 'default' &&
|
||||
Features.hasFeature('saas') &&
|
||||
!userIsMemberOfGroupSubscription &&
|
||||
!hasPaidAffiliation
|
||||
|
||||
res.render('project/list-react', {
|
||||
title: 'your_projects',
|
||||
usersBestSubscription,
|
||||
@@ -301,6 +344,9 @@ async function projectListReactPage(req, res, next) {
|
||||
tags,
|
||||
portalTemplates,
|
||||
prefetchedProjectsBlob,
|
||||
showGroupsAndEnterpriseBanner,
|
||||
groupsAndEnterpriseBannerVariant:
|
||||
groupsAndEnterpriseBannerAssignment?.variant ?? 'default',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user