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
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { useEffect, useState } from 'react'
|
|
import { secondsUntil } from '@/features/ide-react/connection/utils'
|
|
import Notification from '@/shared/components/notification'
|
|
import OLButton from '@/shared/components/ol/ol-button'
|
|
|
|
type LostConnectionAlertProps = {
|
|
reconnectAt: number
|
|
tryReconnectNow: () => void
|
|
}
|
|
|
|
export function LostConnectionAlert({
|
|
reconnectAt,
|
|
tryReconnectNow,
|
|
}: LostConnectionAlertProps) {
|
|
const { t } = useTranslation()
|
|
const [secondsUntilReconnect, setSecondsUntilReconnect] = useState(
|
|
secondsUntil(reconnectAt)
|
|
)
|
|
|
|
useEffect(() => {
|
|
const timer = window.setInterval(() => {
|
|
setSecondsUntilReconnect(secondsUntil(reconnectAt))
|
|
}, 1000)
|
|
return () => window.clearInterval(timer)
|
|
}, [reconnectAt])
|
|
|
|
return (
|
|
<div className="notification-list">
|
|
<Notification
|
|
type="warning"
|
|
content={
|
|
<>
|
|
<strong>{t('lost_connection')}</strong>{' '}
|
|
{t('reconnecting_in_x_secs', { seconds: secondsUntilReconnect })}.
|
|
</>
|
|
}
|
|
action={
|
|
<OLButton
|
|
id="try-reconnect-now-button"
|
|
onClick={() => tryReconnectNow()}
|
|
size="sm"
|
|
variant="secondary"
|
|
>
|
|
{t('try_now')}
|
|
</OLButton>
|
|
}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|