[web] Release editor redesign to Community Edition and Server Pro GitOrigin-RevId: 062779fb418e44a4b245572fab1b4f365585a7f0
33 lines
943 B
TypeScript
33 lines
943 B
TypeScript
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
|
|
|
// For e2e tests purposes, allow overriding to old editor
|
|
export const oldEditorOverride =
|
|
new URLSearchParams(window.location.search).get('old-editor-override') ===
|
|
'true'
|
|
|
|
export const canUseNewEditor = () => {
|
|
return !oldEditorOverride
|
|
}
|
|
|
|
export const useIsNewEditorEnabled = () => {
|
|
const { userSettings } = useUserSettingsContext()
|
|
const noOptOut = useFeatureFlag('editor-redesign-no-opt-out')
|
|
const hasAccess = canUseNewEditor()
|
|
if (!hasAccess) {
|
|
return false
|
|
}
|
|
const enabled = userSettings.enableNewEditor
|
|
if (noOptOut) {
|
|
return true
|
|
}
|
|
return enabled
|
|
}
|
|
|
|
export const useIsNewToNewEditor = () => {
|
|
const { userSettings } = useUserSettingsContext()
|
|
const newEditor = useIsNewEditorEnabled()
|
|
|
|
return newEditor && !userSettings.enableNewEditorLegacy
|
|
}
|