Merge pull request #28126 from overleaf/ii-domain-capture-join-success-message

[web] Notification message for joining group via domain capture

GitOrigin-RevId: 67ef924b2d80afb5e1de75fb6aab147263c0f33c
This commit is contained in:
ilkin-overleaf
2025-09-09 16:09:31 +03:00
committed by Copybot
parent 1e5346d996
commit 96d9ca2d37
8 changed files with 65 additions and 4 deletions

View File

@@ -285,6 +285,8 @@ async function projectListPage(req, res, next) {
const notificationsInstitution = []
// Institution and group SSO Notifications
let groupSsoSetupSuccess
let viaDomainCapture
let joinedGroupName = ''
let reconfirmedViaSAML
if (Features.hasFeature('saml')) {
reconfirmedViaSAML = _.get(req.session, ['saml', 'reconfirmed'])
@@ -324,6 +326,8 @@ async function projectListPage(req, res, next) {
// Notification group SSO: After SSO Linked
if (samlSession.linkedGroup) {
groupSsoSetupSuccess = true
viaDomainCapture = samlSession.domainCaptureJoin
joinedGroupName = samlSession.universityName
}
// Notification institution SSO: After SSO Linked or Logging in
@@ -517,6 +521,8 @@ async function projectListPage(req, res, next) {
showBrlGeoBanner,
projectDashboardReact: true, // used in navbar
groupSsoSetupSuccess,
joinedGroupName,
viaDomainCapture,
groupSubscriptionsPendingEnrollment:
groupSubscriptionsPendingEnrollment.map(subscription => ({
groupId: subscription._id,

View File

@@ -81,6 +81,8 @@ block append meta
data-type='boolean'
content=groupSsoSetupSuccess
)
meta(name='ol-joinedGroupName' data-type='string' content=joinedGroupName)
meta(name='ol-viaDomainCapture' data-type='boolean' content=viaDomainCapture)
meta(name='ol-showUSGovBanner' data-type='boolean' content=showUSGovBanner)
meta(
name='ol-usGovBannerVariant'

View File

@@ -1722,6 +1722,7 @@
"subscription_will_remain_active_until_end_of_billing_period_x": "",
"subscription_will_remain_active_until_end_of_trial_period_x": "",
"success_sso_set_up": "",
"success_youve_successfully_join_group": "",
"suggest_a_different_fix": "",
"suggest_fix": "",
"suggested": "",

View File

@@ -1,24 +1,46 @@
import { useTranslation } from 'react-i18next'
import { useTranslation, Trans } from 'react-i18next'
import Notification from '../../../../../shared/components/notification'
import getMeta from '../../../../../utils/meta'
function GroupSsoSetupSuccess() {
const { t } = useTranslation()
const wasSuccess = getMeta('ol-groupSsoSetupSuccess')
const joinedGroupName = getMeta('ol-joinedGroupName')
const viaDomainCapture = getMeta('ol-viaDomainCapture')
if (!wasSuccess) {
return null
}
return (
if (!viaDomainCapture) {
return (
<li className="notification-entry">
<Notification
type="success"
content={t('success_sso_set_up')}
isDismissible
/>
</li>
)
}
return joinedGroupName ? (
<li className="notification-entry">
<Notification
type="success"
content={t('success_sso_set_up')}
content={
<Trans
i18nKey="success_youve_successfully_join_group"
components={[<b />]} // eslint-disable-line react/jsx-key
values={{ groupName: joinedGroupName }}
shouldUnescape
tOptions={{ interpolation: { escapeValue: true } }}
/>
}
isDismissible
/>
</li>
)
) : null
}
export default GroupSsoSetupSuccess

View File

@@ -168,6 +168,7 @@ export interface Meta {
'ol-itm_campaign': string
'ol-itm_content': string
'ol-itm_referrer': string
'ol-joinedGroupName': string
'ol-labs': boolean
'ol-labsExperiments': ActiveExperiment[] | undefined
'ol-languages': SpellCheckLanguage[]
@@ -298,6 +299,7 @@ export interface Meta {
'ol-usersEmail': string | undefined
'ol-usersSubscription': { personal: boolean; group: boolean }
'ol-validationStatus': ValidationStatus
'ol-viaDomainCapture': boolean
'ol-wikiEnabled': boolean
'ol-writefullCssUrl': string
'ol-writefullEnabled': boolean

View File

@@ -2219,6 +2219,7 @@
"subscription_will_remain_active_until_end_of_billing_period_x": "Your subscription will remain active until the end of your billing period, <0>__terminationDate__</0>.",
"subscription_will_remain_active_until_end_of_trial_period_x": "Your subscription will remain active until the end of your trial period, <0>__terminationDate__</0>.",
"success_sso_set_up": "Success! Single sign-on is all set up for you.",
"success_youve_successfully_join_group": "Success! Youve joined the <0>__groupName__</0> group subscription. Your group has SSO enabled so you can log in without needing to remember a password.",
"suggest_a_different_fix": "Suggest a different fix",
"suggest_fix": "Suggest fix",
"suggested": "Suggested",

View File

@@ -1045,5 +1045,17 @@ describe('<UserNotifications />', function () {
screen.queryByText('Success! Single sign-on is all set up for you.')
).to.be.null
})
it('shows group SSO linked notification when joining via domain capture', function () {
const groupName = 'Group Name'
window.metaAttributesCache.set('ol-groupSsoSetupSuccess', true)
window.metaAttributesCache.set('ol-viaDomainCapture', true)
window.metaAttributesCache.set('ol-joinedGroupName', groupName)
renderWithinProjectListProvider(GroupSsoSetupSuccess)
const alert = screen.getByRole('alert')
expect(alert.textContent).to.contain(
`Success! Youve joined the ${groupName} group subscription. Your group has SSO enabled so you can log in without needing to remember a password.`
)
})
})
})

View File

@@ -569,6 +569,21 @@ describe('ProjectListController', function () {
}
ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
})
it('should show a linked group notification via domain capture', function (ctx) {
ctx.req.session.saml = {
linkedGroup: true,
universityName: ctx.institutionName,
domainCaptureJoin: true,
}
ctx.res.render = (pageName, opts) => {
expect(opts).to.deep.include({
groupSsoSetupSuccess: true,
joinedGroupName: ctx.institutionName,
viaDomainCapture: true,
})
}
ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
})
it('should show a linked another email notification', function (ctx) {
// when they request to link an email but the institution returns
// a different email