mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
32741c07e0
PDF Detach Safari Warning GitOrigin-RevId: e6f8942d8c8c141d887c44921a09716c4e4c85ae
38 lines
998 B
JavaScript
38 lines
998 B
JavaScript
import { Alert } from 'react-bootstrap'
|
|
import { useTranslation } from 'react-i18next'
|
|
import usePersistedState from '../../../shared/hooks/use-persisted-state'
|
|
|
|
const BROWSER_IS_SAFARI =
|
|
navigator.userAgent &&
|
|
/.*Safari\/.*/.test(navigator.userAgent) &&
|
|
!/.*Chrome\/.*/.test(navigator.userAgent) &&
|
|
!/.*Chromium\/.*/.test(navigator.userAgent)
|
|
|
|
function PdfPreviewDetachedRootSafariWarning() {
|
|
const { t } = useTranslation()
|
|
|
|
const [hidePdfDetachSafariAlert, setHidePdfDetachSafariAlert] =
|
|
usePersistedState('hide-pdf-detach-safari-alert', false, true)
|
|
|
|
function handleDismiss() {
|
|
setHidePdfDetachSafariAlert(true)
|
|
}
|
|
|
|
if (!BROWSER_IS_SAFARI) {
|
|
return null
|
|
}
|
|
|
|
if (hidePdfDetachSafariAlert) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<div className="global-alerts global-alerts-detached">
|
|
<Alert bsStyle="warning" onDismiss={handleDismiss}>
|
|
{t('pdf_detach_safari_issues')}
|
|
</Alert>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default PdfPreviewDetachedRootSafariWarning
|