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

[web] Remove new editor elements for CE/SP (#31004)

* [web] Remove new editor elements for CE/SP

Makes rendering of elements conditional or completely removes them from CE/SP:

- Subscription link is removed from settings modal
- Documentation link is present on `proxyLearn === true`
- Contact us link is present when `support` module is available (not the case for CE/SP)

* Using hidden instead of conditional rendering in settings

GitOrigin-RevId: 562563d0bc4d0ca919e336f0c13cf6b476c6cf31
Miguel Serrano 8 месяцев назад
Родитель
Сommit
860f77a06c

+ 17 - 12
services/web/frontend/js/features/ide-react/components/rail/rail-help-dropdown.tsx

@@ -10,6 +10,7 @@ import {
 
 export default function RailHelpDropdown() {
   const showSupport = getMeta('ol-showSupport')
+  const showDocumentation = getMeta('ol-wikiEnabled')
   const { t } = useTranslation()
   const { setActiveModal } = useRailContext()
   const openKeyboardShortcutsModal = useCallback(() => {
@@ -24,20 +25,24 @@ export default function RailHelpDropdown() {
       <DropdownItem onClick={openKeyboardShortcutsModal}>
         {t('keyboard_shortcuts')}
       </DropdownItem>
-      <DropdownItem
-        href="/learn"
-        role="menuitem"
-        target="_blank"
-        rel="noopener noreferrer"
-      >
-        {t('documentation')}
-      </DropdownItem>
-      <DropdownDivider />
-      {showSupport && (
-        <DropdownItem onClick={openContactUsModal}>
-          {t('contact_us')}
+      {showDocumentation && (
+        <DropdownItem
+          href="/learn"
+          role="menuitem"
+          target="_blank"
+          rel="noopener noreferrer"
+        >
+          {t('documentation')}
         </DropdownItem>
       )}
+      {showSupport && (
+        <>
+          <DropdownDivider />
+          <DropdownItem onClick={openContactUsModal}>
+            {t('contact_us')}
+          </DropdownItem>
+        </>
+      )}
     </DropdownMenu>
   )
 }

+ 21 - 13
services/web/frontend/js/features/ide-react/components/toolbar/menu-bar.tsx

@@ -43,6 +43,8 @@ export const ToolbarMenuBar = () => {
   const openProject = useOpenProject()
 
   const anonymous = getMeta('ol-anonymous')
+  const showSupport = getMeta('ol-showSupport')
+  const showDocumentation = getMeta('ol-wikiEnabled')
 
   useCommandProvider(
     () => [
@@ -266,19 +268,25 @@ export const ToolbarMenuBar = () => {
             title={t('keyboard_shortcuts')}
             onClick={openKeyboardShortcutsModal}
           />
-          <MenuBarOption
-            title={t('documentation')}
-            eventKey="documentation"
-            href="/learn"
-            target="_blank"
-            rel="noopener noreferrer"
-          />
-          <DropdownDivider />
-          <MenuBarOption
-            eventKey="contact_us"
-            title={t('contact_us')}
-            onClick={openContactUsModal}
-          />
+          {showDocumentation && (
+            <MenuBarOption
+              title={t('documentation')}
+              eventKey="documentation"
+              href="/learn"
+              target="_blank"
+              rel="noopener noreferrer"
+            />
+          )}
+          {showSupport && (
+            <>
+              <DropdownDivider />
+              <MenuBarOption
+                eventKey="contact_us"
+                title={t('contact_us')}
+                onClick={openContactUsModal}
+              />
+            </>
+          )}
         </MenuBarDropdown>
       </MenuBar>
       <WordCountModal

+ 4 - 1
services/web/frontend/js/features/ide-redesign/contexts/settings-modal-context.tsx

@@ -28,6 +28,7 @@ import DarkModePdfSetting from '../components/settings/appearance-settings/dark-
 import { useProjectSettingsContext } from '@/features/editor-left-menu/context/project-settings-context'
 import { useFeatureFlag } from '@/shared/context/split-test-context'
 import ProjectNotificationsSetting from '../components/settings/editor-settings/project-notifications-setting'
+import getMeta from '@/utils/meta'
 
 const [referenceSearchSettingModule] = importOverleafModules(
   'referenceSearchSetting'
@@ -81,6 +82,7 @@ export const SettingsModalProvider: FC<React.PropsWithChildren> = ({
   children,
 }) => {
   const { t } = useTranslation()
+  const { isOverleaf } = getMeta('ol-ExposedSettings')
   const { overallTheme } = useProjectSettingsContext()
 
   // TODO ide-redesign-cleanup: Rename this field and move it directly into this context
@@ -258,9 +260,10 @@ export const SettingsModalProvider: FC<React.PropsWithChildren> = ({
         title: t('subscription'),
         icon: 'account_balance',
         href: '/user/subscription',
+        hidden: !isOverleaf,
       },
     ],
-    [t, overallTheme, hasEmailNotifications]
+    [t, overallTheme, hasEmailNotifications, isOverleaf]
   )
 
   const settingsTabs = useMemo(