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

Merge pull request #20169 from overleaf/td-contact-modal-acknowledge

Add acknowledgement message to React contact modal after successful submission

GitOrigin-RevId: a27b968351857997df17fedde3baa9da3f82331a
Tim Down 2 лет назад
Родитель
Сommit
e88b971735

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

@@ -867,6 +867,7 @@
   "mendeley_sync_description": "",
   "mendeley_sync_description": "",
   "menu": "",
   "menu": "",
   "merge_cells": "",
   "merge_cells": "",
+  "message_received": "",
   "missing_field_for_entry": "",
   "missing_field_for_entry": "",
   "missing_fields_for_entry": "",
   "missing_fields_for_entry": "",
   "money_back_guarantee": "",
   "money_back_guarantee": "",
@@ -1463,6 +1464,7 @@
   "thank_you_exclamation": "",
   "thank_you_exclamation": "",
   "thank_you_for_your_feedback": "",
   "thank_you_for_your_feedback": "",
   "thanks_for_confirming_your_email_address": "",
   "thanks_for_confirming_your_email_address": "",
+  "thanks_for_getting_in_touch": "",
   "thanks_for_subscribing": "",
   "thanks_for_subscribing": "",
   "thanks_for_subscribing_you_help_sl": "",
   "thanks_for_subscribing_you_help_sl": "",
   "thanks_settings_updated": "",
   "thanks_settings_updated": "",

+ 5 - 1
services/web/frontend/js/features/ui/components/ol/ol-button.tsx

@@ -4,6 +4,7 @@ import type { ButtonProps } from '@/features/ui/components/types/button-props'
 import type { ButtonProps as BS3ButtonPropsBase } from 'react-bootstrap'
 import type { ButtonProps as BS3ButtonPropsBase } from 'react-bootstrap'
 import Button from '../bootstrap-5/button'
 import Button from '../bootstrap-5/button'
 import classnames from 'classnames'
 import classnames from 'classnames'
+import { getAriaAndDataProps } from '@/features/utils/bootstrap-5'
 
 
 export type BS3ButtonSize = 'xsmall' | 'sm' | 'medium' | 'lg'
 export type BS3ButtonSize = 'xsmall' | 'sm' | 'medium' | 'lg'
 
 
@@ -45,10 +46,13 @@ export const mapBsButtonSizes = (
 export default function OLButton(props: OLButtonProps) {
 export default function OLButton(props: OLButtonProps) {
   const { bs3Props, ...rest } = props
   const { bs3Props, ...rest } = props
 
 
+  // Get all `aria-*` and `data-*` attributes
+  const extraProps = getAriaAndDataProps(rest)
+
   return (
   return (
     <BootstrapVersionSwitcher
     <BootstrapVersionSwitcher
       bs3={
       bs3={
-        <BS3Button {...bs3ButtonProps(rest)} {...bs3Props}>
+        <BS3Button {...bs3ButtonProps(rest)} {...bs3Props} {...extraProps}>
           {bs3Props?.loading || rest.children}
           {bs3Props?.loading || rest.children}
         </BS3Button>
         </BS3Button>
       }
       }

+ 42 - 1
services/web/frontend/stories/contact-us-modal.stories.tsx

@@ -1,9 +1,10 @@
-import { ComponentProps } from 'react'
+import { ComponentProps, useCallback, useState } from 'react'
 import useFetchMock from './hooks/use-fetch-mock'
 import useFetchMock from './hooks/use-fetch-mock'
 import ContactUsModal from '../../modules/support/frontend/js/components/contact-us-modal'
 import ContactUsModal from '../../modules/support/frontend/js/components/contact-us-modal'
 import fixedHelpSuggestionSearch from '../../modules/support/test/frontend/util/fixed-help-suggestion-search'
 import fixedHelpSuggestionSearch from '../../modules/support/test/frontend/util/fixed-help-suggestion-search'
 import { ScopeDecorator } from './decorators/scope'
 import { ScopeDecorator } from './decorators/scope'
 import { StoryObj } from '@storybook/react'
 import { StoryObj } from '@storybook/react'
+import OLButton from '@/features/ui/components/ol/ol-button'
 
 
 type Story = StoryObj<typeof ContactUsModal>
 type Story = StoryObj<typeof ContactUsModal>
 type ContactUsModalProps = ComponentProps<typeof ContactUsModal>
 type ContactUsModalProps = ComponentProps<typeof ContactUsModal>
@@ -81,6 +82,46 @@ export const RequestErrorBootstrap5: Story = bootstrap5Story(
   renderContactUsModalWithRequestError
   renderContactUsModalWithRequestError
 )
 )
 
 
+const ContactUsModalWithAcknowledgement = (
+  args: Omit<ContactUsModalProps, 'show' | 'handleHide'>
+) => {
+  useFetchMock(fetchMock => {
+    fetchMock.post('/support', { status: 200 }, { delay: 1000 })
+  })
+
+  const [show, setShow] = useState(false)
+
+  const hideModal = useCallback((event?: Event) => {
+    event?.preventDefault()
+    setShow(false)
+  }, [])
+
+  return (
+    <>
+      <OLButton onClick={() => setShow(true)}>Contact Us</OLButton>
+      <ContactUsModal
+        show={show}
+        handleHide={hideModal}
+        helpSuggestionSearch={fixedHelpSuggestionSearch}
+        {...args}
+      />
+    </>
+  )
+}
+
+const renderContactUsModalWithAcknowledgement = (args: ContactUsModalProps) => {
+  const { show, handleHide, ...rest } = args
+  return <ContactUsModalWithAcknowledgement {...rest} />
+}
+
+export const WithAcknowledgement: Story = bootstrap3Story(
+  renderContactUsModalWithAcknowledgement
+)
+
+export const WithAcknowledgementBootstrap5: Story = bootstrap5Story(
+  renderContactUsModalWithAcknowledgement
+)
+
 export default {
 export default {
   title: 'Shared / Modals / Contact Us',
   title: 'Shared / Modals / Contact Us',
   component: ContactUsModal,
   component: ContactUsModal,

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

@@ -1228,6 +1228,7 @@
   "merge": "Merge",
   "merge": "Merge",
   "merge_cells": "Merge cells",
   "merge_cells": "Merge cells",
   "merging": "Merging",
   "merging": "Merging",
+  "message_received": "Message received",
   "missing_field_for_entry": "Missing field for",
   "missing_field_for_entry": "Missing field for",
   "missing_fields_for_entry": "Missing fields for",
   "missing_fields_for_entry": "Missing fields for",
   "money_back_guarantee": "30-day money back guarantee, no questions asked",
   "money_back_guarantee": "30-day money back guarantee, no questions asked",
@@ -2040,6 +2041,7 @@
   "thank_you_for_your_feedback": "Thank you for your feedback!",
   "thank_you_for_your_feedback": "Thank you for your feedback!",
   "thanks": "Thanks",
   "thanks": "Thanks",
   "thanks_for_confirming_your_email_address": "Thanks for confirming your email address",
   "thanks_for_confirming_your_email_address": "Thanks for confirming your email address",
+  "thanks_for_getting_in_touch": "Thanks for getting in touch. Our team will get back to you by email as soon as possible.",
   "thanks_for_subscribing": "Thanks for subscribing!",
   "thanks_for_subscribing": "Thanks for subscribing!",
   "thanks_for_subscribing_you_help_sl": "Thank you for subscribing to the __planName__ plan. It’s support from people like yourself that allows __appName__ to continue to grow and improve.",
   "thanks_for_subscribing_you_help_sl": "Thank you for subscribing to the __planName__ plan. It’s support from people like yourself that allows __appName__ to continue to grow and improve.",
   "thanks_settings_updated": "Thanks, your settings have been updated.",
   "thanks_settings_updated": "Thanks, your settings have been updated.",