|
| 1 | +'use client'; |
| 2 | + |
1 | 3 | import AlertBox from '@node-core/ui-components/Common/AlertBox'; |
2 | 4 | import { useTranslations } from 'next-intl'; |
| 5 | +import { use, type FC } from 'react'; |
3 | 6 |
|
4 | 7 | import Link from '#site/components/Link'; |
| 8 | +import { ReleasesContext } from '#site/providers/releaseProvider'; |
5 | 9 |
|
6 | 10 | import type { NodeReleaseStatus } from '#site/types'; |
7 | | -import type { FC } from 'react'; |
8 | 11 |
|
9 | 12 | type WithReleaseAlertBoxProps = { |
10 | 13 | status: NodeReleaseStatus; |
11 | 14 | }; |
12 | 15 |
|
13 | 16 | const WithReleaseAlertBox: FC<WithReleaseAlertBoxProps> = ({ status }) => { |
| 17 | + const { releases } = use(ReleasesContext); |
14 | 18 | const t = useTranslations(); |
15 | 19 |
|
| 20 | + const hasCurrent = releases.some(({ status }) => status === 'Current'); |
| 21 | + const hasAlpha = releases.some(({ status }) => status === 'Alpha'); |
| 22 | + |
16 | 23 | switch (status) { |
17 | 24 | case 'EOL': |
18 | 25 | return ( |
@@ -43,17 +50,24 @@ const WithReleaseAlertBox: FC<WithReleaseAlertBoxProps> = ({ status }) => { |
43 | 50 | </AlertBox> |
44 | 51 | ); |
45 | 52 | 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 | | - ); |
| 53 | + if (hasCurrent || hasAlpha) { |
| 54 | + return ( |
| 55 | + <AlertBox |
| 56 | + title={t('components.common.alertBox.info')} |
| 57 | + level="success" |
| 58 | + size="small" |
| 59 | + > |
| 60 | + {t.rich('components.releaseModal.ltsVersionFeaturesNotice', { |
| 61 | + link: text => ( |
| 62 | + <Link href={`/download/${hasCurrent ? 'current' : 'alpha'}`}> |
| 63 | + {text} |
| 64 | + </Link> |
| 65 | + ), |
| 66 | + })} |
| 67 | + </AlertBox> |
| 68 | + ); |
| 69 | + } |
| 70 | + return null; |
57 | 71 | default: |
58 | 72 | return null; |
59 | 73 | } |
|
0 commit comments