2023-10-04 15:36:34 -04:00
|
|
|
import type { ElementType } from 'react'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
|
2023-10-25 14:18:37 -04:00
|
|
|
import { BinaryFile } from '../types/binary-file'
|
2024-10-10 03:38:28 -04:00
|
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
2023-10-04 15:36:34 -04:00
|
|
|
|
|
|
|
type FileViewRefreshErrorProps = {
|
|
|
|
file: BinaryFile
|
|
|
|
refreshError: string
|
|
|
|
}
|
|
|
|
|
2023-10-25 14:18:37 -04:00
|
|
|
const tprFileViewRefreshError = importOverleafModules(
|
|
|
|
'tprFileViewRefreshError'
|
|
|
|
) as {
|
|
|
|
import: { TPRFileViewRefreshError: ElementType }
|
|
|
|
path: string
|
|
|
|
}[]
|
|
|
|
|
2023-10-04 15:36:34 -04:00
|
|
|
export default function FileViewRefreshError({
|
|
|
|
file,
|
|
|
|
refreshError,
|
|
|
|
}: FileViewRefreshErrorProps) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
2023-10-25 14:18:37 -04:00
|
|
|
if (tprFileViewRefreshError.length > 0) {
|
|
|
|
return tprFileViewRefreshError.map(
|
|
|
|
({ import: { TPRFileViewRefreshError }, path }) => (
|
|
|
|
<TPRFileViewRefreshError
|
|
|
|
key={path}
|
|
|
|
file={file}
|
|
|
|
refreshError={refreshError}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)[0]
|
|
|
|
} else {
|
|
|
|
return (
|
2024-10-10 03:38:28 -04:00
|
|
|
<div className="file-view-error">
|
|
|
|
<OLNotification
|
|
|
|
type="error"
|
|
|
|
content={
|
|
|
|
<span>
|
|
|
|
{t('access_denied')}: {refreshError}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
/>
|
2023-10-25 14:18:37 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2023-10-04 15:36:34 -04:00
|
|
|
}
|