mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
Fix: hide Git Bridge, GitHub Sync and Zotero UI elements when the corresponding feature is disabled
This commit is contained in:
@@ -417,6 +417,8 @@ export default async function (webRouter, privateApiRouter, publicApiRouter) {
|
||||
cioWriteKey: Settings.analytics?.cio?.writeKey,
|
||||
cioSiteId: Settings.analytics?.cio?.siteId,
|
||||
linkedInInsightsPartnerId: Settings.analytics?.linkedIn?.partnerId,
|
||||
githubSyncEnabled: !!Settings.githubSync?.clientID && !!Settings.githubSync?.clientSecret,
|
||||
zoteroEnabled: !!Settings.zotero?.clientKey && !!Settings.zotero?.clientSecret,
|
||||
enablePandocConversions: Settings.enablePandocConversions,
|
||||
mixpanelLabsToken:
|
||||
Settings.labs?.enable && Settings.analytics?.mixpanel?.labsToken,
|
||||
|
||||
+6
-1
@@ -13,11 +13,16 @@ import { FullSizeLoadingSpinner } from '@/shared/components/loading-spinner'
|
||||
import getMeta from '@/utils/meta'
|
||||
import OLNotification from '@/shared/components/ol/ol-notification'
|
||||
|
||||
const createFileModeModules = importOverleafModules('createFileModes') as {
|
||||
const allCreateFileModeModules = importOverleafModules('createFileModes') as {
|
||||
import: { CreateFilePane: ElementType; CreateFileMode: ElementType }
|
||||
path: string
|
||||
}[]
|
||||
|
||||
const createFileModeModules = allCreateFileModeModules.filter(
|
||||
({ path }) =>
|
||||
(getMeta('ol-ExposedSettings').zoteroEnabled || !path.includes('zotero-create-file'))
|
||||
)
|
||||
|
||||
const FileTreeUploadDoc = lazy(() => import('./modes/file-tree-upload-doc'))
|
||||
|
||||
export default function FileTreeModalCreateFileBody() {
|
||||
|
||||
@@ -71,7 +71,7 @@ export const RailLayout = () => {
|
||||
const { features } = useProjectContext()
|
||||
const { isRestrictedTokenMember } = useEditorContext()
|
||||
const gitBridgeEnabled = getMeta('ol-gitBridgeEnabled')
|
||||
const { isOverleaf } = getMeta('ol-ExposedSettings')
|
||||
const { isOverleaf, githubSyncEnabled, zoteroEnabled } = getMeta('ol-ExposedSettings')
|
||||
|
||||
const { view, setLeftMenuShown, focusMode } = useLayoutContext()
|
||||
|
||||
@@ -119,7 +119,7 @@ export const RailLayout = () => {
|
||||
icon: 'integration_instructions',
|
||||
title: t('integrations'),
|
||||
component: <IntegrationsPanel />,
|
||||
hide: !isOverleaf && !gitBridgeEnabled,
|
||||
hide: !isOverleaf && !gitBridgeEnabled && !githubSyncEnabled && !zoteroEnabled,
|
||||
},
|
||||
{
|
||||
key: 'review-panel',
|
||||
@@ -148,6 +148,8 @@ export const RailLayout = () => {
|
||||
isRestrictedTokenMember,
|
||||
isOverleaf,
|
||||
gitBridgeEnabled,
|
||||
githubSyncEnabled,
|
||||
zoteroEnabled,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -2,11 +2,19 @@ import { ElementType } from 'react'
|
||||
import importOverleafModules from '../../../macros/import-overleaf-module.macro'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import RailPanelHeader from '@/features/ide-react/components/rail/rail-panel-header'
|
||||
import getMeta from '../../utils/meta'
|
||||
|
||||
const integrationPanelComponents = importOverleafModules(
|
||||
const allIntegrationPanelComponents = importOverleafModules(
|
||||
'integrationPanelComponents'
|
||||
) as { import: { default: ElementType }; path: string }[]
|
||||
|
||||
const integrationPanelComponents = allIntegrationPanelComponents.filter(
|
||||
({ path }) =>
|
||||
(getMeta('ol-gitBridgeEnabled') || !path.includes('git-bridge')) &&
|
||||
(getMeta('ol-ExposedSettings').githubSyncEnabled || !path.includes('github-sync')) &&
|
||||
(getMeta('ol-ExposedSettings').zoteroEnabled || !path.includes('zotero'))
|
||||
)
|
||||
|
||||
export default function IntegrationsPanel() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ function NewProjectButton({
|
||||
align,
|
||||
}: NewProjectButtonProps) {
|
||||
const { t } = useTranslation()
|
||||
const { templateLinks } = getMeta('ol-ExposedSettings')
|
||||
const { templateLinks, githubSyncEnabled } = getMeta('ol-ExposedSettings')
|
||||
const [modal, setModal] =
|
||||
useState<Nullable<NewProjectButtonModalVariant>>(null)
|
||||
const portalTemplates = getMeta('ol-portalTemplates') || []
|
||||
@@ -166,7 +166,7 @@ function NewProjectButton({
|
||||
[sendProjectListMB, sendTrackingEvent]
|
||||
)
|
||||
|
||||
const [importProjectFromGithubMenu] = importOverleafModules(
|
||||
const [importProjectFromGithubMenu] = !githubSyncEnabled ? [] : importOverleafModules(
|
||||
'importProjectFromGithubMenu'
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@ function WelcomeMessageCreateNewProjectDropdown({
|
||||
useFeatureFlag('import-markdown') &&
|
||||
getMeta('ol-ExposedSettings').enablePandocConversions
|
||||
|
||||
const { isOverleaf } = getMeta('ol-ExposedSettings')
|
||||
const { isOverleaf, githubSyncEnabled } = getMeta('ol-ExposedSettings')
|
||||
|
||||
const handleDropdownItemClick = useCallback(
|
||||
(
|
||||
@@ -170,7 +170,7 @@ function WelcomeMessageCreateNewProjectDropdown({
|
||||
</DropdownItem>
|
||||
</li>
|
||||
)}
|
||||
{isOverleaf && (
|
||||
{(isOverleaf || githubSyncEnabled) && (
|
||||
<li role="none">
|
||||
<DropdownItem
|
||||
as="button"
|
||||
|
||||
@@ -7,7 +7,7 @@ import getMeta from '../../../utils/meta'
|
||||
import { useBroadcastUser } from '@/shared/hooks/user-channel/use-broadcast-user'
|
||||
import OLNotification from '@/shared/components/ol/ol-notification'
|
||||
|
||||
const availableIntegrationLinkingWidgets = importOverleafModules(
|
||||
const allAvailableIntegrationLinkingWidgets = importOverleafModules(
|
||||
'integrationLinkingWidgets'
|
||||
) as any[]
|
||||
const availableReferenceLinkingWidgets = importOverleafModules(
|
||||
@@ -17,6 +17,15 @@ const availableLangFeedbackLinkingWidgets = importOverleafModules(
|
||||
'langFeedbackLinkingWidgets'
|
||||
) as any[]
|
||||
|
||||
const gitBridgeEnabled = getMeta('ol-gitBridgeEnabled')
|
||||
const githubSyncEnabled = getMeta('ol-ExposedSettings').githubSyncEnabled
|
||||
const zoteroEnabled = getMeta('ol-ExposedSettings').zoteroEnabled
|
||||
|
||||
const availableIntegrationLinkingWidgets = allAvailableIntegrationLinkingWidgets.filter(
|
||||
({ path }) =>
|
||||
(githubSyncEnabled || !path.includes('github-sync'))
|
||||
)
|
||||
|
||||
function LinkingSection() {
|
||||
useBroadcastUser()
|
||||
const { t } = useTranslation()
|
||||
@@ -29,20 +38,20 @@ function LinkingSection() {
|
||||
const integrationLinkingWidgets = getMeta('ol-hideLinkingWidgets')
|
||||
? []
|
||||
: availableIntegrationLinkingWidgets
|
||||
const referenceLinkingWidgets = getMeta('ol-hideLinkingWidgets')
|
||||
const referenceLinkingWidgets = getMeta('ol-hideLinkingWidgets') || !zoteroEnabled
|
||||
? []
|
||||
: availableReferenceLinkingWidgets
|
||||
const langFeedbackLinkingWidgets = getMeta('ol-hideLinkingWidgets')
|
||||
? []
|
||||
: availableLangFeedbackLinkingWidgets
|
||||
|
||||
const oauth2ServerComponents = importOverleafModules('oauth2Server') as {
|
||||
const oauth2ServerComponents = !gitBridgeEnabled ? [] : importOverleafModules('oauth2Server') as {
|
||||
import: { default: ElementType }
|
||||
path: string
|
||||
}[]
|
||||
|
||||
const renderSyncSection =
|
||||
getMeta('ol-isSaas') || getMeta('ol-gitBridgeEnabled')
|
||||
getMeta('ol-isSaas') || gitBridgeEnabled || githubSyncEnabled
|
||||
|
||||
const allIntegrationLinkingWidgets = integrationLinkingWidgets.concat(
|
||||
oauth2ServerComponents
|
||||
|
||||
@@ -52,5 +52,7 @@ export type ExposedSettings = {
|
||||
wikiEnabled?: boolean
|
||||
templatesEnabled?: boolean
|
||||
linkedInInsightsPartnerId?: string
|
||||
githubSyncEnabled: boolean
|
||||
zoteroEnabled: boolean
|
||||
enablePandocConversions: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user