Skip to content

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

persist tabs for account and resource pages

x0322057e1fc5fce191
diff --git a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
index 6a7c6e0167..eae5f7ff8a 100644
--- a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
+++ b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx
@@ -2,7 +2,7 @@ import { useState } from "react";
import { Helmet } from "react-helmet";
import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useNavigate, useParams } from "@tanstack/react-router";
+import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { BanIcon, EllipsisVerticalIcon, LogInIcon } from "lucide-react";
import { ProjectPermissionCan } from "@app/components/permissions";
@@ -53,6 +53,25 @@ const PageContent = () => {
const { accountId, projectId, resourceType, resourceId } = params;
+ const selectedTab = useSearch({
+ strict: false,
+ select: (el) => el.selectedTab
+ });
+
+ const handleTabChange = (tab: string) => {
+ navigate({
+ to: "/organizations/$orgId/projects/pam/$projectId/resources/$resourceType/$resourceId/accounts/$accountId",
+ search: (prev) => ({ ...prev, selectedTab: tab }),
+ params: {
+ orgId: currentOrg.id,
+ projectId: projectId!,
+ resourceType: resourceType!,
+ resourceId: resourceId!,
+ accountId: accountId!
+ }
+ });
+ };
+
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
@@ -217,7 +236,7 @@ const PageContent = () => {
{/* Right Column - Tabbed Content */}
<div className="flex-1">
- <Tabs defaultValue="resources">
+ <Tabs value={selectedTab} onValueChange={handleTabChange}>
<TabList>
<Tab value="resources">Resources</Tab>
<Tab value="dependencies">Dependencies</Tab>
diff --git a/frontend/src/pages/pam/PamAccountByIDPage/route.tsx b/frontend/src/pages/pam/PamAccountByIDPage/route.tsx
index 1e89f2526f..7ae205c636 100644
--- a/frontend/src/pages/pam/PamAccountByIDPage/route.tsx
+++ b/frontend/src/pages/pam/PamAccountByIDPage/route.tsx
@@ -1,11 +1,26 @@
-import { createFileRoute, linkOptions } from "@tanstack/react-router";
+import { createFileRoute, linkOptions, stripSearchParams } from "@tanstack/react-router";
+import { zodValidator } from "@tanstack/zod-adapter";
+import { z } from "zod";
import { PamAccountByIDPage } from "./PamAccountByIDPage";
+export enum AccountDetailTab {
+ Resources = "resources",
+ Dependencies = "dependencies"
+}
+
+const AccountDetailSearchSchema = z.object({
+ selectedTab: z.nativeEnum(AccountDetailTab).catch(AccountDetailTab.Resources)
+});
+
export const Route = createFileRoute(
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/pam/$projectId/_pam-layout/resources/$resourceType/$resourceId/accounts/$accountId/"
)({
+ validateSearch: zodValidator(AccountDetailSearchSchema),
component: PamAccountByIDPage,
+ search: {
+ middlewares: [stripSearchParams({ selectedTab: AccountDetailTab.Resources })]
+ },
beforeLoad: ({ context, params }) => {
return {
breadcrumbs: [
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx b/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx
index e5cfd2262e..17c4db5b87 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx
@@ -2,7 +2,7 @@ import { useState } from "react";
import { Helmet } from "react-helmet";
import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useNavigate, useParams } from "@tanstack/react-router";
+import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { BanIcon, EllipsisVerticalIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
@@ -45,6 +45,24 @@ const PageContent = () => {
const { resourceId, resourceType, projectId } = params;
+ const selectedTab = useSearch({
+ strict: false,
+ select: (el) => el.selectedTab
+ });
+
+ const handleTabChange = (tab: string) => {
+ navigate({
+ to: "/organizations/$orgId/projects/pam/$projectId/resources/$resourceType/$resourceId",
+ search: (prev) => ({ ...prev, selectedTab: tab }),
+ params: {
+ orgId: currentOrg.id,
+ projectId: projectId!,
+ resourceType: resourceType!,
+ resourceId: resourceId!
+ }
+ });
+ };
+
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
@@ -186,7 +204,7 @@ const PageContent = () => {
{/* Right Column - Tabbed Content */}
<div className="flex-1">
- <Tabs defaultValue="accounts">
+ <Tabs value={selectedTab} onValueChange={handleTabChange}>
<TabList>
<Tab value="accounts">Accounts</Tab>
{resource.resourceType === PamResourceType.ActiveDirectory && (
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/route.tsx b/frontend/src/pages/pam/PamResourceByIDPage/route.tsx
index 08620e92a4..9ea0bb0b59 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/route.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/route.tsx
@@ -1,11 +1,26 @@
-import { createFileRoute, linkOptions } from "@tanstack/react-router";
+import { createFileRoute, linkOptions, stripSearchParams } from "@tanstack/react-router";
+import { zodValidator } from "@tanstack/zod-adapter";
+import { z } from "zod";
import { PamResourceByIDPage } from "./PamResourceByIDPage";
+export enum ResourceDetailTab {
+ Accounts = "accounts",
+ RelatedResources = "related-resources"
+}
+
+const ResourceDetailSearchSchema = z.object({
+ selectedTab: z.nativeEnum(ResourceDetailTab).catch(ResourceDetailTab.Accounts)
+});
+
export const Route = createFileRoute(
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/pam/$projectId/_pam-layout/resources/$resourceType/$resourceId/"
)({
+ validateSearch: zodValidator(ResourceDetailSearchSchema),
component: PamResourceByIDPage,
+ search: {
+ middlewares: [stripSearchParams({ selectedTab: ResourceDetailTab.Accounts })]
+ },
beforeLoad: ({ context, params }) => {
return {
breadcrumbs: [