Files
Verso/services/web/frontend/js/features/editor-navigation-toolbar/try-new-editor-button.tsx
T
David c4b3cd2a77 Merge pull request #29511 from overleaf/dp-new-users-to-new-editor
Move all new users to use the new editor

GitOrigin-RevId: e3611e5853da4b96db9f4cc37114ededb8632aed
2025-11-13 09:06:00 +00:00

38 lines
1.2 KiB
TypeScript

import { useCallback } from 'react'
import OLButton from '../../shared/components/ol/ol-button'
import { useIdeRedesignSwitcherContext } from '../ide-react/context/ide-redesign-switcher-context'
import { useTranslation } from 'react-i18next'
import { canUseNewEditorAsExistingUser } from '../ide-redesign/utils/new-editor-utils'
import { useSwitchEnableNewEditorState } from '../ide-redesign/hooks/use-switch-enable-new-editor-state'
const TryNewEditorButton = () => {
const { t } = useTranslation()
const { setShowSwitcherModal } = useIdeRedesignSwitcherContext()
const showModal = canUseNewEditorAsExistingUser()
const { loading, setEditorRedesignStatus } = useSwitchEnableNewEditorState()
const onClick = useCallback(() => {
if (showModal) {
setShowSwitcherModal(true)
} else {
setEditorRedesignStatus(true)
}
}, [setShowSwitcherModal, showModal, setEditorRedesignStatus])
return (
<div className="d-flex align-items-center">
<OLButton
className="toolbar-experiment-button"
onClick={onClick}
size="sm"
variant="secondary"
isLoading={loading}
>
{t('try_the_new_editor')}
</OLButton>
</div>
)
}
export default TryNewEditorButton