overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-preview-hybrid-toolbar.js
Timothée Alby f6fc3d468c Merge pull request #5854 from overleaf/ta-pdf-detach-v2
PDF Detach Updates

GitOrigin-RevId: c09c4fe37a922b041cfa1376e110a264a88177c8
2021-12-01 09:03:41 +00:00

58 lines
1.7 KiB
JavaScript

import { memo } from 'react'
import { ButtonToolbar } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import { useLayoutContext } from '../../../shared/context/layout-context'
import PdfCompileButton from './pdf-compile-button'
import PdfExpandButton from './pdf-expand-button'
import PdfHybridLogsButton from './pdf-hybrid-logs-button'
import PdfHybridDownloadButton from './pdf-hybrid-download-button'
import PdfHybridCodeCheckButton from './pdf-hybrid-code-check-button'
import PdfOrphanRefreshButton from './pdf-orphan-refresh-button'
import { DetachedSynctexControl } from './detach-synctex-control'
function PdfPreviewHybridToolbar() {
const { detachRole, detachIsLinked } = useLayoutContext()
const orphanPdfTab = !detachIsLinked && detachRole === 'detached'
return (
<ButtonToolbar className="toolbar toolbar-pdf toolbar-pdf-hybrid">
{orphanPdfTab ? (
<PdfPreviewHybridToolbarOrphanInner />
) : (
<PdfPreviewHybridToolbarInner />
)}
</ButtonToolbar>
)
}
function PdfPreviewHybridToolbarInner() {
return (
<>
<div className="toolbar-pdf-left">
<PdfCompileButton />
<PdfHybridLogsButton />
<PdfHybridDownloadButton />
</div>
<div className="toolbar-pdf-right">
<PdfHybridCodeCheckButton />
{!window.showPdfDetach && <PdfExpandButton />}
<DetachedSynctexControl />
</div>
</>
)
}
function PdfPreviewHybridToolbarOrphanInner() {
const { t } = useTranslation()
return (
<>
<div className="toolbar-pdf-orphan">
{t('tab_no_longer_connected')}
<PdfOrphanRefreshButton />
</div>
</>
)
}
export default memo(PdfPreviewHybridToolbar)