Преглед изворни кода

Merge pull request #12901 from overleaf/msm-oauth-token-flags

[web] Feature flags for Personal Access Tokens

GitOrigin-RevId: cb359b7c41d8875ebae7d78a8839528bc4adc04c
Miguel Serrano пре 3 година
родитељ
комит
c2dce961b9

+ 5 - 0
services/web/app/src/Features/Project/ProjectController.js

@@ -1317,6 +1317,10 @@ const ProjectController = {
               onboardingVideoTourAssignment.variant === 'active' &&
               req.session.justRegistered
 
+            const showPersonalAccessToken =
+              !Features.hasFeature('saas') ||
+              req.query?.personal_access_token === 'true'
+
             const template =
               detachRole === 'detached'
                 ? 'project/editor_detached'
@@ -1407,6 +1411,7 @@ const ProjectController = {
               richTextVariant: richTextAssignment.variant,
               showOnboardingVideoTour,
               historyViewReact: historyViewAssignment.variant === 'react',
+              showPersonalAccessToken,
             })
             timer.done()
           }

+ 6 - 0
services/web/app/src/Features/User/UserPagesController.js

@@ -8,6 +8,7 @@ const SessionManager = require('../Authentication/SessionManager')
 const NewsletterManager = require('../Newsletter/NewsletterManager')
 const _ = require('lodash')
 const { expressify } = require('../../util/promises')
+const Features = require('../../infrastructure/Features')
 
 async function settingsPage(req, res) {
   const userId = SessionManager.getLoggedInUserId(req.session)
@@ -64,6 +65,10 @@ async function settingsPage(req, res) {
       res.redirect('/')
     )
   }
+
+  const showPersonalAccessToken =
+    !Features.hasFeature('saas') || req.query?.personal_access_token === 'true'
+
   res.render('user/settings', {
     title: 'account_settings',
     user: {
@@ -106,6 +111,7 @@ async function settingsPage(req, res) {
     ssoErrorMessage,
     thirdPartyIds: UserPagesController._restructureThirdPartyIds(user),
     projectSyncSuccessMessage,
+    showPersonalAccessToken,
   })
 }
 

+ 1 - 0
services/web/app/views/project/editor/meta.pug

@@ -41,6 +41,7 @@ meta(name="ol-showTemplatesServerPro", data-type="boolean" content=showTemplates
 meta(name="ol-showCM6SwitchAwaySurvey", data-type="boolean" content=showCM6SwitchAwaySurvey)
 meta(name="ol-richTextVariant" content=richTextVariant)
 meta(name="ol-showOnboardingVideoTour", data-type="boolean" content=showOnboardingVideoTour)
+meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken)
 if (richTextVariant === 'cm6')
 	meta(name="ol-mathJax3Path" content=mathJax3Path)
 

+ 1 - 1
services/web/app/views/user/settings.pug

@@ -22,7 +22,7 @@ block append meta
 	meta(name="ol-dropbox" data-type="json" content=dropbox)
 	meta(name="ol-github" data-type="json" content=github)
 	meta(name="ol-projectSyncSuccessMessage", content=projectSyncSuccessMessage)
-
+	meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken)
 
 block content
 	main.content.content-alt#settings-page-root

+ 4 - 0
services/web/test/unit/src/User/UserPagesControllerTests.js

@@ -67,6 +67,9 @@ describe('UserPagesController', function () {
       _getRedirectFromSession: sinon.stub(),
       setRedirectInSession: sinon.stub(),
     }
+    this.Features = {
+      hasFeature: sinon.stub().returns(false),
+    }
     this.UserPagesController = SandboxedModule.require(modulePath, {
       requires: {
         '@overleaf/settings': this.settings,
@@ -76,6 +79,7 @@ describe('UserPagesController', function () {
         '../Errors/ErrorController': this.ErrorController,
         '../Authentication/AuthenticationController':
           this.AuthenticationController,
+        '../../infrastructure/Features': this.Features,
         '../Authentication/SessionManager': this.SessionManager,
         request: (this.request = sinon.stub()),
       },