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

update nav menu as links #5759

Merged
merged 2 commits into from
Feb 13, 2025
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
28 changes: 9 additions & 19 deletions clients/admin-ui/src/features/common/nav/MainSideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
AntButton,
AntMenuProps as MenuProps,
Box,
Icons,
Link,
VStack,
} from "fidesui";
import { AntButton, Box, Icons, VStack } from "fidesui";
import palette from "fidesui/src/palette/palette.module.scss";
import NextLink from "next/link";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -39,8 +32,6 @@ export const UnconnectedMainSideNav = ({
handleLogout: any;
username: string;
}) => {
const router = useRouter();

const navMenuItems = groups.map((group) => ({
key: group.title,
icon: group.icon,
Expand All @@ -49,9 +40,13 @@ export const UnconnectedMainSideNav = ({
key: child.path,
// child label needs left margin/padding to align with group title
label: (
<span data-testid={`${child.title}-nav-link`} className="ml-4 pl-0.5">
<NextLink
href={child.path}
data-testid={`${child.title}-nav-link`}
className="ml-4 pl-0.5"
>
{child.title}
</span>
</NextLink>
),
})),
}));
Expand All @@ -75,10 +70,6 @@ export const UnconnectedMainSideNav = ({

const activeKey = getActiveKeyFromUrl();

const handleMenuItemClick: MenuProps["onClick"] = ({ key: path }) => {
router.push(path);
};

// When the nav is first loaded, we want to open the toggles that were open when the user last visited
// the page. This is stored in local storage so that it persists across refreshes.
const getStartupOpenKeys = () => {
Expand Down Expand Up @@ -132,13 +123,12 @@ export const UnconnectedMainSideNav = ({
<Box width="100%">
<Box pb={6}>
<Box px={2}>
<Link as={NextLink} href={INDEX_ROUTE} display="flex">
<NextLink href={INDEX_ROUTE}>
<Image src={logoImage} alt="Fides Logo" width={116} />
</Link>
</NextLink>
</Box>
</Box>
<NavMenu
onClick={handleMenuItemClick}
items={navMenuItems}
selectedKeys={activeKey ? [activeKey] : []}
onOpenChange={handleOpenChange}
Expand Down
10 changes: 7 additions & 3 deletions clients/admin-ui/src/theme/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ h6 {
// Custom styles for dark submenus
.ant-menu-dark .ant-menu-sub {
// The unselected submenu item should be light gray
> .ant-menu-item > .ant-menu-title-content {
> .ant-menu-item > .ant-menu-title-content a {
color: var(--fidesui-neutral-200);

&:hover {
&:hover,
&:focus {
color: var(--fidesui-full-white);
}
&:focus-visible {
text-decoration: underline;
}
}
// The selected submenu item should be dark, because the background is light
// But using the token "darkItemSelectedColor" also affect the group title,
// therefore we need this css rule
> .ant-menu-item.ant-menu-item-selected > .ant-menu-title-content {
> .ant-menu-item.ant-menu-item-selected > .ant-menu-title-content a {
color: var(--fidesui-minos);
}
}
Expand Down
Loading