From d7863bec37290d924b78f0451a9f62701d698da6 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Thu, 27 Jun 2024 08:46:20 -0400 Subject: [PATCH] Merge pull request #19108 from overleaf/jdt-ai-rm-alpha-reqs Remove Alpha bypass for AI Error Correction GitOrigin-RevId: d6b93bc2071dbeeb3d67d48197e61abf4d920944 --- .../app/src/Features/Project/ProjectController.js | 13 ++++++++++++- services/web/app/src/router.js | 1 + .../settings/components/labs-program-section.tsx | 7 +------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index ac8d5563cb..4682372fb5 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -42,6 +42,8 @@ const PublicAccessLevels = require('../Authorization/PublicAccessLevels') const TagsHandler = require('../Tags/TagsHandler') const TutorialHandler = require('../Tutorial/TutorialHandler') const UserUpdater = require('../User/UserUpdater') +const { checkUserPermissions } = + require('../Authorization/PermissionsManager').promises /** * @typedef {import("./types").GetProjectsRequest} GetProjectsRequest @@ -596,10 +598,19 @@ const _ProjectController = { !showPersonalAccessToken && splitTestAssignments['personal-access-token'].variant === 'enabled' // `?personal-access-token=enabled` + let canUseAi + try { + await checkUserPermissions(user, ['use-ai']) + canUseAi = true + } catch (err) { + canUseAi = false + } + const showAiErrorAssistant = userId && Features.hasFeature('saas') && - (user.features?.aiErrorAssistant || user.alphaProgram) && + user.features?.aiErrorAssistant && + canUseAi && (privilegeLevel === PrivilegeLevels.READ_AND_WRITE || privilegeLevel === PrivilegeLevels.OWNER) diff --git a/services/web/app/src/router.js b/services/web/app/src/router.js index f1c876d26b..5c8f090d6c 100644 --- a/services/web/app/src/router.js +++ b/services/web/app/src/router.js @@ -509,6 +509,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) { RateLimiterMiddleware.rateLimit(openProjectRateLimiter, { params: ['Project_id'], }), + PermissionsController.useCapabilities(), AuthorizationMiddleware.ensureUserCanReadProject, ProjectController.loadEditor ) diff --git a/services/web/frontend/js/features/settings/components/labs-program-section.tsx b/services/web/frontend/js/features/settings/components/labs-program-section.tsx index cace463ddf..2420a68e7c 100644 --- a/services/web/frontend/js/features/settings/components/labs-program-section.tsx +++ b/services/web/frontend/js/features/settings/components/labs-program-section.tsx @@ -3,12 +3,7 @@ import { useUserContext } from '../../../shared/context/user-context' function LabsProgramSection() { const { t } = useTranslation() - const { labsProgram, alphaProgram } = useUserContext() - - // keeping alpha only as we test AI experiment in preparation for general labs release - if (!alphaProgram) { - return null - } + const { labsProgram } = useUserContext() const labsStatusText = labsProgram ? t('youre_a_member_of_overleaf_labs')