diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index e69c2f26de..94a767bbd1 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -981,16 +981,15 @@ const ProjectController = { } ) }, - newSourceEditorAssignment(cb) { + legacySourceEditorAssignment(cb) { SplitTestHandler.getAssignment( req, res, - 'source-editor', - {}, + 'source-editor-legacy', (error, assignment) => { // do not fail editor load if assignment fails if (error) { - cb(null) + cb(null, { variant: 'default' }) } else { cb(null, assignment) } @@ -1159,7 +1158,7 @@ const ProjectController = { isTokenMember, isInvitedMember, brandVariation, - newSourceEditorAssignment, + legacySourceEditorAssignment, pdfjsAssignment, editorLeftMenuAssignment, richTextAssignment, @@ -1239,10 +1238,10 @@ const ProjectController = { const detachRole = req.params.detachRole - const showNewSourceEditorOption = - newSourceEditorAssignment?.variant === 'codemirror' || - user.betaProgram || - shouldDisplayFeature('new_source_editor', false) // also allow override via ?new_source_editor=true + const showLegacySourceEditor = + legacySourceEditorAssignment.variant === 'default' || + // Also allow override via legacy_source_editor=true in query string + shouldDisplayFeature('legacy_source_editor') const editorLeftMenuReact = editorLeftMenuAssignment?.variant === 'react' @@ -1335,7 +1334,7 @@ const ProjectController = { showSupport: Features.hasFeature('support'), pdfjsVariant: pdfjsAssignment.variant, debugPdfDetach, - showNewSourceEditorOption, + showLegacySourceEditor, showSymbolPalette, galileoEnabled, galileoFeatures, diff --git a/services/web/app/views/project/editor/meta.pug b/services/web/app/views/project/editor/meta.pug index 95cc1c43a4..de64035241 100644 --- a/services/web/app/views/project/editor/meta.pug +++ b/services/web/app/views/project/editor/meta.pug @@ -22,7 +22,7 @@ meta(name="ol-useShareJsHash" data-type="boolean" content=true) meta(name="ol-wsRetryHandshake" data-type="json" content=settings.wsRetryHandshake) meta(name="ol-pdfjsVariant" content=pdfjsVariant) meta(name="ol-debugPdfDetach" data-type="boolean" content=debugPdfDetach) -meta(name="ol-showNewSourceEditorOption" data-type="boolean" content=showNewSourceEditorOption) +meta(name="ol-showLegacySourceEditor", data-type="boolean" content=showLegacySourceEditor) meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette) meta(name="ol-galileoEnabled" data-type="string" content=galileoEnabled) meta(name="ol-galileoPromptWords" data-type="string" content=galileoPromptWords) diff --git a/services/web/frontend/js/features/source-editor/components/cm6-switch-away-survey.tsx b/services/web/frontend/js/features/source-editor/components/cm6-switch-away-survey.tsx index 67a44a6599..170035f308 100644 --- a/services/web/frontend/js/features/source-editor/components/cm6-switch-away-survey.tsx +++ b/services/web/frontend/js/features/source-editor/components/cm6-switch-away-survey.tsx @@ -1,7 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { Button } from 'react-bootstrap' import useScopeValue from '../../../shared/hooks/use-scope-value' -import getMeta from '../../../utils/meta' import { hasSeenCM6SwitchAwaySurvey, setHasSeenCM6SwitchAwaySurvey, @@ -17,11 +16,6 @@ export default function CM6SwitchAwaySurvey() { const initialRichTextPreference = useRef(richText) useEffect(() => { - // If cm6 is not available, don't show the survey - if (!getMeta('ol-showNewSourceEditorOption')) { - return - } - // If the user has previously seen any switch-away survey, then don't show // the current one if (hasSeenCM6SwitchAwaySurvey()) return diff --git a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx index dadd34da6c..1c007b83b4 100644 --- a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx +++ b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx @@ -38,6 +38,8 @@ function Badge() { ) } +const showLegacySourceEditor: boolean = getMeta('ol-showLegacySourceEditor') + function EditorSwitch() { const [newSourceEditor, setNewSourceEditor] = useScopeValue( 'editor.newSourceEditor' @@ -103,18 +105,22 @@ function EditorSwitch() { Source - - + {showLegacySourceEditor ? ( + <> + + + + ) : null} { diff --git a/services/web/test/frontend/features/source-editor/components/grammarly-warning.test.js b/services/web/test/frontend/features/source-editor/components/grammarly-warning.test.js index ff9a5c7f42..69207b53f3 100644 --- a/services/web/test/frontend/features/source-editor/components/grammarly-warning.test.js +++ b/services/web/test/frontend/features/source-editor/components/grammarly-warning.test.js @@ -27,7 +27,6 @@ describe('', function () { it('shows warning when grammarly is available', async function () { grammarlyStub.returns(true) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', true) renderWithEditorContext(, { scope: { @@ -46,7 +45,6 @@ describe('', function () { it('does not show warning when grammarly is not available', async function () { grammarlyStub.returns(false) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', true) renderWithEditorContext(, { scope: { @@ -68,7 +66,6 @@ describe('', function () { it('does not show warning when user has dismissed the warning', async function () { grammarlyStub.returns(true) localStorage.setItem('editor.has_dismissed_grammarly_warning', true) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', true) renderWithEditorContext(, { scope: { @@ -87,24 +84,8 @@ describe('', function () { }) }) - it('does not show warning when user does not have CM6', async function () { - grammarlyStub.returns(true) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', false) - - renderWithEditorContext() - - await waitFor(() => { - expect( - screen.queryByText( - 'A browser extension, for example Grammarly, may be slowing down Overleaf.' - ) - ).to.not.exist - }) - }) - it('does not show warning when user have ace as their preference', async function () { grammarlyStub.returns(true) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', true) renderWithEditorContext(, { scope: { @@ -125,7 +106,6 @@ describe('', function () { it('does not show warning when user have rich text as their preference', async function () { grammarlyStub.returns(true) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', true) renderWithEditorContext(, { scope: { @@ -147,7 +127,6 @@ describe('', function () { it('hides warning if close button is pressed', async function () { grammarlyStub.returns(true) - window.metaAttributesCache.set('ol-showNewSourceEditorOption', true) renderWithEditorContext(, { scope: {