mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 15:15:34 +00:00
Merge pull request #22142 from overleaf/jdt-enable-wf-on-commons
[Web] Toggle on Writefull commons targeting GitOrigin-RevId: ede7f5397d1f110da006111ffcfd2eebb3626927
This commit is contained in:
parent
1f8a710f0d
commit
f6cbcc51d8
2 changed files with 23 additions and 1 deletions
|
@ -37,6 +37,7 @@ const FeaturesUpdater = require('../Subscription/FeaturesUpdater')
|
|||
const SpellingHandler = require('../Spelling/SpellingHandler')
|
||||
const { hasAdminAccess } = require('../Helpers/AdminAuthorizationHelper')
|
||||
const InstitutionsFeatures = require('../Institutions/InstitutionsFeatures')
|
||||
const InstitutionsGetter = require('../Institutions/InstitutionsGetter')
|
||||
const ProjectAuditLogHandler = require('./ProjectAuditLogHandler')
|
||||
const PublicAccessLevels = require('../Authorization/PublicAccessLevels')
|
||||
const TagsHandler = require('../Tags/TagsHandler')
|
||||
|
@ -383,6 +384,12 @@ const _ProjectController = {
|
|||
logger.error({ err, userId }, 'failed to get institution licence')
|
||||
return false
|
||||
}),
|
||||
affiliations: InstitutionsGetter.promises
|
||||
.getCurrentAffiliations(userId)
|
||||
.catch(err => {
|
||||
logger.error({ err, userId }, 'failed to get institution licence')
|
||||
return false
|
||||
}),
|
||||
subscription:
|
||||
SubscriptionLocator.promises.getUsersSubscription(userId),
|
||||
isTokenMember: CollaboratorsGetter.promises.userIsTokenMember(
|
||||
|
@ -653,6 +660,7 @@ const _ProjectController = {
|
|||
aiFeaturesAllowed = false
|
||||
}
|
||||
}
|
||||
|
||||
const canUseErrorAssistant =
|
||||
user.features?.aiErrorAssistant ||
|
||||
splitTestAssignments['ai-add-on']?.variant === 'enabled'
|
||||
|
@ -669,13 +677,21 @@ const _ProjectController = {
|
|||
})
|
||||
}
|
||||
|
||||
let inEnterpriseCommons = false
|
||||
const affiliations = userValues.affiliations || []
|
||||
for (const affiliation of affiliations) {
|
||||
inEnterpriseCommons =
|
||||
inEnterpriseCommons || affiliation.institution?.enterpriseCommons
|
||||
}
|
||||
|
||||
// check if a user has never tried writefull before (writefull.enabled will be null)
|
||||
// if they previously accepted writefull, or are have been already assigned to a trial, user.writefull will be true,
|
||||
// if they explicitly disabled it, user.writefull will be false
|
||||
if (
|
||||
aiFeaturesAllowed &&
|
||||
user.writefull?.enabled === null &&
|
||||
!userInNonIndividualSub
|
||||
!userIsMemberOfGroupSubscription &&
|
||||
!inEnterpriseCommons
|
||||
) {
|
||||
const { variant } = await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
|
|
|
@ -190,6 +190,11 @@ describe('ProjectController', function () {
|
|||
hasLicence: sinon.stub().resolves(false),
|
||||
},
|
||||
}
|
||||
this.InstitutionsGetter = {
|
||||
promises: {
|
||||
getCurrentAffiliations: sinon.stub().resolves([]),
|
||||
},
|
||||
}
|
||||
this.SubscriptionViewModelBuilder = {
|
||||
getBestSubscription: sinon.stub().yields(null, { type: 'free' }),
|
||||
}
|
||||
|
@ -256,6 +261,7 @@ describe('ProjectController', function () {
|
|||
},
|
||||
},
|
||||
'../Institutions/InstitutionsFeatures': this.InstitutionsFeatures,
|
||||
'../Institutions/InstitutionsGetter': this.InstitutionsGetter,
|
||||
'../Survey/SurveyHandler': this.SurveyHandler,
|
||||
'./ProjectAuditLogHandler': this.ProjectAuditLogHandler,
|
||||
'../Tutorial/TutorialHandler': this.TutorialHandler,
|
||||
|
|
Loading…
Add table
Reference in a new issue