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

Merge pull request #19954 from overleaf/ls-access-token-gradual-rollout-cleanup

Update git bridge modal for pw auth deprecation

GitOrigin-RevId: 2e764922bf350ddcba29bf9f3baa220ed1f48e40
Liangjun Song пре 2 година
родитељ
комит
3f1edfc1c9

+ 2 - 13
services/web/app/src/Features/Project/ProjectController.js

@@ -333,7 +333,6 @@ const _ProjectController = {
       'pdf-caching-prefetching',
       'pdf-presentation-mode',
       'pdfjs-40',
-      'personal-access-token',
       'revert-file',
       'revert-project',
       'review-panel-redesign',
@@ -343,6 +342,7 @@ const _ProjectController = {
       'ieee-stylesheet',
       'write-and-cite',
       'default-visual-for-beginners',
+      'password-authentication-removal',
     ].filter(Boolean)
 
     const getUserValues = async userId =>
@@ -635,16 +635,6 @@ const _ProjectController = {
         !userIsMemberOfGroupSubscription &&
         !userHasInstitutionLicence
 
-      const showPersonalAccessToken =
-        userId &&
-        (!Features.hasFeature('saas') ||
-          req.query?.personal_access_token === 'true')
-
-      const optionalPersonalAccessToken =
-        userId &&
-        !showPersonalAccessToken &&
-        splitTestAssignments['personal-access-token'].variant === 'enabled' // `?personal-access-token=enabled`
-
       let showAiErrorAssistant = false
       if (userId && Features.hasFeature('saas')) {
         try {
@@ -751,8 +741,6 @@ const _ProjectController = {
         showUpgradePrompt,
         fixedSizeDocument: true,
         useOpenTelemetry: Settings.useOpenTelemetryClient,
-        showPersonalAccessToken,
-        optionalPersonalAccessToken,
         hasTrackChangesFeature: Features.hasFeature('track-changes'),
         projectTags,
         linkSharingWarning: linkSharingChanges.variant === 'active',
@@ -762,6 +750,7 @@ const _ProjectController = {
           'enabled'
             ? usedLatex
             : null,
+        isSaas: Features.hasFeature('saas'),
       })
       timer.done()
     } catch (err) {

+ 8 - 26
services/web/app/src/Features/User/UserPagesController.js

@@ -71,20 +71,6 @@ async function settingsPage(req, res) {
     )
   }
 
-  const showPersonalAccessToken =
-    !Features.hasFeature('saas') || req.query?.personal_access_token === 'true'
-
-  // if not already enabled, use a split test to determine whether to offer personal access tokens
-  let optionalPersonalAccessToken = false
-  if (!showPersonalAccessToken) {
-    const { variant } = await SplitTestHandler.promises.getAssignment(
-      req,
-      res,
-      'personal-access-token'
-    )
-    optionalPersonalAccessToken = variant === 'enabled' // `?personal-access-token=enabled`
-  }
-
   // getAssignment sets res.locals, which will pass to the splitTest context
   await SplitTestHandler.promises.getAssignment(
     req,
@@ -93,16 +79,14 @@ async function settingsPage(req, res) {
   )
 
   let personalAccessTokens
-  if (showPersonalAccessToken || optionalPersonalAccessToken) {
-    try {
-      // require this here because module may not be included in some versions
-      const PersonalAccessTokenManager = require('../../../../modules/oauth2-server/app/src/OAuthPersonalAccessTokenManager')
-      personalAccessTokens = await PersonalAccessTokenManager.listTokens(
-        user._id
-      )
-    } catch (error) {
-      logger.error(OError.tag(error))
-    }
+  try {
+    const results = await Modules.promises.hooks.fire(
+      'listPersonalAccessTokens',
+      user._id
+    )
+    personalAccessTokens = results?.[0] ?? []
+  } catch (error) {
+    logger.error(OError.tag(error))
   }
 
   let currentManagedUserAdminEmail
@@ -189,8 +173,6 @@ async function settingsPage(req, res) {
     ssoErrorMessage,
     thirdPartyIds: UserPagesController._restructureThirdPartyIds(user),
     projectSyncSuccessMessage,
-    showPersonalAccessToken,
-    optionalPersonalAccessToken,
     personalAccessTokens,
     emailAddressLimit: Settings.emailAddressLimit,
     isManagedAccount: !!req.managedBy,

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

@@ -31,14 +31,13 @@ meta(name="ol-showUpgradePrompt" data-type="boolean" content=showUpgradePrompt)
 meta(name="ol-useOpenTelemetry" data-type="boolean" content=useOpenTelemetry)
 meta(name="ol-showSupport", data-type="boolean" content=showSupport)
 meta(name="ol-showTemplatesServerPro", data-type="boolean" content=showTemplatesServerPro)
-meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken)
-meta(name="ol-optionalPersonalAccessToken", data-type="boolean" content=optionalPersonalAccessToken)
 meta(name="ol-hasTrackChangesFeature", data-type="boolean" content=hasTrackChangesFeature)
 meta(name="ol-inactiveTutorials", data-type="json" content=user.inactiveTutorials)
 meta(name="ol-projectTags" data-type="json" content=projectTags)
 meta(name="ol-linkSharingWarning" data-type="boolean" content=linkSharingWarning)
 meta(name="ol-usedLatex" data-type="string" content=usedLatex)
 meta(name="ol-ro-mirror-on-client-no-local-storage" data-type="boolean" content=roMirrorOnClientNoLocalStorage)
+meta(name="ol-isSaas" data-type="boolean" content=isSaas)
 
 // translations for the loading page, before i18n has loaded in the client
 meta(name="ol-loadingText", data-type="string" content=translate("loading"))

+ 0 - 2
services/web/app/views/user/settings.pug

@@ -26,8 +26,6 @@ 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)
-	meta(name="ol-optionalPersonalAccessToken", data-type="boolean" content=optionalPersonalAccessToken)
 	meta(name="ol-personalAccessTokens", data-type="json" content=personalAccessTokens)
 	meta(name="ol-emailAddressLimit", data-type="json", content=emailAddressLimit)
 	meta(name="ol-currentManagedUserAdminEmail" data-type="string" content=currentManagedUserAdminEmail)

+ 4 - 1
services/web/frontend/extracted-translations.json

@@ -506,9 +506,12 @@
   "git_bridge_modal_description": "",
   "git_bridge_modal_enter_authentication_token": "",
   "git_bridge_modal_git_authentication_tokens": "",
+  "git_bridge_modal_git_clone_your_project": "",
+  "git_bridge_modal_learn_more_about_authentication_tokens": "",
+  "git_bridge_modal_need_to_generate_an_authentication_token": "",
   "git_bridge_modal_read_only": "",
   "git_bridge_modal_see_once": "",
-  "git_bridge_modal_tokens_description": "",
+  "git_bridge_modal_the_way_you_clone_projects_has_changed": "",
   "git_bridge_modal_use_previous_token": "",
   "git_bridge_modal_you_can_also_git_clone": "",
   "git_integration": "",

+ 3 - 7
services/web/frontend/js/features/settings/components/linking-section.tsx

@@ -44,13 +44,9 @@ function LinkingSection() {
   const renderSyncSection =
     getMeta('ol-isSaas') || getMeta('ol-gitBridgeEnabled')
 
-  const showPersonalAccessTokenComponents =
-    getMeta('ol-showPersonalAccessToken') ||
-    getMeta('ol-optionalPersonalAccessToken')
-
-  const allIntegrationLinkingWidgets = showPersonalAccessTokenComponents
-    ? integrationLinkingWidgets.concat(oauth2ServerComponents)
-    : integrationLinkingWidgets
+  const allIntegrationLinkingWidgets = integrationLinkingWidgets.concat(
+    oauth2ServerComponents
+  )
 
   // currently the only thing that is in the langFeedback section is writefull,
   // which is behind a split test. we should hide this section if the user is not in the split test

+ 0 - 2
services/web/frontend/js/utils/meta.ts

@@ -141,7 +141,6 @@ export interface Meta {
   'ol-notifications': NotificationType[]
   'ol-notificationsInstitution': InstitutionType[]
   'ol-oauthProviders': OAuthProviders
-  'ol-optionalPersonalAccessToken': boolean
   'ol-overallThemes': OverallThemeMeta[]
   'ol-passwordStrengthOptions': PasswordStrengthOptions
   'ol-personalAccessTokens': AccessToken[] | undefined
@@ -174,7 +173,6 @@ export interface Meta {
   'ol-showGroupsAndEnterpriseBanner': boolean
   'ol-showInrGeoBanner': boolean
   'ol-showLATAMBanner': boolean
-  'ol-showPersonalAccessToken': boolean
   'ol-showSupport': boolean
   'ol-showSymbolPalette': boolean
   'ol-showTemplatesServerPro': boolean

+ 0 - 1
services/web/frontend/stories/settings/helpers/linking.js

@@ -75,5 +75,4 @@ export function setPersonalAccessTokensMeta() {
   }
 
   window.metaAttributesCache.set('ol-personalAccessTokens', tokens)
-  window.metaAttributesCache.set('ol-showPersonalAccessToken', true)
 }

+ 4 - 0
services/web/frontend/stylesheets/modules/git-bridge-modal.less

@@ -31,3 +31,7 @@
 .git-bridge-optional-tokens-actions {
   margin-top: @margin-sm;
 }
+
+.git-bridge-modal-notification {
+  margin-bottom: @margin-sm;
+}

+ 0 - 1
services/web/locales/da.json

@@ -528,7 +528,6 @@
   "git_bridge_modal_description": "Du kan git clone dit projekt med linket herunder.",
   "git_bridge_modal_enter_authentication_token": "Når du bliver spurgt om en kode, indtast da din nye autentificeringsnøgle:",
   "git_bridge_modal_see_once": "Du kan kun se denne autentificeringsnøgle én gang. For at slette den eller generere en ny, gå til dine brugerindstilinger. For detalerede instruktioner og fejlsøgning, læs vores <0>hjælpeside</0>.",
-  "git_bridge_modal_tokens_description": "For at git clone dit projekt har du brug for linket herunder og en git autentificeringsnøgle.",
   "git_bridge_modal_use_previous_token": "Hvis du bliver spurgt om en kode kan du bruge en tidligere genereret autentificeringsnøgle. Du kan også generere en ny i dine kontoindstillinger. For mere hjælp, læs vores <0>hjælpeside</0>.",
   "git_integration": "Git-integration",
   "git_integration_info": "Med Git-integration kan du klone dine Overleaf projekter med Git. For komplette instruktioner til hvordan du gør det, læs vores <0>hjælpeside</0>.",

+ 0 - 1
services/web/locales/de.json

@@ -533,7 +533,6 @@
   "git_bridge_modal_description": "Du kannst git clone für dein Projekt über den unten angezeigten Link ausführen.",
   "git_bridge_modal_enter_authentication_token": "Wenn Du nach einem Passwort gefragt wirst, gib deinen neuen Anmeldungs-Token ein:",
   "git_bridge_modal_see_once": "Du siehst diesen Token nur einmal. Um ihn zu löschen oder einen weiteren zu generieren, besuche die Kontoeinstellungen. Für detaillierte Anweisungen und Problembehebung, besuche unsere <0>Hilfe-Seite</0>.",
-  "git_bridge_modal_tokens_description": "Um einen Git-Clone deines Projekts zu erstellen, benutze folgenden Link und einen Git-Anmeldungs-Token.",
   "git_bridge_modal_use_previous_token": "Wenn Du nach einem Passwort gefragt wirst, kannst Du einen zuvor generierten Git-Anmeldungs-Token verwenden. Oder Du kannst einen Neuen in den Kontoeinstellungen generieren. Für mehr Hilfe, besuche unsere <0>Hilfe-Seite</0>.",
   "git_integration": "Git-Integration",
   "git_integration_info": "Mit der Git-Integration kannst Du Overleaf-Projekte Git-clonen. Für weitere Anweisungen hierfür, besuche <0>unsere Hilfe-Seite</0>.",

+ 4 - 1
services/web/locales/en.json

@@ -753,9 +753,12 @@
   "git_bridge_modal_description": "You can git clone your project using the link displayed below.",
   "git_bridge_modal_enter_authentication_token": "When prompted for a password, enter your new authentication token:",
   "git_bridge_modal_git_authentication_tokens": "Git authentication tokens",
+  "git_bridge_modal_git_clone_your_project": "Git clone your project by using the link below and a Git authentication token",
+  "git_bridge_modal_learn_more_about_authentication_tokens": "Learn more about Git integration authentication tokens.",
+  "git_bridge_modal_need_to_generate_an_authentication_token": "Instead of a password, you’ll need to generate an authentication token.",
   "git_bridge_modal_read_only": "<strong>You have read-only access to this project.</strong> This means you can pull from __appName__ but you can’t push any changes you make back to this project.",
   "git_bridge_modal_see_once": "You’ll only see this token once. To delete it or generate a new one, visit Account Settings. For detailed instructions and troubleshooting, read our <0>help page</0>.",
-  "git_bridge_modal_tokens_description": "To git clone your project you’ll need the link below and a Git authentication token.",
+  "git_bridge_modal_the_way_you_clone_projects_has_changed": "The way you git clone projects on Overleaf has changed.",
   "git_bridge_modal_use_previous_token": "If you’re prompted for a password, you can use a previously generated Git authentication token. Or you can generate a new one in Account Settings. For more support, read our <0>help page</0>.",
   "git_bridge_modal_you_can_also_git_clone": "You can also git clone your project by using the link below and a Git authentication token.",
   "git_gitHub_dropbox_mendeley_and_zotero_integrations": "Git, GitHub, Dropbox, Mendeley, and Zotero integrations",

+ 0 - 1
services/web/locales/zh-CN.json

@@ -718,7 +718,6 @@
   "git_bridge_modal_git_authentication_tokens": "Git 身份验证令牌",
   "git_bridge_modal_read_only": "<strong>您对此项目具有只读访问权限</strong>这意味着您可以从__appName__中提取,但不能将您所做的任何更改推送回该项目。",
   "git_bridge_modal_see_once": "您只能看到此令牌一次。要删除或生成新帐户,请访问“帐户设置”。有关详细说明和故障排除,请阅读我们的<0>帮助页面</0>。",
-  "git_bridge_modal_tokens_description": "要用 git 克隆您的项目,您需要下面的链接和 git 身份验证令牌。",
   "git_bridge_modal_use_previous_token": "如果系统提示您输入密码,您可以使用以前生成的Git身份验证令牌。或者,您可以在“帐户设置”中生成一个新帐户。有关更多支持,请阅读我们的<0>帮助页面</0>。",
   "git_bridge_modal_you_can_also_git_clone": "您也可以使用下面的链接和git身份验证令牌来git克隆您的项目。",
   "git_gitHub_dropbox_mendeley_and_zotero_integrations": "Git、GitHub、Dropbox、Mendeley 和 Zotero 集成",

+ 1 - 1
services/web/test/frontend/components/editor-left-menu/editor-left-menu.spec.tsx

@@ -267,7 +267,7 @@ describe('<EditorLeftMenu />', function () {
 
         cy.findByRole('button', { name: 'Git' }).click()
         cy.findByText('Clone with Git')
-        cy.findByText(/your project using the link displayed below/)
+        cy.findByText(/clone your project by using the link below/)
       })
 
       it('shows git modal paywall correctly', function () {