From 351ab1979b33948da8bd6d66dd7cd035986c2674 Mon Sep 17 00:00:00 2001 From: M Fahru Date: Wed, 1 Mar 2023 07:07:53 -0700 Subject: [PATCH] Prevent github menu in project list react to be included in SP/CE build (#11951) GitOrigin-RevId: 58d0378d2307f5c38ea4446b684993aec29fa292 --- services/web/config/settings.defaults.js | 1 + .../components/new-project-button.tsx | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index 52a49b2870..52c5482554 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -786,6 +786,7 @@ module.exports = { integrationLinkingWidgets: [], referenceLinkingWidgets: [], importProjectFromGithubModalWrapper: [], + importProjectFromGithubMenu: [], editorLeftMenuSync: [], }, diff --git a/services/web/frontend/js/features/project-list/components/new-project-button.tsx b/services/web/frontend/js/features/project-list/components/new-project-button.tsx index d31b2e9e6a..22f3109b2b 100644 --- a/services/web/frontend/js/features/project-list/components/new-project-button.tsx +++ b/services/web/frontend/js/features/project-list/components/new-project-button.tsx @@ -1,4 +1,4 @@ -import { useCallback, useState } from 'react' +import { type JSXElementConstructor, useCallback, useState } from 'react' import { Dropdown, MenuItem } from 'react-bootstrap' import { useTranslation } from 'react-i18next' import { ExposedSettings } from '../../../../../types/exposed-settings' @@ -11,6 +11,7 @@ import NewProjectButtonModal, { import AddAffiliation, { useAddAffiliation } from './add-affiliation' import { Nullable } from '../../../../../types/utils' import { sendMB } from '../../../infrastructure/event-tracking' +import importOverleafModules from '../../../../macros/import-overleaf-module.macro' type SendTrackingEvent = { dropdownMenu: string @@ -138,6 +139,14 @@ function NewProjectButton({ [sendTrackingEvent] ) + const [importProjectFromGithubMenu] = importOverleafModules( + 'importProjectFromGithubMenu' + ) + + const ImportProjectFromGithubMenu: JSXElementConstructor<{ + onClick: (e: React.MouseEvent>) => void + }> = importProjectFromGithubMenu?.import.default + return ( <> {t('upload_project')} - handleModalMenuClick(e, { modalVariant: 'import_from_github', dropdownMenuEvent: 'import-from-github', }) } - > - {t('import_from_github')} - + /> {portalTemplates?.length > 0 ? ( <>