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