[rich-text] Add "rich-text" split test (#11180)

GitOrigin-RevId: 8df79f3c70020c8dba0793c8b548fd1f1e1fbf76
This commit is contained in:
Alf Eaton 2023-01-12 12:52:54 +00:00 committed by Copybot
parent 3a890226cf
commit 017f0b49a0
4 changed files with 30 additions and 9 deletions

View file

@ -1067,6 +1067,21 @@ const ProjectController = {
}
)
},
richTextAssignment(cb) {
SplitTestHandler.getAssignment(
req,
res,
'rich-text',
(error, assignment) => {
// do not fail editor load if assignment fails
if (error) {
cb(null, { variant: 'default' })
} else {
cb(null, assignment)
}
}
)
},
},
(
err,
@ -1083,6 +1098,7 @@ const ProjectController = {
newSourceEditorAssignment,
pdfjsAssignment,
editorLeftMenuAssignment,
richTextAssignment,
}
) => {
if (err != null) {
@ -1266,6 +1282,7 @@ const ProjectController = {
fixedSizeDocument: true,
useOpenTelemetry: Settings.useOpenTelemetryClient,
showCM6SwitchAwaySurvey: Settings.showCM6SwitchAwaySurvey,
richTextVariant: richTextAssignment.variant,
})
timer.done()
}

View file

@ -34,6 +34,7 @@ meta(name="ol-showUpgradePrompt" data-type="boolean" content=showUpgradePrompt)
meta(name="ol-useOpenTelemetry" data-type="boolean" content=useOpenTelemetry)
meta(name="ol-showSupport", data-type="boolean" content=showSupport)
meta(name="ol-showCM6SwitchAwaySurvey", data-type="boolean" content=showCM6SwitchAwaySurvey)
meta(name="ol-richTextVariant" content=richTextVariant)
- var fileActionI18n = ['edited', 'renamed', 'created', 'deleted'].reduce((acc, i) => {acc[i] = translate('file_action_' + i); return acc}, {})
meta(name="ol-fileActionI18n" data-type="json" content=fileActionI18n)

View file

@ -2,8 +2,8 @@ import { memo, useCallback } from 'react'
import useScopeValue from '../../../shared/hooks/use-scope-value'
import Tooltip from '../../../shared/components/tooltip'
import { sendMB } from '../../../infrastructure/event-tracking'
const params = new URLSearchParams(window.location.search)
import getMeta from '../../../utils/meta'
import SplitTestBadge from '../../../shared/components/split-test-badge'
function Badge() {
const content = (
@ -66,7 +66,7 @@ function EditorSwitch() {
break
case 'rich-text':
if (params.has('cm_visual')) {
if (getMeta('ol-richTextVariant') === 'cm6') {
setRichText(false)
setVisual(true)
setNewSourceEditor(true)
@ -74,6 +74,7 @@ function EditorSwitch() {
setRichText(true)
setVisual(false)
}
break
}
@ -131,6 +132,10 @@ function EditorSwitch() {
<span>Rich Text</span>
</label>
</fieldset>
{!!richTextOrVisual && (
<SplitTestBadge splitTestName="rich-text" displayOnVariants={['cm6']} />
)}
</div>
)
}

View file

@ -24,8 +24,6 @@ import './controllers/SwitchToPDFButton'
import getMeta from '../../utils/meta'
import { hasSeenCM6SwitchAwaySurvey } from '../../features/source-editor/utils/switch-away-survey'
const params = new URLSearchParams(window.location.search)
let EditorManager
export default EditorManager = (function () {
@ -168,7 +166,7 @@ export default EditorManager = (function () {
}
showRichText() {
if (params.has('cm_visual')) {
if (getMeta('ol-richTextVariant') === 'cm6') {
return false
}
@ -179,13 +177,13 @@ export default EditorManager = (function () {
}
showVisual() {
if (!params.has('cm_visual')) {
if (getMeta('ol-richTextVariant') !== 'cm6') {
return false
}
return (
this.localStorage(`editor.visual-mode.${this.$scope.project_id}`) ===
'visual'
this.localStorage(`editor.mode.${this.$scope.project_id}`) ===
'rich-text'
)
}