Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Moving the version support button to the footer #7156

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions apps/site/components/Common/ActiveLink/__tests__/index.test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { render, screen } from '@testing-library/react';

import { VERSION_SUPPORT_SHORTCUT } from '@/next.constants.mjs';

import ActiveLink from '..';

// mock usePathname, but retain all the other imports
Expand Down Expand Up @@ -64,43 +62,4 @@ describe('ActiveLink', () => {

expect(screen.findByText('Link')).resolves.toHaveAttribute('class', 'link');
});

it('sets active class when href is other than VERSION_SUPPORT_SHORTCUT', () => {
const { usePathname } = require('@/navigation.mjs');
usePathname.mockReturnValue('/link/sublink');

render(
<ActiveLink
className="link"
activeClassName="active"
allowSubPath={true}
href={'/link/sub-link'}
>
Link
</ActiveLink>
);

expect(screen.findByText('Link')).resolves.toHaveAttribute(
'class',
'link active'
);
});

it('does not set active class when href is VERSION_SUPPORT_SHORTCUT', () => {
const { usePathname } = require('@/navigation.mjs');
usePathname.mockReturnValue(VERSION_SUPPORT_SHORTCUT);

render(
<ActiveLink
className="link"
activeClassName="active"
allowSubPath={true}
href={VERSION_SUPPORT_SHORTCUT}
>
Link
</ActiveLink>
);

expect(screen.findByText('Link')).resolves.toHaveAttribute('class', 'link');
});
});
5 changes: 1 addition & 4 deletions apps/site/components/Common/ActiveLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { ComponentProps, FC } from 'react';

import Link from '@/components/Link';
import { usePathname } from '@/navigation.mjs';
import { VERSION_SUPPORT_SHORTCUT } from '@/next.constants.mjs';

type ActiveLocalizedLinkProps = ComponentProps<typeof Link> & {
activeClassName?: string;
Expand All @@ -27,9 +26,7 @@ const ActiveLink: FC<ActiveLocalizedLinkProps> = ({
? // When using allowSubPath we want only to check if
// the current pathname starts with the utmost upper level
// of an href (e.g. /docs/...)
pathname.startsWith(`/${href.toString().split('/')[1]}`) &&
// but not when this link is for the deep link shortcut to previous releases
href.toString() !== VERSION_SUPPORT_SHORTCUT
pathname.startsWith(`/${href.toString().split('/')[1]}`)
: href.toString() === pathname,
});

Expand Down
8 changes: 4 additions & 4 deletions apps/site/navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
"link": "https://nodejs.org/docs/latest/api/",
"label": "components.containers.navBar.links.docs"
},
"support": {
"link": "/about/previous-releases",
"label": "components.containers.navBar.links.support"
},
"certification": {
"link": "https://training.linuxfoundation.org/openjs/",
"label": "components.containers.navBar.links.certification",
Expand All @@ -39,6 +35,10 @@
"link": "https://privacy-policy.openjsf.org/",
"text": "components.containers.footer.links.privacyPolicy"
},
{
"link": "/about/previous-releases",
"text": "components.containers.footer.links.versionSupport"
},
{
"link": "https://github.com/openjs-foundation/cross-project-council/blob/main/CODE_OF_CONDUCT.md",
"text": "components.containers.footer.links.codeOfConduct"
Expand Down
5 changes: 0 additions & 5 deletions apps/site/next.constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,3 @@ export const GITHUB_API_KEY = process.env.NEXT_GITHUB_API_KEY || '';
*/
export const ESP_SUPPORT_THRESHOLD_VERSION =
process.env.ESP_SUPPORT_THRESHOLD_VERSION || '18.0.0';

/**
* This deep link into the app is repeated in the top nav, but we want to ignore it for active-link highlighting, since it will be covered by About
*/
export const VERSION_SUPPORT_SHORTCUT = '/about/previous-releases';
2 changes: 1 addition & 1 deletion packages/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"links": {
"trademarkPolicy": "Trademark Policy",
"privacyPolicy": "Privacy Policy",
"versionSupport": "Version Support",
"codeOfConduct": "Code of Conduct",
"security": "Security Policy"
}
Expand All @@ -14,7 +15,6 @@
"about": "About",
"download": "Download",
"docs": "Docs",
"support": "Version Support",
"guides": "Guides",
"learn": "Learn",
"security": "Security",
Expand Down
Loading