소스 검색

Merge pull request #18256 from overleaf/rd-a11y-form

[web] Create accessibility survey link on the project dashboard

GitOrigin-RevId: 49503da67347c9e0e15a10f041252f25f0effc15
Rebeka Dekany 2 년 전
부모
커밋
3ef06d57c6

+ 2 - 0
services/web/frontend/extracted-translations.json

@@ -510,6 +510,7 @@
   "headers": "",
   "headers": "",
   "help": "",
   "help": "",
   "help_improve_overleaf_fill_out_this_survey": "",
   "help_improve_overleaf_fill_out_this_survey": "",
+  "help_improve_screen_reader_fill_out_this_survey": "",
   "hide_configuration": "",
   "hide_configuration": "",
   "hide_deleted_user": "",
   "hide_deleted_user": "",
   "hide_document_preamble": "",
   "hide_document_preamble": "",
@@ -1290,6 +1291,7 @@
   "tag_name_is_already_used": "",
   "tag_name_is_already_used": "",
   "tags": "",
   "tags": "",
   "take_short_survey": "",
   "take_short_survey": "",
+  "take_survey": "",
   "tc_everyone": "",
   "tc_everyone": "",
   "tc_guests": "",
   "tc_guests": "",
   "tc_switch_everyone_tip": "",
   "tc_switch_everyone_tip": "",

+ 47 - 0
services/web/frontend/js/features/project-list/components/notifications/accessibility-survey-banner.tsx

@@ -0,0 +1,47 @@
+import { memo, useEffect, useState } from 'react'
+import Notification from './notification'
+import customLocalStorage from '@/infrastructure/local-storage'
+import { useTranslation } from 'react-i18next'
+
+function AccessibilitySurveyBanner() {
+  const { t } = useTranslation()
+  const [show, setShow] = useState(false)
+
+  useEffect(() => {
+    const isDismissed = customLocalStorage.getItem(
+      'has_dismissed_accessibility_survey_banner'
+    )
+    if (!isDismissed) setShow(true)
+  }, [])
+
+  const handleClose = () => {
+    customLocalStorage.setItem(
+      'has_dismissed_accessibility_survey_banner',
+      'true'
+    )
+    setShow(false)
+  }
+
+  if (!show) return null
+
+  return (
+    <Notification
+      className="sr-only"
+      bsStyle="info"
+      onDismiss={handleClose}
+      body={<p>{t('help_improve_screen_reader_fill_out_this_survey')}</p>}
+      action={
+        <a
+          className="btn btn-secondary btn-sm pull-right btn-info"
+          href="https://docs.google.com/forms/d/e/1FAIpQLSdxKP_biRXvrkmJzlBjMwI_qPSuv4NbBvYUzSOc3OOTIOTmnQ/viewform"
+          target="_blank"
+          rel="noreferrer"
+        >
+          {t('take_survey')}
+        </a>
+      }
+    />
+  )
+}
+
+export default memo(AccessibilitySurveyBanner)

+ 3 - 0
services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx

@@ -12,6 +12,7 @@ import customLocalStorage from '../../../../infrastructure/local-storage'
 import { sendMB } from '../../../../infrastructure/event-tracking'
 import { sendMB } from '../../../../infrastructure/event-tracking'
 import classNames from 'classnames'
 import classNames from 'classnames'
 import GeoBanners from './geo-banners'
 import GeoBanners from './geo-banners'
+import AccessibilitySurveyBanner from './accessibility-survey-banner'
 
 
 type Subscription = {
 type Subscription = {
   groupId: string
   groupId: string
@@ -85,6 +86,8 @@ function UserNotifications() {
         <GeoBanners />
         <GeoBanners />
         {!showWritefull && !dismissedWritefull && <GroupsAndEnterpriseBanner />}
         {!showWritefull && !dismissedWritefull && <GroupsAndEnterpriseBanner />}
 
 
+        <AccessibilitySurveyBanner />
+
         <WritefullPremiumPromoBanner
         <WritefullPremiumPromoBanner
           show={showWritefull}
           show={showWritefull}
           setShow={setShowWritefull}
           setShow={setShowWritefull}

+ 28 - 26
services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx

@@ -31,32 +31,34 @@ function WritefullPremiumPromoBanner({
   }
   }
 
 
   return (
   return (
-    <Notification
-      bsStyle="info"
-      newNotificationStyle
-      onDismiss={handleClose}
-      body={
-        <>
-          Enjoying Writefull? Get <strong>10% off Writefull Premium</strong>,
-          giving you access to TeXGPT—AI assistance to generate LaTeX code. Use{' '}
-          <strong>OVERLEAF10</strong> at the checkout.
-        </>
-      }
-      action={
-        <a
-          className="btn btn-secondary btn-sm"
-          href="https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans"
-          target="_blank"
-          rel="noreferrer"
-          onClick={() => {
-            sendMB('promo-click', eventSegmentation)
-          }}
-        >
-          <WritefullLogo width="16" height="16" />{' '}
-          <span>Get Writefull Premium</span>
-        </a>
-      }
-    />
+    <div data-testid="writefull-premium-promo-banner">
+      <Notification
+        bsStyle="info"
+        newNotificationStyle
+        onDismiss={handleClose}
+        body={
+          <>
+            Enjoying Writefull? Get <strong>10% off Writefull Premium</strong>,
+            giving you access to TeXGPT—AI assistance to generate LaTeX code.
+            Use <strong>OVERLEAF10</strong> at the checkout.
+          </>
+        }
+        action={
+          <a
+            className="btn btn-secondary btn-sm"
+            href="https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans"
+            target="_blank"
+            rel="noreferrer"
+            onClick={() => {
+              sendMB('promo-click', eventSegmentation)
+            }}
+          >
+            <WritefullLogo width="16" height="16" />{' '}
+            <span>Get Writefull Premium</span>
+          </a>
+        }
+      />
+    </div>
   )
   )
 }
 }
 
 

+ 1 - 0
services/web/frontend/js/features/project-list/components/project-list-root.tsx

@@ -78,6 +78,7 @@ function ProjectListPageContent() {
   ) : (
   ) : (
     <>
     <>
       <SystemMessages />
       <SystemMessages />
+
       <div className="project-list-wrapper clearfix container mx-0 px-0">
       <div className="project-list-wrapper clearfix container mx-0 px-0">
         {totalProjectsCount > 0 ? (
         {totalProjectsCount > 0 ? (
           <>
           <>

+ 2 - 0
services/web/locales/en.json

@@ -756,6 +756,7 @@
   "help": "Help",
   "help": "Help",
   "help_articles_matching": "Help articles matching your subject",
   "help_articles_matching": "Help articles matching your subject",
   "help_improve_overleaf_fill_out_this_survey": "If you would like to help us improve Overleaf, please take a moment to fill out <0>this survey</0>.",
   "help_improve_overleaf_fill_out_this_survey": "If you would like to help us improve Overleaf, please take a moment to fill out <0>this survey</0>.",
+  "help_improve_screen_reader_fill_out_this_survey": "Help us improve your experience using a screen reader with __appName__ by filling out this quick survey.",
   "hide_configuration": "Hide configuration",
   "hide_configuration": "Hide configuration",
   "hide_deleted_user": "Hide deleted users",
   "hide_deleted_user": "Hide deleted users",
   "hide_document_preamble": "Hide document preamble",
   "hide_document_preamble": "Hide document preamble",
@@ -1833,6 +1834,7 @@
   "tags": "Tags",
   "tags": "Tags",
   "take_me_home": "Take me home!",
   "take_me_home": "Take me home!",
   "take_short_survey": "Take a short survey",
   "take_short_survey": "Take a short survey",
+  "take_survey": "Take survey",
   "tc_everyone": "Everyone",
   "tc_everyone": "Everyone",
   "tc_guests": "Guests",
   "tc_guests": "Guests",
   "tc_switch_everyone_tip": "Toggle track-changes for everyone",
   "tc_switch_everyone_tip": "Toggle track-changes for everyone",

+ 6 - 1
services/web/test/frontend/features/project-list/components/notifications.test.tsx

@@ -998,7 +998,12 @@ describe('<UserNotifications />', function () {
       it('dismisses the banner when the close button is clicked', function () {
       it('dismisses the banner when the close button is clicked', function () {
         renderWithinProjectListProvider(UserNotifications)
         renderWithinProjectListProvider(UserNotifications)
         screen.getByRole('link', { name: /Writefull/ })
         screen.getByRole('link', { name: /Writefull/ })
-        const closeButton = screen.getByRole('button', { name: 'Close' })
+        const WritefullPromoBanner = screen.getByTestId(
+          'writefull-premium-promo-banner'
+        )
+        const closeButton = within(WritefullPromoBanner).getByRole('button', {
+          name: 'Close',
+        })
         fireEvent.click(closeButton)
         fireEvent.click(closeButton)
         expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
         expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
         expect(localStorage.getItem('has_dismissed_writefull_promo_banner')).to
         expect(localStorage.getItem('has_dismissed_writefull_promo_banner')).to