sync-menu.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { ElementType } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
  4. import getMeta from '../../../utils/meta'
  5. const components = importOverleafModules('editorLeftMenuSync') as {
  6. import: { default: ElementType }
  7. path: string
  8. }[]
  9. export default function SyncMenu() {
  10. const { t } = useTranslation()
  11. const anonymous = getMeta('ol-anonymous')
  12. const gitBridgeEnabled = getMeta('ol-gitBridgeEnabled')
  13. if (anonymous) {
  14. return null
  15. }
  16. if (components.length === 0) {
  17. return null
  18. }
  19. // This flag can only be false in CE and Server Pro. In this case we skip rendering the
  20. // entire sync section, since Dropbox and GitHub are never available in SP
  21. if (!gitBridgeEnabled) {
  22. return null
  23. }
  24. return (
  25. <>
  26. <h4>{t('sync')}</h4>
  27. <ul className="list-unstyled nav">
  28. {components.map(({ import: { default: Component }, path }) => (
  29. <li key={path}>
  30. <Component />
  31. </li>
  32. ))}
  33. </ul>
  34. </>
  35. )
  36. }