Skip to content

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

fix(frontend): make machine identity table rows real links (#8910)

Andrew Huangd4243c051a55
diff --git a/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsx b/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsx
index b2de34ffcb..f7d9ec981d 100644
--- a/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsx
+++ b/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsx
@@ -58,7 +58,9 @@ const RoleBadge = ({ role, className }: { role: TIdentityRoleBadge; className?:
return (
<Tooltip>
- <TooltipTrigger asChild>{badge}</TooltipTrigger>
+ <TooltipTrigger asChild className="relative z-10">
+ {badge}
+ </TooltipTrigger>
<TooltipContent className="flex flex-col gap-0.5">
<span className="capitalize">{label}</span>
{role.isTemporary && (
@@ -89,7 +91,7 @@ export const IdentityRoleBadges = ({
{overflow.length > 0 && (
<Popover>
<Tooltip>
- <TooltipTrigger className="flex h-4 items-center">
+ <TooltipTrigger className="relative z-10 flex h-4 items-center">
<PopoverTrigger asChild>
<Badge variant="neutral" asChild>
<button type="button" onClick={(e) => e.stopPropagation()}>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
index 9e5f8cf89f..2bc3ee4722 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
@@ -1,5 +1,5 @@
import { useState } from "react";
-import { useNavigate } from "@tanstack/react-router";
+import { Link, useNavigate } from "@tanstack/react-router";
import { formatDistanceToNow } from "date-fns";
import {
ChevronDownIcon,
@@ -51,11 +51,7 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context";
-import {
- getProjectBaseURL,
- getProjectDisplayName,
- pinProjectForNavigation
-} from "@app/helpers/project";
+import { getProjectBaseURL, getProjectDisplayName } from "@app/helpers/project";
import {
getUserTablePreference,
PreferenceKey,
@@ -72,6 +68,7 @@ import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance"
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { IdentityMembershipSearchResult, SearchIdentitiesScope } from "@app/hooks/api/identities";
import { OrgIdentityOrderBy } from "@app/hooks/api/organization/types";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { usePopUp, UsePopUpState } from "@app/hooks/usePopUp";
import { IdentityAuthMethodModal } from "@app/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal";
import { IdentityAuthMethodSheet } from "@app/views/IdentityAuthMethods";
@@ -195,7 +192,7 @@ const LastUsedCell = ({ lastLoginAuthMethod, lastLoginTime }: LastUsedCellProps)
return (
<Tooltip>
<TooltipTrigger asChild>
- <span className="cursor-default text-sm text-foreground/80">{label}</span>
+ <span className="relative z-10 cursor-default text-sm text-foreground/80">{label}</span>
</TooltipTrigger>
<TooltipContent className="max-w-96 min-w-52">
<LastLoginSection
@@ -396,28 +393,49 @@ const IdentityRow = ({ membership, onDelete, onManageAuth, onAddAuthMethod }: Id
const isSubOrgIdentity = currentOrg.id === orgId;
const isProjectScoped = scope === SearchIdentitiesScope.ProjectScope;
- const navigateToIdentity = () => {
- if (isProjectScoped && project) {
- pinProjectForNavigation(currentOrg.id, project);
- navigate({
- to: `${getProjectBaseURL(project.type)}/identities/$identityId` as const,
- params: {
- orgId: currentOrg.id,
- projectId: project.id,
- identityId: id
- }
- });
- return;
+ const getIdentityLink = () => {
+ if (!isProjectScoped || !project) {
+ return {
+ to: "/organizations/$orgId/identities/$identityId",
+ params: { identityId: id, orgId: currentOrg.id }
+ } as const;
+ }
+ // Certificate Manager and Secret Scanning URLs carry no project id, so link through their
+ // legacy project URL, whose redirect pins the instance in whichever tab opens the link.
+ const legacyProjectParams = {
+ orgId: currentOrg.id,
+ projectId: project.id,
+ _splat: `identities/${id}`
+ };
+ if (project.type === ProjectType.CertificateManager) {
+ return {
+ to: "/organizations/$orgId/projects/cert-manager/$projectId/$",
+ params: legacyProjectParams
+ } as const;
}
- navigate({
- to: "/organizations/$orgId/identities/$identityId",
- params: { identityId: id, orgId: currentOrg.id }
- });
+ if (project.type === ProjectType.SecretScanning) {
+ return {
+ to: "/organizations/$orgId/projects/secret-scanning/$projectId/$",
+ params: legacyProjectParams
+ } as const;
+ }
+ return {
+ to: `${getProjectBaseURL(project.type)}/identities/$identityId`,
+ params: { orgId: currentOrg.id, projectId: project.id, identityId: id }
+ } as const;
};
+ const identityLink = getIdentityLink();
return (
- <TableRow className="cursor-pointer" onClick={navigateToIdentity}>
- <TableCell isTruncatable>{name}</TableCell>
+ <TableRow className="relative cursor-pointer">
+ <TableCell isTruncatable>
+ <Link
+ {...identityLink}
+ className="block truncate outline-0 after:absolute after:inset-0 after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-ring"
+ >
+ {name}
+ </Link>
+ </TableCell>
<TableCell>
<IdentityRoleBadges roles={membershipRoles ?? []} />
</TableCell>
@@ -432,7 +450,7 @@ const IdentityRow = ({ membership, onDelete, onManageAuth, onAddAuthMethod }: Id
<TableCell>
<LastUsedCell lastLoginAuthMethod={lastLoginAuthMethod} lastLoginTime={lastLoginTime} />
</TableCell>
- <TableCell variant="action">
+ <TableCell variant="action" className="relative z-10">
<div className="flex items-center justify-end gap-2">
{(activeLockoutAuthMethods?.length ?? 0) > 0 && (
<Tooltip>
@@ -453,7 +471,7 @@ const IdentityRow = ({ membership, onDelete, onManageAuth, onAddAuthMethod }: Id
isSubOrgIdentity={isSubOrgIdentity}
authMethods={authMethods ?? []}
activeLockoutAuthMethods={activeLockoutAuthMethods}
- onEdit={navigateToIdentity}
+ onEdit={() => navigate(identityLink)}
onDelete={() => onDelete({ identityId: id, name })}
onManageAuth={(authMethod) => onManageAuth({ identityId: id, authMethod })}
onAddAuthMethod={() =>
diff --git a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
index 6fb0a7ca96..3519c834f1 100644
--- a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
@@ -1,6 +1,6 @@
import { useCallback, useState } from "react";
import { subject } from "@casl/ability";
-import { useNavigate } from "@tanstack/react-router";
+import { Link } from "@tanstack/react-router";
import {
ChevronDownIcon,
FilterIcon,
@@ -98,7 +98,6 @@ export const IdentityTab = withProjectPermission(
() => {
const scopeVariant = useScopeVariant();
const { currentProject, projectId } = useProject();
- const navigate = useNavigate();
const { isSubOrganization, currentOrg } = useOrganization();
const productLabel = getProjectLabel(currentProject?.type);
const projectsHidden = hidesProjects(currentProject?.type);
@@ -378,37 +377,20 @@ export const IdentityTab = withProjectPermission(
roles
} = identityMember;
return (
- <TableRow
- className="group cursor-pointer"
- key={`st-v3-${id}`}
- role="button"
- tabIndex={0}
- onKeyDown={(evt) => {
- if (evt.target !== evt.currentTarget) return;
- if (evt.key === "Enter" || evt.key === " ") {
- evt.preventDefault();
- navigate({
- to: `${getProjectBaseURL(currentProject.type)}/identities/$identityId` as const,
- params: {
- orgId: currentOrg.id,
- projectId: currentProject.id,
- identityId: id
- }
- });
- }
- }}
- onClick={() =>
- navigate({
- to: `${getProjectBaseURL(currentProject.type)}/identities/$identityId` as const,
- params: {
+ <TableRow className="group relative cursor-pointer" key={`st-v3-${id}`}>
+ <TableCell isTruncatable>
+ <Link
+ to={`${getProjectBaseURL(currentProject.type)}/identities/$identityId`}
+ params={{
orgId: currentOrg.id,
projectId: currentProject.id,
identityId: id
- }
- })
- }
- >
- <TableCell isTruncatable>{name}</TableCell>
+ }}
+ className="block truncate outline-0 after:absolute after:inset-0 after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-ring"
+ >
+ {name}
+ </Link>
+ </TableCell>
<TableCell>
<IdentityRoleBadges roles={roles} />
</TableCell>
@@ -442,7 +424,7 @@ export const IdentityTab = withProjectPermission(
)}
</Badge>
</TableCell>
- <TableCell>
+ <TableCell className="relative z-10">
<div className="flex items-center justify-end gap-2">
{(activeLockoutAuthMethods?.length ?? 0) > 0 && (
<Tooltip>