mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
[web] Set layout-react
in Subscription pages (#21529)
* Update `User` type * Set `layout-react`: `subscriptions/successful-subscription-react` * Set `layout-react`: `subscriptions/canceled-subscription-react` * Set `layout-react`: `subscriptions/dashboard-react` * Set `layout-react`: `subscriptions/team/invite-managed`, `subscriptions/team/invite`, `subscriptions/team/invite_logged_out` * Set `layout-react`: `subscriptions/team/group-invites` * Add `header-footer-react` to subscription/base.js * Fix: Replace `date-type` by `data-type` * Fix SubscriptionControllerTests GitOrigin-RevId: b9049a9093a700b3be1bf33809e3a1494022350a
This commit is contained in:
parent
59a1cc2c7a
commit
5462fcd128
13 changed files with 55 additions and 20 deletions
|
@ -435,6 +435,7 @@ async function successfulSubscription(req, res) {
|
||||||
title: 'thank_you',
|
title: 'thank_you',
|
||||||
personalSubscription,
|
personalSubscription,
|
||||||
postCheckoutRedirect,
|
postCheckoutRedirect,
|
||||||
|
user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,6 +470,7 @@ async function canceledSubscription(req, res, next) {
|
||||||
)
|
)
|
||||||
return res.render('subscriptions/canceled-subscription-react', {
|
return res.render('subscriptions/canceled-subscription-react', {
|
||||||
title: 'subscription_canceled',
|
title: 'subscription_canceled',
|
||||||
|
user: SessionManager.getSessionUser(req.session),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,8 @@ async function createInvite(req, res, next) {
|
||||||
|
|
||||||
async function viewInvite(req, res, next) {
|
async function viewInvite(req, res, next) {
|
||||||
const { token } = req.params
|
const { token } = req.params
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const sessionUser = SessionManager.getSessionUser(req.session)
|
||||||
|
const userId = sessionUser?._id
|
||||||
const { invite, subscription } =
|
const { invite, subscription } =
|
||||||
await TeamInvitesHandler.promises.getInvite(token)
|
await TeamInvitesHandler.promises.getInvite(token)
|
||||||
|
|
||||||
|
@ -102,13 +102,13 @@ async function viewInvite(req, res, next) {
|
||||||
await subscription.populate('groupPolicy')
|
await subscription.populate('groupPolicy')
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await UserGetter.promises.getUser(userId)
|
const dbUser = await UserGetter.promises.getUser(userId)
|
||||||
|
|
||||||
const isUserEnrolledInDifferentGroup =
|
const isUserEnrolledInDifferentGroup =
|
||||||
(
|
(
|
||||||
await Modules.promises.hooks.fire(
|
await Modules.promises.hooks.fire(
|
||||||
'isUserEnrolledInDifferentGroup',
|
'isUserEnrolledInDifferentGroup',
|
||||||
user.enrollment,
|
dbUser.enrollment,
|
||||||
subscription._id
|
subscription._id
|
||||||
)
|
)
|
||||||
)?.[0] === true
|
)?.[0] === true
|
||||||
|
@ -122,7 +122,7 @@ async function viewInvite(req, res, next) {
|
||||||
|
|
||||||
validationStatus =
|
validationStatus =
|
||||||
await PermissionsManager.promises.getUserValidationStatus({
|
await PermissionsManager.promises.getUserValidationStatus({
|
||||||
user,
|
user: dbUser,
|
||||||
groupPolicy: subscription.groupPolicy,
|
groupPolicy: subscription.groupPolicy,
|
||||||
subscription,
|
subscription,
|
||||||
})
|
})
|
||||||
|
@ -143,6 +143,7 @@ async function viewInvite(req, res, next) {
|
||||||
currentManagedUserAdminEmail,
|
currentManagedUserAdminEmail,
|
||||||
groupSSOActive,
|
groupSSOActive,
|
||||||
subscriptionId: subscription._id.toString(),
|
subscriptionId: subscription._id.toString(),
|
||||||
|
user: sessionUser,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let currentManagedUserAdminEmail
|
let currentManagedUserAdminEmail
|
||||||
|
@ -162,6 +163,7 @@ async function viewInvite(req, res, next) {
|
||||||
currentManagedUserAdminEmail,
|
currentManagedUserAdminEmail,
|
||||||
groupSSOActive,
|
groupSSOActive,
|
||||||
subscriptionId: subscription._id.toString(),
|
subscriptionId: subscription._id.toString(),
|
||||||
|
user: sessionUser,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,18 +177,18 @@ async function viewInvite(req, res, next) {
|
||||||
appName: settings.appName,
|
appName: settings.appName,
|
||||||
accountExists: userByEmail != null,
|
accountExists: userByEmail != null,
|
||||||
emailAddress: invite.email,
|
emailAddress: invite.email,
|
||||||
|
user: { id: null },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function viewInvites(req, res, next) {
|
async function viewInvites(req, res, next) {
|
||||||
const userId = SessionManager.getLoggedInUserId(req.session)
|
const user = SessionManager.getSessionUser(req.session)
|
||||||
const userEmail = await UserGetter.promises.getUserEmail(userId)
|
|
||||||
const groupSubscriptions =
|
const groupSubscriptions =
|
||||||
await SubscriptionLocator.promises.getGroupsWithTeamInvitesEmail(userEmail)
|
await SubscriptionLocator.promises.getGroupsWithTeamInvitesEmail(user.email)
|
||||||
|
|
||||||
const teamInvites = groupSubscriptions.map(groupSubscription =>
|
const teamInvites = groupSubscriptions.map(groupSubscription =>
|
||||||
groupSubscription.teamInvites.find(invite => invite.email === userEmail)
|
groupSubscription.teamInvites.find(invite => invite.email === user.email)
|
||||||
)
|
)
|
||||||
|
|
||||||
await SplitTestHandler.promises.getAssignment(
|
await SplitTestHandler.promises.getAssignment(
|
||||||
|
@ -197,6 +199,7 @@ async function viewInvites(req, res, next) {
|
||||||
|
|
||||||
return res.render('subscriptions/team/group-invites', {
|
return res.render('subscriptions/team/group-invites', {
|
||||||
teamInvites,
|
teamInvites,
|
||||||
|
user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../layout-marketing
|
extends ../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
|
@ -7,5 +7,8 @@ block vars
|
||||||
block entrypointVar
|
block entrypointVar
|
||||||
- entrypoint = 'pages/user/subscription/canceled-subscription'
|
- entrypoint = 'pages/user/subscription/canceled-subscription'
|
||||||
|
|
||||||
|
block append meta
|
||||||
|
meta(name="ol-user" data-type="json" content=user)
|
||||||
|
|
||||||
block content
|
block content
|
||||||
main.content.content-alt#subscription-canceled-root
|
main.content.content-alt#subscription-canceled-root
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../layout-marketing
|
extends ../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../layout-marketing
|
extends ../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
|
@ -10,6 +10,7 @@ block entrypointVar
|
||||||
block append meta
|
block append meta
|
||||||
meta(name="ol-subscription" data-type="json" content=personalSubscription)
|
meta(name="ol-subscription" data-type="json" content=personalSubscription)
|
||||||
meta(name="ol-postCheckoutRedirect" content=postCheckoutRedirect)
|
meta(name="ol-postCheckoutRedirect" content=postCheckoutRedirect)
|
||||||
|
meta(name="ol-user" data-type="json" content=user)
|
||||||
|
|
||||||
block content
|
block content
|
||||||
main.content.content-alt#subscription-success-root
|
main.content.content-alt#subscription-success-root
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../../layout-marketing
|
extends ../../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
|
@ -9,6 +9,7 @@ block entrypointVar
|
||||||
|
|
||||||
block append meta
|
block append meta
|
||||||
meta(name="ol-teamInvites" data-type="json" content=teamInvites)
|
meta(name="ol-teamInvites" data-type="json" content=teamInvites)
|
||||||
|
meta(name="ol-user" data-type="json" content=user)
|
||||||
|
|
||||||
block content
|
block content
|
||||||
main.content.content-alt.team-invite#group-invites-root
|
main.content.content-alt.team-invite#group-invites-root
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../../layout-marketing
|
extends ../../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
|
@ -16,6 +16,7 @@ block append meta
|
||||||
meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)
|
meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)
|
||||||
meta(name="ol-groupSSOActive" data-type="boolean" content=groupSSOActive)
|
meta(name="ol-groupSSOActive" data-type="boolean" content=groupSSOActive)
|
||||||
meta(name="ol-subscriptionId" data-type="string" content=subscriptionId)
|
meta(name="ol-subscriptionId" data-type="string" content=subscriptionId)
|
||||||
|
meta(name="ol-user" data-type="json" content=user)
|
||||||
|
|
||||||
block content
|
block content
|
||||||
main.content.content-alt.team-invite#invite-managed-root
|
main.content.content-alt.team-invite#invite-managed-root
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../../layout-marketing
|
extends ../../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
|
@ -9,12 +9,13 @@ block entrypointVar
|
||||||
|
|
||||||
block append meta
|
block append meta
|
||||||
meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
|
meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
|
||||||
meta(name="ol-inviterName" date-type="string" content=inviterName)
|
meta(name="ol-inviterName" data-type="string" content=inviterName)
|
||||||
meta(name="ol-inviteToken" data-type="string" content=inviteToken)
|
meta(name="ol-inviteToken" data-type="string" content=inviteToken)
|
||||||
meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)
|
meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)
|
||||||
meta(name="ol-expired" data-type="boolean" content=expired)
|
meta(name="ol-expired" data-type="boolean" content=expired)
|
||||||
meta(name="ol-groupSSOActive" data-type="boolean" content=groupSSOActive)
|
meta(name="ol-groupSSOActive" data-type="boolean" content=groupSSOActive)
|
||||||
meta(name="ol-subscriptionId" data-type="string" content=subscriptionId)
|
meta(name="ol-subscriptionId" data-type="string" content=subscriptionId)
|
||||||
|
meta(name="ol-user" data-type="json" content=user)
|
||||||
|
|
||||||
block content
|
block content
|
||||||
main.content.content-alt#invite-root
|
main.content.content-alt#invite-root
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
extends ../../layout-marketing
|
extends ../../layout-react
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
- bootstrap5PageStatus = 'enabled' // One of 'disabled', 'enabled', and 'queryStringOnly'
|
||||||
- bootstrap5PageSplitTest = 'bootstrap-5-subscription'
|
- bootstrap5PageSplitTest = 'bootstrap-5-subscription'
|
||||||
|
|
||||||
|
block append meta
|
||||||
|
meta(name="ol-user" data-type="json" content=user)
|
||||||
|
|
||||||
block content
|
block content
|
||||||
- var colClass = bootstrapVersion === 5 ? 'col-lg-8 m-auto' : 'col-md-8 col-md-offset-2'
|
- var colClass = bootstrapVersion === 5 ? 'col-lg-8 m-auto' : 'col-md-8 col-md-offset-2'
|
||||||
|
|
||||||
|
|
|
@ -5,3 +5,4 @@ import './../../../i18n'
|
||||||
import '../../../features/event-tracking'
|
import '../../../features/event-tracking'
|
||||||
import '../../../features/cookie-banner'
|
import '../../../features/cookie-banner'
|
||||||
import '../../../features/link-helpers/slow-link'
|
import '../../../features/link-helpers/slow-link'
|
||||||
|
import '../../../features/header-footer-react'
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { createContext, FC, useContext, useMemo } from 'react'
|
import { createContext, FC, useContext, useMemo } from 'react'
|
||||||
import getMeta from '../../utils/meta'
|
import getMeta from '../../utils/meta'
|
||||||
import { User } from '../../../../types/user'
|
import { LoggedOutUser, User } from '../../../../types/user'
|
||||||
|
|
||||||
export const UserContext = createContext<User | undefined>(undefined)
|
export const UserContext = createContext<User | LoggedOutUser | undefined>(
|
||||||
|
undefined
|
||||||
|
)
|
||||||
|
|
||||||
export const UserProvider: FC = ({ children }) => {
|
export const UserProvider: FC = ({ children }) => {
|
||||||
const user = useMemo(() => getMeta('ol-user'), [])
|
const user = useMemo(() => getMeta('ol-user'), [])
|
||||||
|
|
|
@ -1017,6 +1017,7 @@ describe('SubscriptionController', function () {
|
||||||
title: 'thank_you',
|
title: 'thank_you',
|
||||||
personalSubscription: 'foo',
|
personalSubscription: 'foo',
|
||||||
postCheckoutRedirect: undefined,
|
postCheckoutRedirect: undefined,
|
||||||
|
user: this.user,
|
||||||
})
|
})
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ export type FeatureUsage = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type User = {
|
export type User = {
|
||||||
id: UserId | null
|
id: UserId
|
||||||
isAdmin?: boolean
|
isAdmin?: boolean
|
||||||
email: string
|
email: string
|
||||||
allowedFreeTrial?: boolean
|
allowedFreeTrial?: boolean
|
||||||
|
@ -54,4 +54,20 @@ export type User = {
|
||||||
featureUsage?: FeatureUsage
|
featureUsage?: FeatureUsage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type LoggedOutUser = {
|
||||||
|
id: null
|
||||||
|
email?: undefined
|
||||||
|
first_name?: undefined
|
||||||
|
last_name?: undefined
|
||||||
|
signUpDate?: undefined
|
||||||
|
labsProgram?: undefined
|
||||||
|
alphaProgram?: undefined
|
||||||
|
betaProgram?: undefined
|
||||||
|
allowedFreeTrial?: undefined
|
||||||
|
features?: undefined
|
||||||
|
refProviders?: undefined
|
||||||
|
writefull?: undefined
|
||||||
|
isAdmin?: undefined
|
||||||
|
}
|
||||||
|
|
||||||
export type MongoUser = Pick<User, Exclude<keyof User, 'id'>> & { _id: string }
|
export type MongoUser = Pick<User, Exclude<keyof User, 'id'>> & { _id: string }
|
||||||
|
|
Loading…
Reference in a new issue