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

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

Expose ODC role to compile timeout paywall

GitOrigin-RevId: eca3983019200349e90b4681b59720c0028fb3b6
roo hutton пре 1 година
родитељ
комит
32793f7872

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

@@ -411,6 +411,13 @@ const _ProjectController = {
             logger.error({ err, userId })
             logger.error({ err, userId })
             return null
             return null
           }),
           }),
+          odcRole: OnboardingDataCollectionManager.getOnboardingDataValue(
+            userId,
+            'role'
+          ).catch(err => {
+            logger.error({ err, userId })
+            return null
+          }),
         })
         })
       )
       )
     const splitTestAssignments = {}
     const splitTestAssignments = {}
@@ -464,6 +471,7 @@ const _ProjectController = {
         isTokenMember,
         isTokenMember,
         isInvitedMember,
         isInvitedMember,
         usedLatex,
         usedLatex,
+        odcRole,
       } = userValues
       } = userValues
 
 
       const brandVariation = project?.brandVariationId
       const brandVariation = project?.brandVariationId
@@ -816,6 +824,12 @@ const _ProjectController = {
           'enabled'
           'enabled'
             ? usedLatex
             ? usedLatex
             : null,
             : 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'),
         isSaas: Features.hasFeature('saas'),
         shouldLoadHotjar: splitTestAssignments.hotjar?.variant === 'enabled',
         shouldLoadHotjar: splitTestAssignments.hotjar?.variant === 'enabled',
         isReviewerRoleEnabled:
         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-isSaas" data-type="boolean" content=isSaas)
 meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar)
 meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar)
 meta(name="ol-isReviewerRoleEnabled" data-type="boolean" content=isReviewerRoleEnabled)
 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)
 meta(name="ol-isPaywallChangeCompileTimeoutEnabled" data-type="boolean" content=isPaywallChangeCompileTimeoutEnabled)
 
 
 // translations for the loading page, before i18n has loaded in the client
 // 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() {
 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
 export default TimeoutUpgradePaywallPrompt

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

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