mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #35065 from overleaf/jel-cleanup-domain-captured-by-group
[web] Remove `domain-captured-by-group` rollout flag for user settings GitOrigin-RevId: f7fe0e66649e4cd4b94124f8f2eefa150758203a
This commit is contained in:
@@ -123,11 +123,7 @@ async function settingsPage(req, res) {
|
||||
}
|
||||
|
||||
await SplitTestHandler.promises.getAssignment(req, res, 'email-notifications')
|
||||
await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'domain-captured-by-group'
|
||||
)
|
||||
|
||||
res.render('user/settings', {
|
||||
title: 'account_settings',
|
||||
user: {
|
||||
|
||||
@@ -22,16 +22,12 @@ import { ConfirmEmailForm } from '@/features/settings/components/emails/confirm-
|
||||
import RecaptchaConditions from '@/shared/components/recaptcha-conditions'
|
||||
import SsoLinkingInfoGroup from './add-email/sso-linking-info-group'
|
||||
import Notification from '@/shared/components/notification'
|
||||
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
||||
|
||||
function isDomainCapturedByGroup(
|
||||
domainInfo: DomainInfo,
|
||||
domainCapturedByGroupRolloutFlagEnabled: boolean
|
||||
): boolean {
|
||||
return domainCapturedByGroupRolloutFlagEnabled
|
||||
? (domainInfo.capturedByGroup && domainInfo.group?.domainCaptureEnabled) ||
|
||||
false
|
||||
: domainInfo.group?.domainCaptureEnabled || false
|
||||
function isDomainCapturedByGroup(domainInfo: DomainInfo): boolean {
|
||||
return (
|
||||
(domainInfo.capturedByGroup && domainInfo.group?.domainCaptureEnabled) ||
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
function AddEmail() {
|
||||
@@ -60,10 +56,6 @@ function AddEmail() {
|
||||
const emailAddressLimit = getMeta('ol-emailAddressLimit') || 10
|
||||
const { ref: recaptchaRef, getReCaptchaToken } = useRecaptcha()
|
||||
|
||||
const domainCapturedByGroupRolloutFlagEnabled = useFeatureFlag(
|
||||
'domain-captured-by-group'
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
setUserEmailsContextLoading(isLoading)
|
||||
}, [setUserEmailsContextLoading, isLoading])
|
||||
@@ -212,10 +204,7 @@ function AddEmail() {
|
||||
}
|
||||
|
||||
const isDomainCaptured = newEmailMatchedDomain
|
||||
? isDomainCapturedByGroup(
|
||||
newEmailMatchedDomain,
|
||||
domainCapturedByGroupRolloutFlagEnabled
|
||||
)
|
||||
? isDomainCapturedByGroup(newEmailMatchedDomain)
|
||||
: false
|
||||
const isSsoAvailableForDomain =
|
||||
newEmailMatchedDomain &&
|
||||
|
||||
@@ -8,7 +8,6 @@ import Actions from './actions'
|
||||
import { institutionAlreadyLinked } from '../../utils/selectors'
|
||||
import { useUserEmailsContext } from '../../context/user-email-context'
|
||||
import getMeta from '../../../../utils/meta'
|
||||
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
||||
import { ssoAvailableForInstitution } from '../../utils/sso'
|
||||
import ReconfirmationInfo from './reconfirmation-info'
|
||||
import { useLocation } from '../../../../shared/hooks/use-location'
|
||||
@@ -72,10 +71,6 @@ function SSOAffiliationInfo({ userEmailData }: SSOAffiliationInfoProps) {
|
||||
const [linkAccountsButtonDisabled, setLinkAccountsButtonDisabled] =
|
||||
useState(false)
|
||||
|
||||
const domainCapturedByGroupRolloutFlagEnabled = useFeatureFlag(
|
||||
'domain-captured-by-group'
|
||||
)
|
||||
|
||||
function handleLinkAccountsButtonClick() {
|
||||
setLinkAccountsButtonDisabled(true)
|
||||
location.assign(
|
||||
@@ -145,10 +140,8 @@ function SSOAffiliationInfo({ userEmailData }: SSOAffiliationInfoProps) {
|
||||
}
|
||||
|
||||
const domainAlsoForGroupWithDomainCapture =
|
||||
domainCapturedByGroupRolloutFlagEnabled
|
||||
? userEmailData?.affiliation?.domainCapturedByGroup &&
|
||||
userEmailData?.affiliation?.group?.domainCaptureEnabled
|
||||
: userEmailData?.affiliation?.group?.domainCaptureEnabled
|
||||
userEmailData?.affiliation?.domainCapturedByGroup &&
|
||||
userEmailData?.affiliation?.group?.domainCaptureEnabled
|
||||
|
||||
if (domainAlsoForGroupWithDomainCapture) {
|
||||
// user is not linked via Commons and should link via groups
|
||||
|
||||
@@ -150,6 +150,7 @@ describe('<EmailsRow/>', function () {
|
||||
})
|
||||
|
||||
it('does not prompt the user to link to their institutional account', function () {
|
||||
affiliatedEmailWithDomainCaptureAndCommons.affiliation.domainCapturedByGroup = true
|
||||
renderEmailsRow(affiliatedEmailWithDomainCaptureAndCommons)
|
||||
expect(() =>
|
||||
getByTextContent(
|
||||
@@ -170,16 +171,13 @@ describe('<EmailsRow/>', function () {
|
||||
.null
|
||||
})
|
||||
|
||||
it('uses `domainCapturedByGroup` when the feature flag is enabled', function () {
|
||||
it('uses `domainCapturedByGroup`', function () {
|
||||
affiliatedEmailWithDomainCaptureAndCommons.affiliation.group = {
|
||||
_id: 'grou123',
|
||||
domainCaptureEnabled: true,
|
||||
managedUsersEnabled: true,
|
||||
}
|
||||
affiliatedEmailWithDomainCaptureAndCommons.affiliation.domainCapturedByGroup = true
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'domain-captured-by-group': 'enabled',
|
||||
})
|
||||
|
||||
renderEmailsRow(affiliatedEmailWithDomainCaptureAndCommons)
|
||||
|
||||
@@ -187,17 +185,16 @@ describe('<EmailsRow/>', function () {
|
||||
.null
|
||||
})
|
||||
|
||||
it('ignores group domain capture when the feature flag is enabled and the domain is not captured', function () {
|
||||
it('still prompts to link Commons SSO when domainCaptureEnabled but domain not captured by group', function () {
|
||||
affiliatedEmailWithDomainCaptureAndCommons.affiliation.group = {
|
||||
_id: 'grou123',
|
||||
domainCaptureEnabled: true,
|
||||
managedUsersEnabled: true,
|
||||
}
|
||||
affiliatedEmailWithDomainCaptureAndCommons.affiliation.domainCapturedByGroup = false
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'domain-captured-by-group': 'enabled',
|
||||
})
|
||||
|
||||
renderEmailsRow(affiliatedEmailWithDomainCaptureAndCommons)
|
||||
|
||||
getByTextContent(
|
||||
'You can now link your Overleaf account to your Overleaf institutional account.'
|
||||
)
|
||||
screen.getByRole('button', { name: 'Link accounts' })
|
||||
})
|
||||
})
|
||||
|
||||
+4
-11
@@ -768,6 +768,7 @@ describe('<EmailsSection />', function () {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
capturedByGroup: true,
|
||||
}
|
||||
|
||||
fetchMock.get('express:/institutions/domains', [institution])
|
||||
@@ -811,6 +812,7 @@ describe('<EmailsSection />', function () {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
capturedByGroup: true,
|
||||
}
|
||||
|
||||
fetchMock.get('express:/institutions/domains', [institution])
|
||||
@@ -903,6 +905,7 @@ describe('<EmailsSection />', function () {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
capturedByGroup: true,
|
||||
}
|
||||
|
||||
fetchMock.get('express:/institutions/domains', [institution])
|
||||
@@ -936,17 +939,7 @@ describe('<EmailsSection />', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the domain-captured-by-group feature flag is enabled', function () {
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'domain-captured-by-group': 'enabled',
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {})
|
||||
})
|
||||
|
||||
describe('domain capturedByGroup', function () {
|
||||
describe('and capturedByGroup is true with managedUsersEnabled', function () {
|
||||
beforeEach(async function () {
|
||||
await fetchMock.callHistory.flush(true)
|
||||
|
||||
Reference in New Issue
Block a user