|
| 1 | +import { ArrowRightIcon, ArrowUpIcon, FileIcon, ListUnorderedIcon } from '@primer/octicons-react' |
| 2 | +import { useMainContext } from 'components/context/MainContext' |
| 3 | +import { useProductLandingContext } from 'components/context/ProductLandingContext' |
| 4 | +import { useTranslation } from 'components/hooks/useTranslation' |
| 5 | +import { Link } from 'components/Link' |
| 6 | +import { useRouter } from 'next/router' |
| 7 | + |
| 8 | +export function ProductReleases() { |
| 9 | + const { t } = useTranslation('product_landing') |
| 10 | + const router = useRouter() |
| 11 | + const { enterpriseServerReleases, allVersions } = useMainContext() |
| 12 | + const { releases } = useProductLandingContext() |
| 13 | + const currentPath = router.asPath.split('?')[0] |
| 14 | + return ( |
| 15 | + <div> |
| 16 | + <div className="d-lg-flex gutter-lg flex-items-stretch"> |
| 17 | + {releases.map((release) => { |
| 18 | + const releaseNumber = release.version |
| 19 | + if (!enterpriseServerReleases.supported.includes(releaseNumber)) { |
| 20 | + return null |
| 21 | + } |
| 22 | + const releaseVersion = `enterprise-server@${releaseNumber}` |
| 23 | + const latestPatch = release.patches[0] |
| 24 | + const firstPreviousVersion = `enterprise-server@${release.firstPreviousRelease}` |
| 25 | + const secondPreviousVersion = `enterprise-server@${release.secondPreviousRelease}` |
| 26 | + return ( |
| 27 | + <div key={releaseNumber} className="col-lg-4 col-12 mb-3"> |
| 28 | + <div className="Box color-shadow-medium height-full d-block hover-shadow-large no-underline color-text-primary p-5"> |
| 29 | + <h2>{allVersions[releaseVersion].versionTitle}</h2> |
| 30 | + <p className="mt-2 mb-4 color-text-tertiary"> |
| 31 | + <ListUnorderedIcon />{' '} |
| 32 | + <Link |
| 33 | + href={`/${router.locale}/${releaseVersion}/admin/release-notes#${latestPatch.version}`} |
| 34 | + > |
| 35 | + {t('release_notes_for')} {latestPatch.version} |
| 36 | + </Link>{' '} |
| 37 | + ({latestPatch.date}) |
| 38 | + </p> |
| 39 | + <p className="mt-2 mb-4 color-text-tertiary"> |
| 40 | + <ArrowUpIcon /> {t('upgrade_from')}{' '} |
| 41 | + <Link |
| 42 | + href={`/${router.locale}/${firstPreviousVersion}/admin/enterprise-management/upgrading-github-enterprise-server`} |
| 43 | + > |
| 44 | + {release.firstPreviousRelease} |
| 45 | + </Link>{' '} |
| 46 | + or{' '} |
| 47 | + <Link |
| 48 | + href={`/${router.locale}/${secondPreviousVersion}/admin/enterprise-management/upgrading-github-enterprise-server`} |
| 49 | + > |
| 50 | + {release.secondPreviousRelease} |
| 51 | + </Link> |
| 52 | + </p> |
| 53 | + <p className="mt-2 mb-4 color-text-tertiary"> |
| 54 | + <FileIcon />{' '} |
| 55 | + <Link href={`/${router.locale}/${releaseVersion}`}>{t('browse_all_docs')}</Link> |
| 56 | + </p> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + ) |
| 60 | + })} |
| 61 | + </div> |
| 62 | + |
| 63 | + <Link href={`${currentPath}/release-notes}`} className="btn btn-outline float-right"> |
| 64 | + {t('explore_release_notes')} <ArrowRightIcon /> |
| 65 | + </Link> |
| 66 | + </div> |
| 67 | + ) |
| 68 | +} |
0 commit comments