Skip to content

Commit b1931f7

Browse files
committed
Link to Alpha in LTS alert box when no Current
1 parent b86c448 commit b1931f7

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

‎apps/site/components/withReleaseAlertBox.tsx‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import AlertBox from '@node-core/ui-components/Common/AlertBox';
22
import { useTranslations } from 'next-intl';
3+
import { use, type FC } from 'react';
34

45
import Link from '#site/components/Link';
6+
import { ReleasesContext } from '#site/providers/releaseProvider';
57

68
import type { NodeReleaseStatus } from '#site/types';
7-
import type { FC } from 'react';
89

910
type WithReleaseAlertBoxProps = {
1011
status: NodeReleaseStatus;
1112
};
1213

1314
const WithReleaseAlertBox: FC<WithReleaseAlertBoxProps> = ({ status }) => {
15+
const { releases } = use(ReleasesContext);
1416
const t = useTranslations();
1517

18+
const hasCurrent = releases.some(({ status }) => status === 'Current');
19+
const hasAlpha = releases.some(({ status }) => status === 'Alpha');
20+
1621
switch (status) {
1722
case 'EOL':
1823
return (
@@ -43,17 +48,24 @@ const WithReleaseAlertBox: FC<WithReleaseAlertBoxProps> = ({ status }) => {
4348
</AlertBox>
4449
);
4550
case 'LTS':
46-
return (
47-
<AlertBox
48-
title={t('components.common.alertBox.info')}
49-
level="success"
50-
size="small"
51-
>
52-
{t.rich('components.releaseModal.ltsVersionFeaturesNotice', {
53-
link: text => <Link href="/download/current">{text}</Link>,
54-
})}
55-
</AlertBox>
56-
);
51+
if (hasCurrent || hasAlpha) {
52+
return (
53+
<AlertBox
54+
title={t('components.common.alertBox.info')}
55+
level="success"
56+
size="small"
57+
>
58+
{t.rich('components.releaseModal.ltsVersionFeaturesNotice', {
59+
link: text => (
60+
<Link href={`/download/${hasCurrent ? 'current' : 'alpha'}`}>
61+
{text}
62+
</Link>
63+
),
64+
})}
65+
</AlertBox>
66+
);
67+
}
68+
return null;
5769
default:
5870
return null;
5971
}

0 commit comments

Comments
 (0)