Просмотр исходного кода

Merge pull request #23319 from overleaf/rh-compile-timeout-students

Expose ODC role to compile timeout paywall

GitOrigin-RevId: eca3983019200349e90b4681b59720c0028fb3b6
roo hutton 1 год назад
Родитель
Сommit
32793f7872

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

@@ -411,6 +411,13 @@ const _ProjectController = {
             logger.error({ err, userId })
             return null
           }),
+          odcRole: OnboardingDataCollectionManager.getOnboardingDataValue(
+            userId,
+            'role'
+          ).catch(err => {
+            logger.error({ err, userId })
+            return null
+          }),
         })
       )
     const splitTestAssignments = {}
@@ -464,6 +471,7 @@ const _ProjectController = {
         isTokenMember,
         isInvitedMember,
         usedLatex,
+        odcRole,
       } = userValues
 
       const brandVariation = project?.brandVariationId
@@ -816,6 +824,12 @@ const _ProjectController = {
           'enabled'
             ? usedLatex
             : null,
+        odcRole:
+          // only use the ODC role value if the split test is enabled
+          splitTestAssignments['paywall-change-compile-timeout']?.variant ===
+          'enabled'
+            ? odcRole
+            : null,
         isSaas: Features.hasFeature('saas'),
         shouldLoadHotjar: splitTestAssignments.hotjar?.variant === 'enabled',
         isReviewerRoleEnabled:

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

@@ -40,6 +40,7 @@ meta(name="ol-ro-mirror-on-client-no-local-storage" data-type="boolean" content=
 meta(name="ol-isSaas" data-type="boolean" content=isSaas)
 meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar)
 meta(name="ol-isReviewerRoleEnabled" data-type="boolean" content=isReviewerRoleEnabled)
+meta(name="ol-odcRole" data-type="string" content=odcRole)
 meta(name="ol-isPaywallChangeCompileTimeoutEnabled" data-type="boolean" content=isPaywallChangeCompileTimeoutEnabled)
 
 // translations for the loading page, before i18n has loaded in the client

+ 19 - 1
services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-paywall-prompt.tsx

@@ -1,5 +1,23 @@
+import getMeta from '@/utils/meta'
+import {
+  studentRoles,
+  StudentRole,
+} from '../../../../../modules/onboarding/frontend/js/components/data/roles'
+import { useMemo } from 'react'
+
 function TimeoutUpgradePaywallPrompt() {
-  return <div>Hello world from new paywall component</div>
+  const odcRole = getMeta('ol-odcRole')
+  const isStudent = useMemo(
+    () => studentRoles.includes(odcRole as StudentRole),
+    [odcRole]
+  )
+
+  return (
+    <div>
+      <p>Hello world from new paywall component</p>
+      <p>Current user is {!isStudent && 'not'} a student.</p>
+    </div>
+  )
 }
 
 export default TimeoutUpgradePaywallPrompt

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

@@ -153,6 +153,7 @@ export interface Meta {
   'ol-notifications': NotificationType[]
   'ol-notificationsInstitution': InstitutionType[]
   'ol-oauthProviders': OAuthProviders
+  'ol-odcRole': string
   'ol-overallThemes': OverallThemeMeta[]
   'ol-passwordStrengthOptions': PasswordStrengthOptions
   'ol-personalAccessTokens': AccessToken[] | undefined