Use the handle to determine if the side menu is expanded

This commit is contained in:
Matt Aitken
2023-07-11 14:35:14 +01:00
parent b925a573f3
commit 0a7bae4dac
6 changed files with 13 additions and 5 deletions
@@ -18,6 +18,8 @@ import { UserProfilePhoto } from "../UserProfilePhoto";
import { NavLinkButton } from "../primitives/Buttons";
import type { IconNames } from "../primitives/NamedIcon";
import { SimpleTooltip } from "../primitives/Tooltip";
import { usePathName } from "~/hooks/usePathName";
import { Handle } from "~/utils/handle";
export function SideMenuContainer({ children }: { children: React.ReactNode }) {
return (
@@ -46,14 +48,15 @@ export function ProjectSideMenu() {
const project = useProject();
const matches = useMatches();
//we collapse the menu if we're in a job or an integration
const job = useOptionalJob();
const client = useOptionalIntegrationClient();
const isCollapsed = job !== undefined || client !== undefined;
//the deepest route `handle` determines if the menu is expanded
const deepestMatch = matches.at(-1);
const handle = deepestMatch?.handle as Handle;
const isCollapsed = handle?.expandSidebar ? !handle.expandSidebar : true;
const job = useOptionalJob();
const jobsActive =
job !== undefined ||
matches.at(-1)?.id ===
deepestMatch?.id ===
"routes/_app.orgs.$organizationSlug.projects.$projectParam._index";
return (
@@ -32,6 +32,7 @@ export const handle: Handle = {
breadcrumb: (match) => (
<BreadcrumbLink to={trimTrailingSlash(match.pathname)} title="Jobs" />
),
expandSidebar: true,
};
export default function Page() {
@@ -76,6 +76,7 @@ export const handle: Handle = {
breadcrumb: (match) => (
<BreadcrumbLink to={match.pathname} title="Environments" />
),
expandSidebar: true,
};
export default function Page() {
@@ -72,6 +72,7 @@ export const handle: Handle = {
breadcrumb: (match) => (
<BreadcrumbLink to={match.pathname} title="Integrations" />
),
expandSidebar: true,
};
export default function Integrations() {
@@ -50,6 +50,7 @@ export const handle: Handle = {
title="External Triggers"
/>
),
expandSidebar: true,
};
export default function Integrations() {
+1
View File
@@ -2,4 +2,5 @@ import { BreadcrumbItem } from "~/components/navigation/Breadcrumb";
export type Handle = {
breadcrumb?: BreadcrumbItem;
expandSidebar?: boolean;
};