mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
* Merge intermediate component wrappers into OL-prefixed components * Replace all intermediate wrapper consumers with OL-prefixed components directly * Fix jsx/js files still importing deleted shim components * Remove duplicate OLNotification imports left by first pass * Rename OLTagIcon to TagIcon, remove OL prefix * Rename OLDropdownMenuItem to DropdownMenuItem, remove OL prefix * Remove OLNotification, use Notification directly * Move Notification to the main shared component folder * Update tag-icon import path out of ol/ * Move TagIcon to the main shared component folder * Update dropdown-menu-item import path out of ol/ * Move DropdownMenuItem to the main shared component folder * Fix dropdown-menu-item import path to dropdown/ subfolder * Remove BS5 alias prefixes from shared components * Restore notification-list wrapper in Notification component * Add translation for loading button * Remove redundant import aliasing * Resolve conflicts * Restore notification container `notification-list` GitOrigin-RevId: 24a5af18599a3e02ac6fd61c09cf5a49ef6e0020
103 lines
2.7 KiB
TypeScript
103 lines
2.7 KiB
TypeScript
import { useCommandProvider } from '@/features/ide-react/hooks/use-command-provider'
|
|
import DropdownMenuItem from '@/shared/components/dropdown/dropdown-menu-item'
|
|
import OLTooltip from '@/shared/components/ol/ol-tooltip'
|
|
import { isSmallDevice, sendMB } from '@/infrastructure/event-tracking'
|
|
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
|
|
import { useProjectContext } from '@/shared/context/project-context'
|
|
import { useCallback } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
|
|
|
|
export const DownloadProjectZip = () => {
|
|
const { t } = useTranslation()
|
|
const { projectId } = useProjectContext()
|
|
const sendDownloadEvent = useCallback(() => {
|
|
sendMB('download-zip-button-click', {
|
|
projectId,
|
|
location: 'project-name-dropdown',
|
|
isSmallDevice,
|
|
})
|
|
}, [projectId])
|
|
|
|
useCommandProvider(
|
|
() => [
|
|
{
|
|
id: 'download-as-source-zip',
|
|
href: `/project/${projectId}/download/zip`,
|
|
label: t('download_as_source_zip'),
|
|
},
|
|
],
|
|
[t, projectId]
|
|
)
|
|
|
|
return (
|
|
<DropdownMenuItem
|
|
href={`/project/${projectId}/download/zip`}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
onClick={sendDownloadEvent}
|
|
>
|
|
{t('download_as_source_zip')}
|
|
</DropdownMenuItem>
|
|
)
|
|
}
|
|
|
|
export const DownloadProjectPDF = () => {
|
|
const { t } = useTranslation()
|
|
const { pdfDownloadUrl, pdfUrl } = useCompileContext()
|
|
const { projectId } = useProjectContext()
|
|
const { sendEvent } = useEditorAnalytics()
|
|
const sendDownloadEvent = useCallback(() => {
|
|
sendEvent('download-pdf-button-click', {
|
|
projectId,
|
|
location: 'project-name-dropdown',
|
|
isSmallDevice,
|
|
})
|
|
}, [projectId, sendEvent])
|
|
|
|
useCommandProvider(
|
|
() => [
|
|
{
|
|
id: 'download-pdf',
|
|
disabled: !pdfUrl,
|
|
href: pdfDownloadUrl || pdfUrl,
|
|
handler: ({ location }) => {
|
|
sendEvent('download-pdf-button-click', {
|
|
projectId,
|
|
location,
|
|
isSmallDevice,
|
|
})
|
|
},
|
|
label: t('download_as_pdf'),
|
|
},
|
|
],
|
|
[t, pdfUrl, projectId, pdfDownloadUrl, sendEvent]
|
|
)
|
|
|
|
const button = (
|
|
<DropdownMenuItem
|
|
href={pdfDownloadUrl || pdfUrl}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
onClick={sendDownloadEvent}
|
|
disabled={!pdfUrl}
|
|
>
|
|
{t('download_as_pdf')}
|
|
</DropdownMenuItem>
|
|
)
|
|
|
|
if (!pdfUrl) {
|
|
return (
|
|
<OLTooltip
|
|
id="tooltip-download-pdf-unavailable"
|
|
description={t('please_compile_pdf_before_download')}
|
|
overlayProps={{ placement: 'right', delay: 0 }}
|
|
>
|
|
<span>{button}</span>
|
|
</OLTooltip>
|
|
)
|
|
} else {
|
|
return button
|
|
}
|
|
}
|