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

Next release/version simple #6257

Merged
merged 11 commits into from
Nov 10, 2023
Merged
7 changes: 3 additions & 4 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export const Layout = ({
currentPlatform = platform
? platform
: PLATFORMS.includes(asPathPlatform)
? asPathPlatform
: DEFAULT_PLATFORM;
? asPathPlatform
: DEFAULT_PLATFORM;
}

const title = [
Expand Down Expand Up @@ -186,8 +186,7 @@ export const Layout = ({
if (isGen2) {
menu = <Menu rootMenuNode={rootMenuNode} />;
} else if (isPrev) {
let prevNode = findDirectoryNode('/[platform]/prev');
menu = <Menu currentPlatform={currentPlatform} rootMenuNode={prevNode} />;
menu = <Menu currentPlatform={currentPlatform} rootMenuNode={rootMenuNode} isPrev={true} />
}

return (
Expand Down
16 changes: 15 additions & 1 deletion src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@ import { ReactElement } from 'react';
import { MenuItem } from './MenuItem';
import { Platform } from '@/data/platforms';
import { PageNode } from 'src/directory/directory';
import { findDirectoryNode } from '@/utils/findDirectoryNode';
import { BUILD_A_BACKEND, PREV_BUILD_A_BACKEND } from '@/data/routes';

type MenuProps = {
currentPlatform?: Platform;
rootMenuNode: PageNode | undefined;
isPrev?: boolean;
};

const invalidChildren = ['/[platform]/prev'];

export function Menu({
currentPlatform,
rootMenuNode
rootMenuNode,
isPrev = false
}: MenuProps): ReactElement {
let childrenNodes = rootMenuNode?.children?.filter((childNode) => {
return invalidChildren.indexOf(childNode.route) === -1;
});
if (isPrev) {
// replace build a backend with previous build a backend
const buildABackend = findDirectoryNode(PREV_BUILD_A_BACKEND);
childrenNodes = childrenNodes?.map((child) => {
if (child.route === BUILD_A_BACKEND) {
return buildABackend;
}
return child;
});
}

return (
<nav className="menu">
Expand Down
3 changes: 2 additions & 1 deletion src/components/VersionSwitcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IconCheck } from '@/components/Icons';
import { PLATFORM_VERSIONS } from '@/data/platforms';
import classNames from 'classnames';
import { trackVersionChange } from '@/utils/track';
import { BUILD_A_BACKEND, PREV_BUILD_A_BACKEND } from '@/data/routes';

const findRoute = (platform, isPrev) => {
const router = useRouter();
Expand All @@ -23,7 +24,7 @@ export const VersionSwitcher = ({ platform, isPrev, ...rest }) => {
const router = useRouter();
const versions = PLATFORM_VERSIONS[platform];
const switchPath = findRoute(platform, isPrev);
let path = isPrev ? '/[platform]' : '/[platform]/prev';
let path = isPrev ? BUILD_A_BACKEND : PREV_BUILD_A_BACKEND;
if (switchPath) path = switchPath;

const inactiveHref = {
Expand Down
3 changes: 3 additions & 0 deletions src/data/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const BUILD_A_BACKEND = '/[platform]/build-a-backend';

export const PREV_BUILD_A_BACKEND = '/[platform]/prev/build-a-backend';
Loading