import { useEffect, useRef } from 'react' import dayjs from 'dayjs' import cx from 'classnames' import { useTranslation } from 'components/hooks/useTranslation' import { PatchNotes } from './PatchNotes' import { Link } from 'components/Link' import { CurrentVersion, ReleaseNotePatch, GHESMessage } from './types' import { useOnScreen } from 'components/hooks/useOnScreen' import styles from './PatchNotes.module.scss' type Props = { patch: ReleaseNotePatch currentVersion: CurrentVersion latestPatch: string latestRelease: string message: GHESMessage didEnterView: () => void } export function GHESReleaseNotePatch({ patch, currentVersion, latestPatch, latestRelease, message, didEnterView, }: Props) { const { t } = useTranslation('header') const containerRef = useRef(null) const onScreen = useOnScreen(containerRef, { rootMargin: '-40% 0px -50%' }) useEffect(() => { if (onScreen) { didEnterView() } }, [onScreen]) return (

{currentVersion.versionTitle}.{patch.patchVersion}

{patch.release_candidate && ( Release Candidate )} {currentVersion.plan === 'enterprise-server' && ( Download GitHub Enterprise Server {patch.downloadVersion} )}

{dayjs(patch.date).format('MMMM DD, YYYY')}

{patch.version !== latestPatch && currentVersion.currentRelease === latestRelease && (

{' '} {t('notices.release_notes_use_latest')}

)} {patch.version === latestPatch && currentVersion.currentRelease !== latestRelease && (

{' '} {t('notices.release_notes_use_latest')}

)} {patch.version !== latestPatch && currentVersion.currentRelease !== latestRelease && (

{' '} {t('notices.release_notes_use_latest')}

)}
) }