From 4938c7fe46dc75a56f083044d2fc3733a6af9914 Mon Sep 17 00:00:00 2001 From: Justyn Oh Date: Tue, 25 Apr 2023 14:07:59 +0800 Subject: [PATCH 01/11] chore: remove react migration vars --- .../admin-form/common/AdminFormLayout.tsx | 3 - .../admin-form/preview/PreviewFormPage.tsx | 3 - .../admin-form/template/TemplateFormPage.tsx | 3 - .../src/features/env/AdminFeedbackIcon.tsx | 36 -- .../src/features/env/AdminFeedbackModal.tsx | 180 --------- frontend/src/features/env/EnvService.ts | 133 +------ .../src/features/env/PublicFeedbackModal.tsx | 284 -------------- .../env/SwitchEnvFeedbackModal.stories.tsx | 77 ---- frontend/src/features/env/mutations.ts | 49 --- frontend/src/features/env/queries.ts | 30 +- frontend/src/features/env/utils.ts | 12 - .../FormFields/FormFieldsContainer.tsx | 10 - .../components/PublicSwitchEnvMessage.tsx | 118 ------ .../src/features/workspace/WorkspacePage.tsx | 3 - .../components/AdminSwitchEnvMessage.tsx | 72 ---- .../EmptyWorkspace/EmptyWorkspace.tsx | 8 +- .../components/WorkspacePageContent.tsx | 5 - frontend/src/services/EnvService.ts | 21 - shared/types/core.ts | 6 - src/app/config/schema.ts | 74 ---- src/app/loaders/express/index.ts | 2 - src/app/loaders/express/locals.ts | 18 - src/app/loaders/express/logging.ts | 28 +- .../modules/feedback/feedback.controller.ts | 18 +- .../public-form/public-form.controller.ts | 9 - .../public-form/public-form.middlewares.ts | 15 - src/app/modules/frontend/frontend.service.ts | 8 - .../react-migration.controller.ts | 365 ------------------ .../react-migration/react-migration.routes.ts | 23 -- src/app/routes/api/v3/admin/admin.routes.ts | 9 - .../api/v3/forms/public-forms.form.routes.ts | 24 -- .../forms/public-forms.submissions.routes.ts | 11 - src/public/main.css | 1 - src/public/main.js | 4 - .../react-switch-banner.client.view.html | 12 - .../react-switch-banner.client.component.js | 29 -- .../forms/admin/css/react-switch-banner.css | 46 --- .../admin/views/list-forms.client.view.html | 3 - src/public/services/AdminService.ts | 17 - src/public/services/PublicFormService.ts | 47 --- .../services/__tests__/AdminService.test.ts | 28 -- src/types/config.ts | 26 -- 42 files changed, 10 insertions(+), 1860 deletions(-) delete mode 100644 frontend/src/features/env/AdminFeedbackIcon.tsx delete mode 100644 frontend/src/features/env/AdminFeedbackModal.tsx delete mode 100644 frontend/src/features/env/PublicFeedbackModal.tsx delete mode 100644 frontend/src/features/env/SwitchEnvFeedbackModal.stories.tsx delete mode 100644 frontend/src/features/env/mutations.ts delete mode 100644 frontend/src/features/env/utils.ts delete mode 100644 frontend/src/features/public-form/components/PublicSwitchEnvMessage.tsx delete mode 100644 frontend/src/features/workspace/components/AdminSwitchEnvMessage.tsx delete mode 100644 frontend/src/services/EnvService.ts delete mode 100644 src/app/modules/form/public-form/public-form.middlewares.ts delete mode 100644 src/app/modules/react-migration/react-migration.controller.ts delete mode 100644 src/app/modules/react-migration/react-migration.routes.ts delete mode 100644 src/public/modules/forms/admin/componentViews/react-switch-banner.client.view.html delete mode 100644 src/public/modules/forms/admin/components/react-switch-banner.client.component.js delete mode 100644 src/public/modules/forms/admin/css/react-switch-banner.css delete mode 100644 src/public/services/AdminService.ts delete mode 100644 src/public/services/__tests__/AdminService.test.ts diff --git a/frontend/src/features/admin-form/common/AdminFormLayout.tsx b/frontend/src/features/admin-form/common/AdminFormLayout.tsx index 074d3e3865..36bf0a3efa 100644 --- a/frontend/src/features/admin-form/common/AdminFormLayout.tsx +++ b/frontend/src/features/admin-form/common/AdminFormLayout.tsx @@ -9,8 +9,6 @@ import { Banner } from '~components/Banner' import AdminForbiddenErrorPage from '~pages/AdminForbiddenError' import NotFoundErrorPage from '~pages/NotFoundError' -// TODO #4279: Remove after React rollout is complete -import { AdminFeedbackIcon } from '~features/env/AdminFeedbackIcon' import { useEnv } from '~features/env/queries' import { StorageResponsesProvider } from '../responses/ResponsesPage/storage/StorageResponsesProvider' @@ -68,7 +66,6 @@ export const AdminFormLayout = (): JSX.Element => { ) : null} - diff --git a/frontend/src/features/admin-form/preview/PreviewFormPage.tsx b/frontend/src/features/admin-form/preview/PreviewFormPage.tsx index 7eacef38e4..eb312f6421 100644 --- a/frontend/src/features/admin-form/preview/PreviewFormPage.tsx +++ b/frontend/src/features/admin-form/preview/PreviewFormPage.tsx @@ -4,8 +4,6 @@ import { Flex } from '@chakra-ui/react' import { fillHeightCss } from '~utils/fillHeightCss' import GovtMasthead from '~components/GovtMasthead' -// TODO #4279: Remove after React rollout is complete -import { AdminFeedbackIcon } from '~features/env/AdminFeedbackIcon' import FormEndPage from '~features/public-form/components/FormEndPage' import FormFields from '~features/public-form/components/FormFields' import { FormSectionsProvider } from '~features/public-form/components/FormFields/FormSectionsContext' @@ -28,7 +26,6 @@ export const PreviewFormPage = (): JSX.Element => { - diff --git a/frontend/src/features/admin-form/template/TemplateFormPage.tsx b/frontend/src/features/admin-form/template/TemplateFormPage.tsx index 569e3d5325..082b9b1d5d 100644 --- a/frontend/src/features/admin-form/template/TemplateFormPage.tsx +++ b/frontend/src/features/admin-form/template/TemplateFormPage.tsx @@ -4,8 +4,6 @@ import { Flex } from '@chakra-ui/react' import { fillHeightCss } from '~utils/fillHeightCss' import GovtMasthead from '~components/GovtMasthead' -// TODO #4279: Remove after React rollout is complete -import { AdminFeedbackIcon } from '~features/env/AdminFeedbackIcon' import FormEndPage from '~features/public-form/components/FormEndPage' import FormFields from '~features/public-form/components/FormFields' import { FormSectionsProvider } from '~features/public-form/components/FormFields/FormSectionsContext' @@ -28,7 +26,6 @@ export const TemplateFormPage = (): JSX.Element => { - diff --git a/frontend/src/features/env/AdminFeedbackIcon.tsx b/frontend/src/features/env/AdminFeedbackIcon.tsx deleted file mode 100644 index 8187c5f5a4..0000000000 --- a/frontend/src/features/env/AdminFeedbackIcon.tsx +++ /dev/null @@ -1,36 +0,0 @@ -// TODO #4279: Remove after React rollout is complete -import { BiMessage } from 'react-icons/bi' -import { Flex, Portal, useDisclosure } from '@chakra-ui/react' - -import { noPrintCss } from '~utils/noPrintCss' -import IconButton from '~components/IconButton' -import Tooltip from '~components/Tooltip' - -import { AdminFeedbackModal } from './AdminFeedbackModal' - -export const AdminFeedbackIcon = (): JSX.Element => { - const { isOpen, onOpen, onClose } = useDisclosure() - - return ( - - - - } - onClick={onOpen} - /> - - - - - ) -} diff --git a/frontend/src/features/env/AdminFeedbackModal.tsx b/frontend/src/features/env/AdminFeedbackModal.tsx deleted file mode 100644 index e404d96787..0000000000 --- a/frontend/src/features/env/AdminFeedbackModal.tsx +++ /dev/null @@ -1,180 +0,0 @@ -// TODO #4279: Remove after React rollout is complete -import { useCallback, useRef } from 'react' -import { Controller, useForm } from 'react-hook-form' -import { - chakra, - FormControl, - Input, - Modal, - ModalBody, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, - Skeleton, - Stack, - useBreakpointValue, -} from '@chakra-ui/react' -import { datadogRum } from '@datadog/browser-rum' -import { isEmpty } from 'lodash' - -import { AdminFeedbackFormDto } from '~shared/types' - -import { REQUIRED_ERROR } from '~constants/validation' -import { useIsMobile } from '~hooks/useIsMobile' -import { useToast } from '~hooks/useToast' -import Button from '~components/Button' -import Rating from '~components/Field/Rating' -import FormErrorMessage from '~components/FormControl/FormErrorMessage' -import FormLabel from '~components/FormControl/FormLabel' -import { ModalCloseButton } from '~components/Modal' -import Textarea from '~components/Textarea' - -import { useUser } from '~features/user/queries' - -import { useFeedbackMutation } from './mutations' -import { useAdminFeedbackFormView } from './queries' -import { isUsableFeedback } from './utils' - -export const AdminFeedbackModal = ({ - isOpen, - onClose, -}: { - isOpen: boolean - onClose: () => void -}): JSX.Element => { - const modalSize = useBreakpointValue({ - base: 'mobile', - xs: 'mobile', - md: 'md', - }) - const isMobile = useIsMobile() - const toast = useToast({ status: 'success', isClosable: true }) - - const { - register, - handleSubmit, - control, - formState: { errors }, - } = useForm() - - const initialRef = useRef(null) - - const { user } = useUser() - const url = window.location.href - const rumSessionId = datadogRum.getInternalContext()?.session_id - - const { data: feedbackForm, isLoading } = useAdminFeedbackFormView() - const feedbackMutation = useFeedbackMutation() - - const handleSubmitForm = handleSubmit((formInputs: AdminFeedbackFormDto) => { - if (!feedbackForm) return - if (isUsableFeedback(formInputs.feedback)) { - feedbackMutation.mutate({ - formInputs, - feedbackForm, - }) - } - toast({ description: 'Your feedback has been submitted.' }) - onClose() - }) - - const handleClose = useCallback(() => { - onClose() - }, [onClose]) - - return ( - - - - - - Share your feedback - - - - - - - How was your experience using FormSG? - ( - onChange(val?.toString())} - {...rest} - /> - )} - /> - - {errors['rating']?.message} - - - - - Do you have any other feedback for us? -