Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
import type { JSX } from "react";
import { useLocation, useParams } from "@tanstack/react-router";
import { Sidebar, SidebarContent, SidebarFooter, SidebarTrigger } from "@app/components/v3";
import { useOrganization } from "@app/context";
import {
hasIntermediateProjectsView,
parseProjectSlugFromPath,
urlSlugToProjectType
} from "@app/helpers/project";
import { useImplicitProduct } from "@app/hooks";
import { ProjectType } from "@app/hooks/api/projects/types";
import { OrgNav } from "./OrgNav";
import { ProjectNav } from "./ProjectNav";
import { ProjectTypeNav } from "./ProjectTypeNav";
// --- Main sidebar ---
export const OrgSidebar = () => {
const { projectId, type: typeSlug } = useParams({
strict: false,
select: (el) => ({
projectId: (el as { projectId?: string })?.projectId,
type: (el as { type?: string })?.type
})
});
const { pathname } = useLocation();
const orgScopedProduct = useImplicitProduct();
const isInsideProject = Boolean(projectId) || Boolean(orgScopedProduct);
// The org-wide KMIP servers and Secret Sharing pages live at literal /projects/<slug>/<resource>
// paths with no $type route param, so fall back to parsing the product slug from the pathname.
const effectiveTypeSlug = typeSlug ?? parseProjectSlugFromPath(pathname);
const projectType = effectiveTypeSlug ? urlSlugToProjectType(effectiveTypeSlug) : null;
const isOnProjectTypeListing =
!isInsideProject &&
Boolean(projectType) &&
(hasIntermediateProjectsView(projectType!) || pathname.includes("/product-settings"));
const { isSubOrganization } = useOrganization();
let scope: "project" | "sub-org" | "org" | "pam" | "agent-vault" | "secret-scanning" = "org";
if (orgScopedProduct === ProjectType.PAM) scope = "pam";
else if (orgScopedProduct === ProjectType.AgentVault) scope = "agent-vault";
else if (orgScopedProduct === ProjectType.SecretScanning) scope = "secret-scanning";
else if (isInsideProject || isOnProjectTypeListing) scope = "project";
else if (isSubOrganization) scope = "sub-org";
let body: JSX.Element;
if (isInsideProject) body = <ProjectNav />;
else if (isOnProjectTypeListing) body = <ProjectTypeNav />;
else body = <OrgNav />;
return (
<Sidebar scope={scope} collapsible="none" side="left">
<SidebarContent>{body}</SidebarContent>
<SidebarFooter className="border-t border-border-soft p-2">
<SidebarTrigger variant="ghost" className="w-full" />
</SidebarFooter>
</Sidebar>
);
};