mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #11332 from overleaf/td-remove-ace-split-test
Add handling for source-editor-legacy split test GitOrigin-RevId: 9575087c34bc3f2e8b490846984bc97641c560aa
This commit is contained in:
parent
c59b28d315
commit
a05438d9c7
7 changed files with 31 additions and 58 deletions
|
@ -981,16 +981,15 @@ const ProjectController = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
newSourceEditorAssignment(cb) {
|
legacySourceEditorAssignment(cb) {
|
||||||
SplitTestHandler.getAssignment(
|
SplitTestHandler.getAssignment(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
'source-editor',
|
'source-editor-legacy',
|
||||||
{},
|
|
||||||
(error, assignment) => {
|
(error, assignment) => {
|
||||||
// do not fail editor load if assignment fails
|
// do not fail editor load if assignment fails
|
||||||
if (error) {
|
if (error) {
|
||||||
cb(null)
|
cb(null, { variant: 'default' })
|
||||||
} else {
|
} else {
|
||||||
cb(null, assignment)
|
cb(null, assignment)
|
||||||
}
|
}
|
||||||
|
@ -1159,7 +1158,7 @@ const ProjectController = {
|
||||||
isTokenMember,
|
isTokenMember,
|
||||||
isInvitedMember,
|
isInvitedMember,
|
||||||
brandVariation,
|
brandVariation,
|
||||||
newSourceEditorAssignment,
|
legacySourceEditorAssignment,
|
||||||
pdfjsAssignment,
|
pdfjsAssignment,
|
||||||
editorLeftMenuAssignment,
|
editorLeftMenuAssignment,
|
||||||
richTextAssignment,
|
richTextAssignment,
|
||||||
|
@ -1239,10 +1238,10 @@ const ProjectController = {
|
||||||
|
|
||||||
const detachRole = req.params.detachRole
|
const detachRole = req.params.detachRole
|
||||||
|
|
||||||
const showNewSourceEditorOption =
|
const showLegacySourceEditor =
|
||||||
newSourceEditorAssignment?.variant === 'codemirror' ||
|
legacySourceEditorAssignment.variant === 'default' ||
|
||||||
user.betaProgram ||
|
// Also allow override via legacy_source_editor=true in query string
|
||||||
shouldDisplayFeature('new_source_editor', false) // also allow override via ?new_source_editor=true
|
shouldDisplayFeature('legacy_source_editor')
|
||||||
|
|
||||||
const editorLeftMenuReact =
|
const editorLeftMenuReact =
|
||||||
editorLeftMenuAssignment?.variant === 'react'
|
editorLeftMenuAssignment?.variant === 'react'
|
||||||
|
@ -1335,7 +1334,7 @@ const ProjectController = {
|
||||||
showSupport: Features.hasFeature('support'),
|
showSupport: Features.hasFeature('support'),
|
||||||
pdfjsVariant: pdfjsAssignment.variant,
|
pdfjsVariant: pdfjsAssignment.variant,
|
||||||
debugPdfDetach,
|
debugPdfDetach,
|
||||||
showNewSourceEditorOption,
|
showLegacySourceEditor,
|
||||||
showSymbolPalette,
|
showSymbolPalette,
|
||||||
galileoEnabled,
|
galileoEnabled,
|
||||||
galileoFeatures,
|
galileoFeatures,
|
||||||
|
|
|
@ -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-wsRetryHandshake" data-type="json" content=settings.wsRetryHandshake)
|
||||||
meta(name="ol-pdfjsVariant" content=pdfjsVariant)
|
meta(name="ol-pdfjsVariant" content=pdfjsVariant)
|
||||||
meta(name="ol-debugPdfDetach" data-type="boolean" content=debugPdfDetach)
|
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-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
|
||||||
meta(name="ol-galileoEnabled" data-type="string" content=galileoEnabled)
|
meta(name="ol-galileoEnabled" data-type="string" content=galileoEnabled)
|
||||||
meta(name="ol-galileoPromptWords" data-type="string" content=galileoPromptWords)
|
meta(name="ol-galileoPromptWords" data-type="string" content=galileoPromptWords)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { Button } from 'react-bootstrap'
|
import { Button } from 'react-bootstrap'
|
||||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||||
import getMeta from '../../../utils/meta'
|
|
||||||
import {
|
import {
|
||||||
hasSeenCM6SwitchAwaySurvey,
|
hasSeenCM6SwitchAwaySurvey,
|
||||||
setHasSeenCM6SwitchAwaySurvey,
|
setHasSeenCM6SwitchAwaySurvey,
|
||||||
|
@ -17,11 +16,6 @@ export default function CM6SwitchAwaySurvey() {
|
||||||
const initialRichTextPreference = useRef<boolean>(richText)
|
const initialRichTextPreference = useRef<boolean>(richText)
|
||||||
|
|
||||||
useEffect(() => {
|
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
|
// If the user has previously seen any switch-away survey, then don't show
|
||||||
// the current one
|
// the current one
|
||||||
if (hasSeenCM6SwitchAwaySurvey()) return
|
if (hasSeenCM6SwitchAwaySurvey()) return
|
||||||
|
|
|
@ -38,6 +38,8 @@ function Badge() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showLegacySourceEditor: boolean = getMeta('ol-showLegacySourceEditor')
|
||||||
|
|
||||||
function EditorSwitch() {
|
function EditorSwitch() {
|
||||||
const [newSourceEditor, setNewSourceEditor] = useScopeValue(
|
const [newSourceEditor, setNewSourceEditor] = useScopeValue(
|
||||||
'editor.newSourceEditor'
|
'editor.newSourceEditor'
|
||||||
|
@ -103,18 +105,22 @@ function EditorSwitch() {
|
||||||
<span>Source</span>
|
<span>Source</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input
|
{showLegacySourceEditor ? (
|
||||||
type="radio"
|
<>
|
||||||
name="editor"
|
<input
|
||||||
value="ace"
|
type="radio"
|
||||||
id="editor-switch-ace"
|
name="editor"
|
||||||
className="toggle-switch-input"
|
value="ace"
|
||||||
checked={!richTextOrVisual && !newSourceEditor}
|
id="editor-switch-ace"
|
||||||
onChange={handleChange}
|
className="toggle-switch-input"
|
||||||
/>
|
checked={!richTextOrVisual && !newSourceEditor}
|
||||||
<label htmlFor="editor-switch-ace" className="toggle-switch-label">
|
onChange={handleChange}
|
||||||
<span>Source (legacy)</span>
|
/>
|
||||||
</label>
|
<label htmlFor="editor-switch-ace" className="toggle-switch-label">
|
||||||
|
<span>Source (legacy)</span>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { Nullable } from '../../../../../types/utils'
|
||||||
import customLocalStorage from '../../../infrastructure/local-storage'
|
import customLocalStorage from '../../../infrastructure/local-storage'
|
||||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||||
import grammarlyExtensionPresent from '../../../shared/utils/grammarly'
|
import grammarlyExtensionPresent from '../../../shared/utils/grammarly'
|
||||||
import getMeta from '../../../utils/meta'
|
|
||||||
|
|
||||||
type GrammarlyWarningProps = {
|
type GrammarlyWarningProps = {
|
||||||
delay: number
|
delay: number
|
||||||
|
@ -55,10 +54,6 @@ export default function GrammarlyWarning({ delay }: GrammarlyWarningProps) {
|
||||||
customLocalStorage.setItem('editor.has_dismissed_grammarly_warning', true)
|
customLocalStorage.setItem('editor.has_dismissed_grammarly_warning', true)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (!getMeta('ol-showNewSourceEditorOption')) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!show) {
|
if (!show) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,9 +195,9 @@ export default EditorManager = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
newSourceEditor() {
|
newSourceEditor() {
|
||||||
// only use the new source editor if the option to switch is available
|
// Use the new source editor if the legacy editor is disabled
|
||||||
if (!getMeta('ol-showNewSourceEditorOption')) {
|
if (!getMeta('ol-showLegacySourceEditor')) {
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const storedPrefIsCM6 = () => {
|
const storedPrefIsCM6 = () => {
|
||||||
|
|
|
@ -27,7 +27,6 @@ describe('<GrammarlyWarning />', function () {
|
||||||
|
|
||||||
it('shows warning when grammarly is available', async function () {
|
it('shows warning when grammarly is available', async function () {
|
||||||
grammarlyStub.returns(true)
|
grammarlyStub.returns(true)
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', true)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -46,7 +45,6 @@ describe('<GrammarlyWarning />', function () {
|
||||||
|
|
||||||
it('does not show warning when grammarly is not available', async function () {
|
it('does not show warning when grammarly is not available', async function () {
|
||||||
grammarlyStub.returns(false)
|
grammarlyStub.returns(false)
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', true)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -68,7 +66,6 @@ describe('<GrammarlyWarning />', function () {
|
||||||
it('does not show warning when user has dismissed the warning', async function () {
|
it('does not show warning when user has dismissed the warning', async function () {
|
||||||
grammarlyStub.returns(true)
|
grammarlyStub.returns(true)
|
||||||
localStorage.setItem('editor.has_dismissed_grammarly_warning', true)
|
localStorage.setItem('editor.has_dismissed_grammarly_warning', true)
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', true)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -87,24 +84,8 @@ describe('<GrammarlyWarning />', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not show warning when user does not have CM6', async function () {
|
|
||||||
grammarlyStub.returns(true)
|
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', false)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />)
|
|
||||||
|
|
||||||
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 () {
|
it('does not show warning when user have ace as their preference', async function () {
|
||||||
grammarlyStub.returns(true)
|
grammarlyStub.returns(true)
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', true)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -125,7 +106,6 @@ describe('<GrammarlyWarning />', function () {
|
||||||
|
|
||||||
it('does not show warning when user have rich text as their preference', async function () {
|
it('does not show warning when user have rich text as their preference', async function () {
|
||||||
grammarlyStub.returns(true)
|
grammarlyStub.returns(true)
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', true)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -147,7 +127,6 @@ describe('<GrammarlyWarning />', function () {
|
||||||
|
|
||||||
it('hides warning if close button is pressed', async function () {
|
it('hides warning if close button is pressed', async function () {
|
||||||
grammarlyStub.returns(true)
|
grammarlyStub.returns(true)
|
||||||
window.metaAttributesCache.set('ol-showNewSourceEditorOption', true)
|
|
||||||
|
|
||||||
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
renderWithEditorContext(<GrammarlyWarning delay={100} />, {
|
||||||
scope: {
|
scope: {
|
||||||
|
|
Loading…
Reference in a new issue