Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Product sidebar improvements

Carlos Monastyrski9e2cd18d98c5
diff --git a/frontend/src/helpers/project.ts b/frontend/src/helpers/project.ts
index 800a3413e5..37bb174411 100644
--- a/frontend/src/helpers/project.ts
+++ b/frontend/src/helpers/project.ts
@@ -75,6 +75,16 @@ export const urlSlugToProjectType = (slug: string): ProjectType | null => {
return slug as ProjectType;
};
+const PROJECT_TYPES_WITH_INTERMEDIATE_VIEW = new Set<ProjectType>([
+ ProjectType.SecretManager,
+ ProjectType.KMS,
+ ProjectType.SecretScanning,
+ ProjectType.PAM
+]);
+
+export const hasIntermediateProjectsView = (type: ProjectType) =>
+ PROJECT_TYPES_WITH_INTERMEDIATE_VIEW.has(type);
+
export const getProjectBaseURL = (type: ProjectType) => {
switch (type) {
case ProjectType.SecretManager:
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
index 9fe5843c41..6e49d33632 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
@@ -2,27 +2,40 @@ import { useParams } from "@tanstack/react-router";
import { Sidebar, SidebarContent, SidebarFooter, SidebarTrigger } from "@app/components/v3";
import { useOrganization } from "@app/context";
+import { hasIntermediateProjectsView, urlSlugToProjectType } from "@app/helpers/project";
import { OrgNavWrapper } from "./OrgNav";
import { ProjectNav } from "./ProjectNav";
+import { ProjectTypeNav } from "./ProjectTypeNav";
// --- Main sidebar ---
export const OrgSidebar = () => {
- const projectId = useParams({
+ const { projectId, type: typeSlug } = useParams({
strict: false,
- select: (el) => el?.projectId
+ select: (el) => ({
+ projectId: (el as { projectId?: string })?.projectId,
+ type: (el as { type?: string })?.type
+ })
});
const isInsideProject = Boolean(projectId);
+ const projectType = typeSlug ? urlSlugToProjectType(typeSlug) : null;
+ const isOnProjectTypeListing =
+ !isInsideProject && Boolean(projectType) && hasIntermediateProjectsView(projectType!);
const { isSubOrganization } = useOrganization();
let scope: "project" | "sub-org" | "org" = "org";
- if (isInsideProject) scope = "project";
+ 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 = <OrgNavWrapper />;
+
return (
<Sidebar scope={scope} collapsible="none" side="left">
- <SidebarContent>{isInsideProject ? <ProjectNav /> : <OrgNavWrapper />}</SidebarContent>
+ <SidebarContent>{body}</SidebarContent>
<SidebarFooter className="border-t border-border p-2">
<SidebarTrigger variant="ghost" className="w-full" />
</SidebarFooter>
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
index 9f34262338..aeb1c9f21f 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
@@ -5,6 +5,7 @@ import { ChevronLeft } from "lucide-react";
import { SidebarGroup, SidebarGroupLabel } from "@app/components/v3";
import { useOrganization, useProject } from "@app/context";
+import { hasIntermediateProjectsView, projectTypeToUrlSlug } from "@app/helpers/project";
import { ProjectType } from "@app/hooks/api/projects/types";
import { AINav } from "./AINav";
@@ -61,7 +62,11 @@ export const ProjectNav = () => {
const isFromRootRequests = (locationSearch as { from?: string })?.from === "root-requests";
const { submenu: smApprovalsSubmenu, pendingRequestsCount: smPendingCount } =
useApprovalSubmenu();
- const projectLabel = isSubOrganization ? "Sub-Organization" : "Organization";
+ const intermediateAvailable = hasIntermediateProjectsView(currentProject.type);
+ let projectLabel: string;
+ if (intermediateAvailable) projectLabel = "Projects";
+ else if (isSubOrganization) projectLabel = "Sub-Organization";
+ else projectLabel = "Organization";
const NavComponent = PROJECT_NAV_COMPONENT[currentProject.type];
// scott: we currently have to use this flaky inclusion for routes/nested routes because we haven't
@@ -159,14 +164,24 @@ export const ProjectNav = () => {
<button
className="cursor-pointer hover:bg-foreground/[0.025]"
type="button"
- onClick={() =>
+ onClick={() => {
+ if (intermediateAvailable) {
+ navigate({
+ to: "/organizations/$orgId/projects/$type",
+ params: {
+ orgId: currentOrg.id,
+ type: projectTypeToUrlSlug(currentProject.type)
+ }
+ });
+ return;
+ }
navigate({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
to: "/organizations/$orgId/projects" as any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
params: { orgId: currentOrg.id } as any
- })
- }
+ });
+ }}
>
<ChevronLeft />
<span>{projectLabel}</span>
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
new file mode 100644
index 0000000000..a8a7529f08
--- /dev/null
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
@@ -0,0 +1,49 @@
+import { Link, useParams } from "@tanstack/react-router";
+import { ChevronLeft } from "lucide-react";
+
+import {
+ ProjectIcon,
+ SidebarGroup,
+ SidebarGroupLabel,
+ SidebarMenu,
+ SidebarMenuButton,
+ SidebarMenuItem
+} from "@app/components/v3";
+import { useOrganization } from "@app/context";
+
+export const ProjectTypeNav = () => {
+ const { type: typeSlug, orgId } = useParams({ strict: false }) as {
+ type?: string;
+ orgId?: string;
+ };
+ const { currentOrg } = useOrganization();
+ const resolvedOrgId = orgId ?? currentOrg.id;
+
+ return (
+ <SidebarGroup>
+ <SidebarGroupLabel asChild>
+ <Link
+ to="/organizations/$orgId/projects"
+ params={{ orgId: resolvedOrgId }}
+ className="cursor-pointer hover:bg-foreground/[0.025]"
+ >
+ <ChevronLeft />
+ <span>Organization</span>
+ </Link>
+ </SidebarGroupLabel>
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton size="lg" scope="project" asChild isActive tooltip="Projects">
+ <Link
+ to="/organizations/$orgId/projects/$type"
+ params={{ orgId: resolvedOrgId, type: typeSlug ?? "" }}
+ >
+ <ProjectIcon className="size-4" />
+ <span>Projects</span>
+ </Link>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarGroup>
+ );
+};
diff --git a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
index df3a1769fe..d61d25d518 100644
--- a/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/ProjectTypePage/ProjectTypePage.tsx
@@ -147,7 +147,7 @@ const ProjectTypeContent = ({
className="mb-4 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80"
>
<ChevronLeftIcon size={16} />
- Overview
+ Organization
</Link>
<div className="mb-10">
<h1 className="flex items-center text-2xl font-medium text-white underline decoration-project/90 underline-offset-4">
diff --git a/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx b/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
index fe6ddd5129..f4b48a8a5f 100644
--- a/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
+++ b/frontend/src/pages/organization/ProjectsPage/components/ProjectCategoryOverview.tsx
@@ -115,7 +115,7 @@ export const ProjectCategoryOverview = () => {
if (isProjectsLoading) {
return (
- <div className="grid grid-cols-1 gap-5 lg:grid-cols-2 xl:grid-cols-3">
+ <div className="grid grid-cols-1 gap-5 lg:grid-cols-2">
{Array.from({ length: 5 }).map((_, i) => (
<Card key={`tile-loading-${i + 1}`}>
<CardHeader>
@@ -141,7 +141,7 @@ export const ProjectCategoryOverview = () => {
return (
<>
- <div className="grid grid-cols-1 gap-5 lg:grid-cols-2 xl:grid-cols-3">
+ <div className="grid grid-cols-1 gap-5 lg:grid-cols-2">
{PRODUCT_TYPES.map((type) => {
const isCertManager = type === ProjectType.CertificateManager;
const count = projectCountsByType[type] || 0;