Skip to content

Commit 843297a

Browse files
refactor: use cache on providers (#8216)
* refactor: cache release data * try something * wip * 404 on server * cache more stuff * Revert "cache more stuff" This reverts commit 353b170. --------- Co-authored-by: avivkeller <me@aviv.sh>
1 parent 3d01d2e commit 843297a

File tree

15 files changed

+265
-208
lines changed

15 files changed

+265
-208
lines changed

apps/site/app/[locale]/download/archive/[version]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const getPage: FC<PageParams> = async props => {
4646
const [locale, pathname] = basePage.getLocaleAndPath(version, routeLocale);
4747

4848
if (version === 'current') {
49-
const releaseData = provideReleaseData();
49+
const releaseData = await provideReleaseData();
5050

5151
const release = releaseData.find(release => release.status === 'Current');
5252

apps/site/app/[locale]/not-found.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
'use client';
1+
'use server';
22

33
import { ArrowRightIcon } from '@heroicons/react/24/solid';
4-
import { useTranslations } from 'next-intl';
4+
import { getTranslations } from 'next-intl/server';
55
import type { FC } from 'react';
66

77
import Button from '#site/components/Common/Button';
88
import Turtle from '#site/components/Common/Turtle';
99
import GlowingBackdropLayout from '#site/layouts/GlowingBackdrop';
1010

11-
const NotFoundPage: FC = () => {
12-
const t = useTranslations();
11+
const NotFoundPage: FC = async () => {
12+
const t = await getTranslations();
1313

1414
return (
1515
<GlowingBackdropLayout kind="default">

apps/site/components/EOL/EOLReleaseTable.tsx

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
'use client';
2+
3+
import { useTranslations } from 'next-intl';
4+
import type { FC } from 'react';
5+
import { Fragment, useState } from 'react';
6+
7+
import FormattedTime from '#site/components/Common/FormattedTime';
8+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
9+
import EOLModal from '#site/components/EOL/EOLModal';
10+
import VulnerabilityChips from '#site/components/EOL/VulnerabilityChips';
11+
import type { NodeRelease } from '#site/types/releases.js';
12+
import type { GroupedVulnerabilities } from '#site/types/vulnerabilities.js';
13+
14+
type EOLReleaseTableBodyProps = {
15+
eolReleases: Array<NodeRelease>;
16+
vulnerabilities: GroupedVulnerabilities;
17+
};
18+
19+
const EOLReleaseTableBody: FC<EOLReleaseTableBodyProps> = ({
20+
eolReleases,
21+
vulnerabilities,
22+
}) => {
23+
const t = useTranslations();
24+
25+
const [currentModal, setCurrentModal] = useState<string | undefined>();
26+
27+
return (
28+
<tbody>
29+
{eolReleases.map(release => (
30+
<Fragment key={release.major}>
31+
<tr>
32+
<td data-label="Version">
33+
v{release.major} {release.codename ? `(${release.codename})` : ''}
34+
</td>
35+
36+
<td data-label="Date">
37+
<FormattedTime date={release.releaseDate} />
38+
</td>
39+
40+
<td>
41+
<VulnerabilityChips
42+
vulnerabilities={vulnerabilities[release.major]}
43+
/>
44+
</td>
45+
46+
<td>
47+
<LinkWithArrow
48+
className="cursor-pointer"
49+
onClick={() => setCurrentModal(release.version)}
50+
>
51+
{t('components.downloadReleasesTable.details')}
52+
</LinkWithArrow>
53+
</td>
54+
</tr>
55+
56+
<EOLModal
57+
release={release}
58+
vulnerabilities={vulnerabilities[release.major]}
59+
open={currentModal === release.version}
60+
onOpenChange={open => open || setCurrentModal(undefined)}
61+
/>
62+
</Fragment>
63+
))}
64+
</tbody>
65+
);
66+
};
67+
68+
export default EOLReleaseTableBody;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { getTranslations } from 'next-intl/server';
2+
import type { FC } from 'react';
3+
4+
import provideReleaseData from '#site/next-data/providers/releaseData';
5+
import provideVulnerabilities from '#site/next-data/providers/vulnerabilities';
6+
import { EOL_VERSION_IDENTIFIER } from '#site/next.constants.mjs';
7+
8+
import EOLReleaseTableBody from './TableBody';
9+
10+
const EOLReleaseTable: FC = async () => {
11+
const releaseData = await provideReleaseData();
12+
const vulnerabilities = provideVulnerabilities();
13+
14+
const eolReleases = releaseData.filter(
15+
release => release.status === EOL_VERSION_IDENTIFIER
16+
);
17+
18+
const t = await getTranslations();
19+
20+
return (
21+
<table id="tbVulnerabilities">
22+
<thead>
23+
<tr>
24+
<th>
25+
{t('components.eolTable.version')} (
26+
{t('components.eolTable.codename')})
27+
</th>
28+
<th>{t('components.eolTable.lastUpdated')}</th>
29+
<th>{t('components.eolTable.vulnerabilities')}</th>
30+
<th>{t('components.eolTable.details')}</th>
31+
</tr>
32+
</thead>
33+
34+
<EOLReleaseTableBody
35+
eolReleases={eolReleases}
36+
vulnerabilities={vulnerabilities}
37+
/>
38+
</table>
39+
);
40+
};
41+
42+
export default EOLReleaseTable;

apps/site/components/Releases/PreviousReleasesTable.tsx

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)