Skip to content

Commit

Permalink
chore: minor changes and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd committed Feb 25, 2024
1 parent 009f192 commit eaa7fc5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
18 changes: 18 additions & 0 deletions components/Downloads/Release/BitnessDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ const BitnessDropdown: FC = () => {
return disabledItems;
}, [os, release.version]);

// @TODO: We should have a proper utility that gives
// disabled OSs, Platforms, based on specific criteria
// this can be an optimisation for the future
// to remove this logic from this component
useEffect(() => {
const currentBittnessExcluded = disabledItems.includes(String(bitness));

const nonExcludedBitness = bitnessItems[os]
.map(({ value }) => value)
.find(bittness => !disabledItems.includes(bittness));

if (currentBittnessExcluded && nonExcludedBitness) {
setBitness(nonExcludedBitness);
}
// we shouldn't react when "actions" change
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [os, disabledItems]);

return (
<Select
label={t('layouts.download.dropdown.bitness')}
Expand Down
4 changes: 4 additions & 0 deletions components/Downloads/Release/OperatingSystemDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const OperatingSystemDropdown: FC<OperatingSystemDropdownProps> = ({
return disabledItems;
}, [exclude, platform]);

// @TODO: We should have a proper utility that gives
// disabled OSs, Platforms, based on specific criteria
// this can be an optimisation for the future
// to remove this logic from this component
useEffect(() => {
const currentOSExcluded = disabledItems.includes(os);

Expand Down
5 changes: 3 additions & 2 deletions components/Downloads/Release/ReleaseCodeBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { useTranslations } from 'next-intl';
import { useContext, useEffect, useState } from 'react';
import type { FC } from 'react';

Expand All @@ -20,6 +21,7 @@ const ReleaseCodeBox: FC = () => {
} = useContext(ReleaseContext);

const [code, setCode] = useState('');
const t = useTranslations();

useEffect(() => {
const updatedCode = getNodeDownloadSnippet(major, os)[platform];
Expand All @@ -41,8 +43,7 @@ const ReleaseCodeBox: FC = () => {
)}

<span className="text-center text-xs text-neutral-800 dark:text-neutral-200">
Package Managers and their installation scripts are not maintained by
the Node.js project.
{t('layouts.download.codeBox.communityWarning')}
</span>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
"os": "Operating System",
"version": "Version",
"platform": "Platform"
},
"codeBox": {
"communityWarning": "Package Managers and their installation scripts are not maintained by the Node.js project.s"
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions util/downloadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export const platformItems = [

export const bitnessItems = {
WIN: [
{
label: '32-bit',
value: '86',
},
{
label: '64-bit',
value: '64',
},
{
label: '32-bit',
value: '86',
},
{
label: 'ARM64',
value: 'arm64',
Expand Down

0 comments on commit eaa7fc5

Please sign in to comment.