Skip to content

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

fix(frontend): open the right Certificate Manager and Secret Scanning instance from org-level links (#8919)

Andrew Huang7508d3ed5859
diff --git a/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx b/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
index 7dc54e25b6..b4f103ff85 100644
--- a/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
+++ b/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
@@ -3,7 +3,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link } from "@tanstack/react-router";
import { useOrganization } from "@app/context";
-import { setCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
import { useImplicitProjectId } from "@app/hooks";
import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
@@ -37,10 +36,9 @@ export const CertManagerInstanceBanner = () => {
You're viewing a legacy Certificate Manager project.{" "}
{activeProject ? (
<Link
- to="/organizations/$orgId/cert-manager/overview"
- params={{ orgId: currentOrg.id }}
+ to="/organizations/$orgId/projects/cert-manager/$projectId/$"
+ params={{ orgId: currentOrg.id, projectId: activeProject.id, _splat: "overview" }}
reloadDocument
- onClick={() => setCertManagerActiveProjectCookie(currentOrg.id, activeProject.id)}
className="underline underline-offset-2 hover:text-warning"
>
Switch to your active project →
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx
index 87a66f6c90..06431b4e0e 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionRow.tsx
@@ -42,9 +42,9 @@ import {
getAppConnectionMethodDetails
} from "@app/helpers/appConnections";
import {
+ getInstancePinningLink,
getProjectBaseURL,
- getProjectDisplayName,
- pinProjectForNavigation
+ getProjectDisplayName
} from "@app/helpers/project";
import { useToggle } from "@app/hooks";
import { GitHubConnectionMethod, TAppConnection } from "@app/hooks/api/appConnections";
@@ -202,19 +202,18 @@ export const AppConnectionRow = ({
<TableCell className="max-w-0 min-w-32!">
{project ? (
<Link
- // @ts-expect-error app-connections aren't in kms/ssh
- to={
- project.type === ProjectType.AgentVault
- ? "/organizations/$orgId/agent-vault/settings"
- : `${getProjectBaseURL(project.type)}/app-connections`
- }
- params={{
- orgId: currentOrg?.id || "",
- projectId: project.id
- }}
- onClick={() => {
- if (currentOrg?.id) pinProjectForNavigation(currentOrg.id, project);
- }}
+ {...(getInstancePinningLink(currentOrg?.id || "", project, "app-connections") ??
+ // app-connections aren't in kms/ssh, which the route types can't express
+ ({
+ to:
+ project.type === ProjectType.AgentVault
+ ? "/organizations/$orgId/agent-vault/settings"
+ : `${getProjectBaseURL(project.type)}/app-connections`,
+ params: {
+ orgId: currentOrg?.id || "",
+ projectId: project.id
+ }
+ } as never))}
className="underline"
>
<p className="flex items-center gap-1.5 truncate">
diff --git a/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupProjectsSection/GroupProjectRow.tsx b/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupProjectsSection/GroupProjectRow.tsx
index f2dc1f2dc1..cb66e9fc10 100644
--- a/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupProjectsSection/GroupProjectRow.tsx
+++ b/frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupProjectsSection/GroupProjectRow.tsx
@@ -11,11 +11,12 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
IconButton,
+ RowLink,
TableCell,
TableRow
} from "@app/components/v3";
import { OrgPermissionGroupActions, OrgPermissionSubjects, useOrganization } from "@app/context";
-import { getProjectBaseURL, getProjectTitle, pinProjectForNavigation } from "@app/helpers/project";
+import { getInstancePinningLink, getProjectBaseURL, getProjectTitle } from "@app/helpers/project";
import { useGetUserProjects } from "@app/hooks/api";
import { TGroupProject } from "@app/hooks/api/groups/types";
import { ProjectType } from "@app/hooks/api/projects/types";
@@ -44,38 +45,36 @@ export const GroupProjectRow = ({ project, handlePopUpOpen }: Props) => {
return workspaceIds.has(project.id);
}, [workspaces, project]);
+ const projectLink =
+ getInstancePinningLink(
+ currentOrg.id,
+ { id: project.id, type: project.type as ProjectType },
+ "access-management"
+ ) ??
+ ({
+ to: `${getProjectBaseURL(project.type as ProjectType)}/access-management`,
+ params: { orgId: currentOrg.id, projectId: project.id }
+ } as const);
+ const projectSearch = { selectedTab: "groups" };
+
return (
<TableRow
key={`group-project-${project.id}`}
- onClick={() => {
- if (isAccessible) {
- pinProjectForNavigation(currentOrg?.id || "", {
- id: project.id,
- type: project.type as ProjectType
- });
- navigate({
- to: `${getProjectBaseURL(project.type as ProjectType)}/access-management` as const,
- params: {
- orgId: currentOrg?.id || "",
- projectId: project.id
- },
- search: {
- selectedTab: "groups"
- }
- });
- return;
- }
-
- createNotification({
- text: "Unable to access project",
- type: "error"
- });
- }}
+ linked={isAccessible}
+ onClick={
+ isAccessible
+ ? undefined
+ : () => createNotification({ text: "Unable to access project", type: "error" })
+ }
>
- <TableCell className="max-w-0 truncate">{project.name}</TableCell>
+ <TableCell className="max-w-0 truncate">
+ <RowLink {...projectLink} search={projectSearch} disabled={!isAccessible}>
+ {project.name}
+ </RowLink>
+ </TableCell>
<TableCell>{getProjectTitle(project.type as ProjectType)}</TableCell>
<TableCell>{format(new Date(project.joinedGroupAt), "yyyy-MM-dd")}</TableCell>
- <TableCell>
+ <TableCell data-row-interactive>
<DropdownMenu>
<DropdownMenuTrigger>
<IconButton variant="ghost" size="xs">
@@ -87,20 +86,7 @@ export const GroupProjectRow = ({ project, handlePopUpOpen }: Props) => {
isDisabled={!isAccessible}
onClick={(e) => {
e.stopPropagation();
- pinProjectForNavigation(currentOrg?.id || "", {
- id: project.id,
- type: project.type as ProjectType
- });
- navigate({
- to: `${getProjectBaseURL(project.type as ProjectType)}/access-management` as const,
- params: {
- orgId: currentOrg?.id || "",
- projectId: project.id
- },
- search: {
- selectedTab: "groups"
- }
- });
+ navigate({ ...projectLink, search: projectSearch });
}}
>
Access Project
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectRow.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectRow.tsx
index 6a4c97ee32..77be72f45d 100644
--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectRow.tsx
+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityProjectsSection/IdentityProjectRow.tsx
@@ -10,11 +10,12 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
IconButton,
+ RowLink,
TableCell,
TableRow
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { getProjectBaseURL, pinProjectForNavigation } from "@app/helpers/project";
+import { getInstancePinningLink, getProjectBaseURL } from "@app/helpers/project";
import { formatProjectRoleName } from "@app/helpers/roles";
import { useGetUserProjects } from "@app/hooks/api";
import { IdentityProjectMembershipV1 } from "@app/hooks/api/identities/types";
@@ -53,37 +54,38 @@ export const IdentityProjectRow = ({
return workspaceIds.has(project.id);
}, [workspaces, project]);
+ const projectLink =
+ getInstancePinningLink(
+ currentOrg.id,
+ { id: project.id, type: project.type },
+ "access-management"
+ ) ??
+ ({
+ to: `${getProjectBaseURL(project.type)}/access-management`,
+ params: { orgId: currentOrg.id, projectId: project.id }
+ } as const);
+ const projectSearch = { selectedTab: TabSections.Identities };
+
return (
<TableRow
key={`identity-project-membership-${id}`}
- onClick={() => {
- if (isAccessible) {
- pinProjectForNavigation(currentOrg?.id || "", { id: project.id, type: project.type });
- navigate({
- to: `${getProjectBaseURL(project.type)}/access-management` as const,
- params: {
- orgId: currentOrg?.id || "",
- projectId: project.id
- },
- search: {
- selectedTab: TabSections.Identities
- }
- });
- return;
- }
-
- createNotification({
- text: "Unable to access project",
- type: "error"
- });
- }}
+ linked={isAccessible}
+ onClick={
+ isAccessible
+ ? undefined
+ : () => createNotification({ text: "Unable to access project", type: "error" })
+ }
>
- <TableCell className="max-w-0 truncate">{project.name}</TableCell>
+ <TableCell className="max-w-0 truncate">
+ <RowLink {...projectLink} search={projectSearch} disabled={!isAccessible}>
+ {project.name}
+ </RowLink>
+ </TableCell>
<TableCell>{`${formatProjectRoleName(roles[0].role, roles[0].customRoleName)}${
roles.length > 1 ? ` (+${roles.length - 1})` : ""
}`}</TableCell>
<TableCell>{format(new Date(createdAt), "yyyy-MM-dd")}</TableCell>
- <TableCell>
+ <TableCell data-row-interactive>
<DropdownMenu>
<DropdownMenuTrigger>
<IconButton variant="ghost" size="xs">
@@ -95,20 +97,7 @@ export const IdentityProjectRow = ({
isDisabled={!isAccessible}
onClick={(e) => {
e.stopPropagation();
- pinProjectForNavigation(currentOrg?.id || "", {
- id: project.id,
- type: project.type
- });
- navigate({
- to: `${getProjectBaseURL(project.type)}/access-management` as const,
- params: {
- orgId: currentOrg?.id || "",
- projectId: project.id
- },
- search: {
- selectedTab: TabSections.Identities
- }
- });
+ navigate({ ...projectLink, search: projectSearch });
}}
>
Access Project
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
index 8447d16b6a..6884f5c306 100644
--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
@@ -24,7 +24,6 @@ import {
Skeleton
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { setCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";
import {
TGatewayConnectedResources,
@@ -48,18 +47,16 @@ const ResourceRow = ({
subtitle,
to,
params,
- search,
- onClick
+ search
}: {
name: string;
subtitle: string;
to: string;
params: Record<string, string>;
search?: Record<string, unknown>;
- onClick?: () => void;
}) => (
<Item asChild variant="outline" size="xs">
- <Link to={to as "/"} params={params} search={search as never} onClick={onClick}>
+ <Link to={to as "/"} params={params} search={search as never}>
<ItemContent>
<ItemTitle>{name}</ItemTitle>
<ItemDescription className="text-muted">{subtitle}</ItemDescription>
@@ -241,11 +238,12 @@ export const GatewayConnectedResourcesSection = ({ gatewayId }: Props) => {
? c.projectName
: "Certificate Manager"
}
- to="/organizations/$orgId/cert-manager/discovery/$discoveryId"
- params={{ orgId: currentOrg.id, discoveryId: c.id }}
- onClick={() =>
- setCertManagerActiveProjectCookie(currentOrg.id, c.projectId)
- }
+ to="/organizations/$orgId/projects/cert-manager/$projectId/$"
+ params={{
+ orgId: currentOrg.id,
+ projectId: c.projectId,
+ _splat: `discovery/${c.id}`
+ }}
/>
))}
</ItemGroup>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSecretScanningTab/OrgSecretScanningTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSecretScanningTab/OrgSecretScanningTab.tsx
index a5512a67be..2eaf443fe8 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSecretScanningTab/OrgSecretScanningTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSecretScanningTab/OrgSecretScanningTab.tsx
@@ -1,4 +1,4 @@
-import { useNavigate } from "@tanstack/react-router";
+import { Link, useNavigate } from "@tanstack/react-router";
import { BoxIcon, ExternalLinkIcon, RadarIcon, TriangleAlertIcon } from "lucide-react";
import {
@@ -26,7 +26,6 @@ import {
OrgPermissionAdminConsoleAction,
OrgPermissionSubjects
} from "@app/context/OrgPermissionContext/types";
-import { setSecretScanningActiveProjectCookie } from "@app/helpers/secretScanningActiveProject";
import { useGetUserProjects } from "@app/hooks/api";
import { useOrgAdminAccessProject } from "@app/hooks/api/orgAdmin/mutation";
import {
@@ -70,20 +69,20 @@ export const OrgSecretScanningTab = () => {
const isMember = (projectId: string) => userProjects.some((p) => p.id === projectId);
- const handleOpen = async (project: TSecretScanningInstanceProject) => {
- if (!isMember(project.id)) {
- try {
- await orgAdminAccessProject.mutateAsync({ projectId: project.id });
- } catch {
- // The global mutation error handler already reports the failure.
- return;
- }
+ const getProjectDataSourcesLink = (projectId: string) =>
+ ({
+ to: "/organizations/$orgId/projects/secret-scanning/$projectId/$",
+ params: { orgId: currentOrg.id, projectId, _splat: "data-sources" }
+ }) as const;
+
+ const handleJoinAndOpen = async (project: TSecretScanningInstanceProject) => {
+ try {
+ await orgAdminAccessProject.mutateAsync({ projectId: project.id });
+ } catch {
+ // The global mutation error handler already reports the failure.
+ return;
}
- setSecretScanningActiveProjectCookie(currentOrg.id, project.id);
- navigate({
- to: "/organizations/$orgId/secret-scanning/data-sources",
- params: { orgId: currentOrg.id }
- });
+ navigate(getProjectDataSourcesLink(project.id));
};
return (
@@ -133,18 +132,29 @@ export const OrgSecretScanningTab = () => {
{canOpen ? (
<Tooltip>
<TooltipTrigger asChild>
- <IconButton
- variant="ghost"
- size="xs"
- aria-label={`Open ${project.name}`}
- isPending={
- orgAdminAccessProject.isPending &&
- orgAdminAccessProject.variables?.projectId === project.id
- }
- onClick={() => handleOpen(project)}
- >
- <ExternalLinkIcon />
- </IconButton>
+ {isMember(project.id) ? (
+ <IconButton variant="ghost" size="xs" asChild>
+ <Link
+ {...getProjectDataSourcesLink(project.id)}
+ aria-label={`Open ${project.name}`}
+ >
+ <ExternalLinkIcon />
+ </Link>
+ </IconButton>
+ ) : (
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label={`Open ${project.name}`}
+ isPending={
+ orgAdminAccessProject.isPending &&
+ orgAdminAccessProject.variables?.projectId === project.id
+ }
+ onClick={() => handleJoinAndOpen(project)}
+ >
+ <ExternalLinkIcon />
+ </IconButton>
+ )}
</TooltipTrigger>
<TooltipContent>Open project</TooltipContent>
</Tooltip>
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectRow.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectRow.tsx
index 1a6ebd6d42..0e412dfb15 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectRow.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserProjectsSection/UserProjectRow.tsx
@@ -9,11 +9,12 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
IconButton,
+ RowLink,
TableCell,
TableRow
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-import { getProjectBaseURL, pinProjectForNavigation } from "@app/helpers/project";
+import { getInstancePinningLink, getProjectBaseURL } from "@app/helpers/project";
import { formatProjectRoleName } from "@app/helpers/roles";
import { useGetUserProjects } from "@app/hooks/api";
import { TWorkspaceUser } from "@app/hooks/api/types";
@@ -46,36 +47,37 @@ export const UserProjectRow = ({
return workspaceIds.has(project.id);
}, [workspaces, project]);
+ const projectLink =
+ getInstancePinningLink(
+ currentOrg.id,
+ { id: project.id, type: project.type },
+ "access-management"
+ ) ??
+ ({
+ to: `${getProjectBaseURL(project.type)}/access-management`,
+ params: { orgId: currentOrg.id, projectId: project.id }
+ } as const);
+ const projectSearch = { selectedTab: OrgAccessControlTabSections.Member };
+
return (
<TableRow
key={`user-project-membership-${id}`}
- onClick={() => {
- if (isAccessible) {
- pinProjectForNavigation(currentOrg?.id || "", { id: project.id, type: project.type });
- navigate({
- to: `${getProjectBaseURL(project.type)}/access-management` as const,
- params: {
- orgId: currentOrg?.id || "",
- projectId: project.id
- },
- search: {
- selectedTab: OrgAccessControlTabSections.Member
- }
- });
- return;
- }
-
- createNotification({
- text: "Unable to access project",
- type: "error"
- });
- }}
+ linked={isAccessible}
+ onClick={
+ isAccessible
+ ? undefined
+ : () => createNotification({ text: "Unable to access project", type: "error" })
+ }
>
- <TableCell className="max-w-0 truncate">{project.name}</TableCell>
+ <TableCell className="max-w-0 truncate">
+ <RowLink {...projectLink} search={projectSearch} disabled={!isAccessible}>
+ {project.name}
+ </RowLink>
+ </TableCell>
<TableCell>{`${formatProjectRoleName(roles[0].role, roles[0].customRoleName)}${
roles.length > 1 ? ` (+${roles.length - 1})` : ""
}`}</TableCell>
- <TableCell>
+ <TableCell data-row-interactive>
<DropdownMenu>
<DropdownMenuTrigger>
<IconButton variant="ghost" size="xs">
@@ -87,20 +89,7 @@ export const UserProjectRow = ({
isDisabled={!isAccessible}
onClick={(e) => {
e.stopPropagation();
- pinProjectForNavigation(currentOrg?.id || "", {
- id: project.id,
- type: project.type
- });
- navigate({
- to: `${getProjectBaseURL(project.type)}/access-management` as const,
- params: {
- orgId: currentOrg?.id || "",
- projectId: project.id
- },
- search: {
- selectedTab: OrgAccessControlTabSections.Member
- }
- });
+ navigate({ ...projectLink, search: projectSearch });
}}
>
Access Project