1
0
mirror of synced 2025-12-21 10:57:10 -05:00

use plain link to link to unsupported GHES versions (#32204)

This commit is contained in:
Peter Bengtsson
2022-10-31 18:26:06 +01:00
committed by GitHub
parent 5713ff456c
commit 18feadbe23
4 changed files with 44 additions and 5 deletions

View File

@@ -11,10 +11,12 @@ import { GHESReleaseNotesContextT } from './types'
import { GHESReleaseNotePatch } from './GHESReleaseNotePatch'
import styles from './PatchNotes.module.scss'
import { PlainLink } from './PlainLink'
type Props = {
context: GHESReleaseNotesContextT
}
export function GHESReleaseNotes({ context }: Props) {
const router = useRouter()
const { currentProduct } = useMainContext()
@@ -59,16 +61,24 @@ export function GHESReleaseNotes({ context }: Props) {
{releases.map((release) => {
const releaseLink = `/${router.locale}/${currentVersion.plan}@${release.version}/${currentProduct?.id}/release-notes`
// Use client-side router link component only if it's a supported release.
// Otherwise, it will trigger a NextJS data XHR fetch for releases
// that are deprecated when in fact you should load it regularly
// so it's read as a proxy from the archive.
const LinkComponent = currentVersion.releases.includes(release.version)
? Link
: PlainLink
if (!release.patches || release.patches.length === 0) {
return (
<li key={release.version} className="border-bottom">
<Link
<LinkComponent
href={releaseLink}
className="Link--primary no-underline px-3 py-4 my-0 d-flex flex-items-center flex-justify-between"
>
{release.version}
<LinkExternalIcon />
</Link>
</LinkComponent>
</li>
)
}
@@ -86,7 +96,7 @@ export function GHESReleaseNotes({ context }: Props) {
return (
<li key={release.version} className="border-bottom">
<Link
<LinkComponent
className="px-3 py-4 my-0 d-flex flex-items-center flex-justify-between"
href={releaseLink}
>
@@ -95,7 +105,7 @@ export function GHESReleaseNotes({ context }: Props) {
{release.patches.length}{' '}
{release.patches.length === 1 ? 'release' : 'releases'}
</span>
</Link>
</LinkComponent>
</li>
)
})}