import { useIdeRedesignSwitcherContext } from '@/features/ide-react/context/ide-redesign-switcher-context' import OLButton from '@/features/ui/components/ol/ol-button' import OLModal, { OLModalBody, OLModalFooter, OLModalHeader, OLModalTitle, } from '@/features/ui/components/ol/ol-modal' import { FC, useCallback } from 'react' import { canUseNewEditor, useIsNewEditorEnabled, } from '../../utils/new-editor-utils' import Notification from '@/shared/components/notification' import { useSwitchEnableNewEditorState } from '../../hooks/use-switch-enable-new-editor-state' import { Trans, useTranslation } from 'react-i18next' import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics' import { useFeatureFlag } from '@/shared/context/split-test-context' import { useSurveyUrl } from '../../hooks/use-survey-url' export const IdeRedesignSwitcherModal = () => { const { t } = useTranslation() const { showSwitcherModal, setShowSwitcherModal } = useIdeRedesignSwitcherContext() const onHide = useCallback( () => setShowSwitcherModal(false), [setShowSwitcherModal] ) const { loading, error, setEditorRedesignStatus } = useSwitchEnableNewEditorState() const enabled = useIsNewEditorEnabled() const hasAccess = canUseNewEditor() if (!hasAccess) { return null } const Content = enabled ? SwitcherModalContentEnabled : SwitcherModalContentDisabled return ( {t('the_new_overleaf_editor')} {error && } ) } type ModalContentProps = { setEditorRedesignStatus: (enabled: boolean) => Promise hide: () => void loading: boolean } const SwitcherModalContentEnabled: FC = ({ setEditorRedesignStatus, hide, loading, }) => { const { t } = useTranslation() const { sendEvent } = useEditorAnalytics() const disable = useCallback(() => { sendEvent('editor-redesign-toggle', { action: 'disable', location: 'modal', }) setEditorRedesignStatus(false) .then(hide) .catch(() => { // do nothing, we're already showing the error }) }, [setEditorRedesignStatus, hide, sendEvent]) const surveyURL = useSurveyUrl() return ( <>

{t('youre_helping_us_shape_the_future_of_overleaf')}

{t( 'thanks_for_being_part_of_this_labs_experiment_your_feedback_will_help_us_make_the_new_editor_the_best_yet' )}

{t('switch_to_old_editor')} {t('cancel')} {t('give_feedback')} ) } const SwitcherModalContentDisabled: FC = ({ setEditorRedesignStatus, hide, loading, }) => { const { t } = useTranslation() const { sendEvent } = useEditorAnalytics() const enable = useCallback(() => { sendEvent('editor-redesign-toggle', { action: 'enable', location: 'modal', }) setEditorRedesignStatus(true) .then(hide) .catch(() => { // do nothing, we're already showing the error }) }, [setEditorRedesignStatus, hide, sendEvent]) return ( <>

{t('help_shape_the_future_of_overleaf')}

{t('were_redesigning_our_editor_to_make_it_easier_to_use')}

{t('cancel')} {t('switch_to_new_editor')} ) } const SwitcherWhatsNew = () => { const { t } = useTranslation() const newErrorlogs = useFeatureFlag('new-editor-error-logs-redesign') return (

{t('latest_updates')}

    {newErrorlogs &&
  • {t('new_error_logs_panel')}
  • }
  • {t('searching_all_project_files_is_now_available')}
  • {t('double_clicking_on_the_pdf_shows')}

{t('whats_different_in_the_new_editor')}

  • {t('new_look_and_feel')}
  • {t('new_navigation_introducing_left_hand_side_rail_and_top_menus')}
  • {t('new_look_and_placement_of_the_settings')}
  • {t('improved_dark_mode')}
  • {t('review_panel_and_error_logs_moved_to_the_left')}
) } const LeavingNote = () => { return (

]} shouldUnescape tOptions={{ interpolation: { escapeValue: true } }} />

) }