Skip to content
Closed
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
11 changes: 9 additions & 2 deletions app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,24 @@ export const NavLinkItem = (props: {
children: React.ReactNode
end?: boolean
disabled?: boolean
/**
* Used for making sure the link highlights for all sub-routes even if it
* links to the first sub-route directly, e.g., for route tabs
*/
activePrefix?: string
}) => {
const { pathname } = useLocation()
// If the current page is the create form for this NavLinkItem's resource, highlight the NavLink in the sidebar
const currentPathIsCreateForm = useLocation().pathname.startsWith(`${props.to}-new`)
const onCreateFormForPath = pathname.startsWith(`${props.to}-new`)
const altActive = props.activePrefix && pathname.startsWith(props.activePrefix)
return (
<li>
<NavLink
to={props.to}
className={({ isActive }) =>
cn(linkStyles, {
'text-accent !bg-accent-secondary hover:!bg-accent-secondary-hover svg:!text-accent-tertiary':
isActive || currentPathIsCreateForm,
isActive || onCreateFormForPath || altActive,
'pointer-events-none text-disabled': props.disabled,
})
}
Expand Down
2 changes: 1 addition & 1 deletion app/layouts/SystemLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function SystemLayout() {
<NavLinkItem to={pb.systemUtilization()}>
<Metrics16Icon /> Utilization
</NavLinkItem>
<NavLinkItem to={pb.sledInventory()}>
<NavLinkItem to={pb.sledInventory()} activePrefix={pb.inventory()}>
<Servers16Icon /> Inventory
</NavLinkItem>
<NavLinkItem to={pb.ipPools()}>
Expand Down