Просмотр исходного кода

[web] Move ARS Write and Cite behind separate feature flag (#20631)

* [web] Move ARS Write and Cite behind separate feature flag

* [web] Use isSplitTestEnabled function

* [web] Only load Write and Cite if project has ARS access

* [web] Enable Write and Cite ARS by default

* [web] Fix condition for loading write and cite ref sources

* [web] Remove references settings button in free projects

GitOrigin-RevId: c4f3b7c60da9864409c788dcf34bdc77347441a8
Mathias Jakobsen 2 лет назад
Родитель
Сommit
aba4694377

+ 1 - 0
services/web/app/src/Features/Project/ProjectController.js

@@ -339,6 +339,7 @@ const _ProjectController = {
       !anonymous && 'writefull-oauth-promotion',
       'ieee-stylesheet',
       'write-and-cite',
+      'write-and-cite-ars',
       'default-visual-for-beginners',
       'spell-check-client',
     ].filter(Boolean)

+ 5 - 4
services/web/frontend/js/features/source-editor/extensions/index.ts

@@ -54,9 +54,10 @@ import { ranges } from './ranges'
 import { trackDetachedComments } from './track-detached-comments'
 import { addComment } from './add-comment'
 
-const moduleExtensions: Array<() => Extension> = importOverleafModules(
-  'sourceEditorExtensions'
-).map((item: { import: { extension: Extension } }) => item.import.extension)
+const moduleExtensions: Array<(options: Record<string, any>) => Extension> =
+  importOverleafModules('sourceEditorExtensions').map(
+    (item: { import: { extension: Extension } }) => item.import.extension
+  )
 
 export const createExtensions = (options: Record<string, any>): Extension[] => [
   lineNumbers(),
@@ -145,7 +146,7 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
   // Send exceptions to Sentry
   EditorView.exceptionSink.of(options.handleException),
   // CodeMirror extensions provided by modules
-  moduleExtensions.map(extension => extension()),
+  moduleExtensions.map(extension => extension(options)),
   thirdPartyExtensions(),
   effectListeners(),
   geometryChangeEvent(),

+ 4 - 0
services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts

@@ -111,6 +111,7 @@ function useCodeMirrorScope(view: EditorView) {
   const [spellCheckLanguage] = useScopeValue<string>(
     'project.spellCheckLanguage'
   )
+  const [projectFeatures] = useScopeValue<boolean>('project.features')
 
   const hunspellManager = useHunspell(spellCheckLanguage)
 
@@ -228,6 +229,8 @@ function useCodeMirrorScope(view: EditorView) {
     view.dispatch(setSpellCheckLanguage(spellingRef.current))
   }, [view, spellCheckLanguage, hunspellManager])
 
+  const projectFeaturesRef = useRef(projectFeatures)
+
   // listen to doc:after-opened, and focus the editor if it's not a new doc
   useEffect(() => {
     const listener: EventListener = event => {
@@ -326,6 +329,7 @@ function useCodeMirrorScope(view: EditorView) {
           phrases: phrasesRef.current,
           spelling: spellingRef.current,
           visual: visualRef.current,
+          projectFeatures: projectFeaturesRef.current,
           changeManager: createChangeManager(view, currentDoc),
           handleError,
           handleException,