Skip to content

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

misc: addressed comments

Sheen Capadngan29c1aed53196
diff --git a/backend/src/ee/services/permission/default-roles.ts b/backend/src/ee/services/permission/default-roles.ts
index c0c314693d..6f0faba23f 100644
--- a/backend/src/ee/services/permission/default-roles.ts
+++ b/backend/src/ee/services/permission/default-roles.ts
@@ -1163,7 +1163,12 @@ const buildPamResourceConnectorPermissionRules = () => {
const buildPamResourceAuditorPermissionRules = () => {
const { can, rules } = new AbilityBuilder<MongoAbility<ResourcePermissionSet>>(createMongoAbility);
can(
- [ResourcePermissionPamResourceActions.ViewSessions, ResourcePermissionPamResourceActions.ViewAuditLogs],
+ [
+ ResourcePermissionPamResourceActions.ReadFolder,
+ ResourcePermissionPamResourceActions.ReadAccounts,
+ ResourcePermissionPamResourceActions.ViewSessions,
+ ResourcePermissionPamResourceActions.ViewAuditLogs
+ ],
ResourcePermissionSub.PamResource
);
return rules;
diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsx
index 0457f28a29..a5315dc932 100644
--- a/frontend/src/hooks/api/pam/queries.tsx
+++ b/frontend/src/hooks/api/pam/queries.tsx
@@ -207,7 +207,7 @@ export type TAccessiblePamFolder = {
accountCount: number;
};
-export const useListAccessiblePamFolders = () => {
+export const useListAccessiblePamFolders = (options?: { enabled?: boolean }) => {
return useQuery({
queryKey: pamKeys.accessibleFolders(),
queryFn: async () => {
@@ -216,7 +216,8 @@ export const useListAccessiblePamFolders = () => {
{ params: { onlyAccessible: "true" } }
);
return data.folders;
- }
+ },
+ enabled: options?.enabled ?? true
});
};
@@ -262,7 +263,10 @@ export const useListPamAccountsAdmin = (
});
};
-export const useListPamFoldersAdmin = (params?: { search?: string }) => {
+export const useListPamFoldersAdmin = (
+ params?: { search?: string },
+ options?: { enabled?: boolean }
+) => {
return useQuery({
queryKey: pamKeys.listFolders(params),
queryFn: async () => {
@@ -271,7 +275,8 @@ export const useListPamFoldersAdmin = (params?: { search?: string }) => {
{ params }
);
return data.folders;
- }
+ },
+ enabled: options?.enabled ?? true
});
};
diff --git a/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx b/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx
index 906e9fe4e3..e827ec61f2 100644
--- a/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useState } from "react";
+import { useCallback, useEffect, useState } from "react";
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
import { ChevronDown, FolderOpen, FolderPlus, Layers, Plus, Search } from "lucide-react";
@@ -80,13 +80,21 @@ export const PamAccountsPage = () => {
const [resultCounts, setResultCounts] = useState<Record<string, number>>({});
// Check user capabilities to determine admin vs regular user view
- const { data: capabilities } = useGetPamAccessCapabilities();
+ const { data: capabilities, isLoading: isLoadingCapabilities } = useGetPamAccessCapabilities();
const isAdmin = Boolean(capabilities?.isProductAdmin || capabilities?.isResourceAdmin);
// Admin users see all folders; regular users see only accessible folders
- const { data: adminFolders = [], isLoading: isLoadingAdminFolders } = useListPamFoldersAdmin();
- const { data: userFolders = [], isLoading: isLoadingUserFolders } = useListAccessiblePamFolders();
- const isLoadingFolders = isAdmin ? isLoadingAdminFolders : isLoadingUserFolders;
+ // Only enable the relevant hook once capabilities are loaded to avoid duplicate/failing requests
+ const capabilitiesLoaded = !isLoadingCapabilities && capabilities !== undefined;
+ const { data: adminFolders = [], isLoading: isLoadingAdminFolders } = useListPamFoldersAdmin(
+ undefined,
+ { enabled: capabilitiesLoaded && isAdmin }
+ );
+ const { data: userFolders = [], isLoading: isLoadingUserFolders } = useListAccessiblePamFolders({
+ enabled: capabilitiesLoaded && !isAdmin
+ });
+ const isLoadingFolders =
+ isLoadingCapabilities || (isAdmin ? isLoadingAdminFolders : isLoadingUserFolders);
// Admin: filter by templates; Users: filter by account types
const { data: templates = [] } = useListPamAccountTemplates();
@@ -133,6 +141,11 @@ export const PamAccountsPage = () => {
setResultCounts((prev) => (prev[folderId] === count ? prev : { ...prev, [folderId]: count }));
}, []);
+ // Reset result counts when filters change so folder groups recompute counts for new filter
+ useEffect(() => {
+ setResultCounts({});
+ }, [query, selectedTemplateId, selectedAccountType]);
+
// Compute visible folders separately for admin and user views (for proper typing)
const visibleAdminFolders = selectedFolderId
? adminFolders.filter((folder) => folder.id === selectedFolderId)
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
index f5df57a2e6..4073d446b7 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
@@ -40,9 +40,16 @@ export const AccountActionsMenu = ({
}: Props) => {
const { can, isLoading } = usePamAccountActions(accountId, true);
+ const canLaunch = can(PamResourcePermissionActions.LaunchSessions);
const canDelete = can(PamResourcePermissionActions.DeleteAccounts);
const isRotatable = isRotatablePamAccountType(accountType);
+ // Launch requires both: account is provisioned AND user has permission
+ const isLaunchDisabled = !isAccessible || !canLaunch;
+ const launchDisabledReason = !canLaunch
+ ? "You don't have permission to launch sessions"
+ : "This account is not ready to launch";
+
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -63,16 +70,14 @@ export const AccountActionsMenu = ({
<Tooltip>
<TooltipTrigger asChild>
<div>
- <DropdownMenuItem isDisabled={!isAccessible} onClick={onLaunch}>
+ <DropdownMenuItem isDisabled={isLaunchDisabled} onClick={onLaunch}>
<Rocket className="size-4" />
Launch Session
</DropdownMenuItem>
</div>
</TooltipTrigger>
- {!isAccessible && (
- <TooltipContent side="left">
- You don&apos;t have access to launch this account
- </TooltipContent>
+ {isLaunchDisabled && (
+ <TooltipContent side="left">{launchDisabledReason}</TooltipContent>
)}
</Tooltip>
<DropdownMenuSeparator />
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountRowActions.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountRowActions.tsx
new file mode 100644
index 0000000000..d4081c10cd
--- /dev/null
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountRowActions.tsx
@@ -0,0 +1,58 @@
+import { Rocket } from "lucide-react";
+
+import { IconButton } from "@app/components/v3";
+import {
+ PamAccountType,
+ PamResourcePermissionActions,
+ usePamAccountActions
+} from "@app/hooks/api/pam";
+import { PamSheetTab } from "@app/hooks/usePamSheetState";
+
+import { AccountActionsMenu } from "./AccountActionsMenu";
+
+type Props = {
+ accountId: string;
+ accountType: PamAccountType;
+ isAccessible: boolean;
+ onLaunch: () => void;
+ onOpenTab: (tab: PamSheetTab) => void;
+ onDelete: () => void;
+};
+
+export const AccountRowActions = ({
+ accountId,
+ accountType,
+ isAccessible,
+ onLaunch,
+ onOpenTab,
+ onDelete
+}: Props) => {
+ const { can } = usePamAccountActions(accountId, true);
+ const canLaunch = can(PamResourcePermissionActions.LaunchSessions);
+
+ // Launch requires both: account is provisioned AND user has permission
+ const isLaunchDisabled = !isAccessible || !canLaunch;
+
+ return (
+ <div className="flex items-center gap-0.5">
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label="Launch session"
+ className="text-muted hover:text-foreground"
+ isDisabled={isLaunchDisabled}
+ onClick={onLaunch}
+ >
+ <Rocket className="size-4" />
+ </IconButton>
+ <AccountActionsMenu
+ accountId={accountId}
+ accountType={accountType}
+ isAccessible={isAccessible}
+ onLaunch={onLaunch}
+ onOpenTab={onOpenTab}
+ onDelete={onDelete}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
index 8cdba8f384..8ba0f82ead 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx
@@ -1,8 +1,8 @@
import { useEffect, useMemo } from "react";
-import { ChevronRight, Folder, FolderOpen, Rocket } from "lucide-react";
+import { ChevronRight, Folder, FolderOpen } from "lucide-react";
import { HighlightText } from "@app/components/v2/HighlightText";
-import { Badge, IconButton, TableCell, TableRow } from "@app/components/v3";
+import { Badge, TableCell, TableRow } from "@app/components/v3";
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import {
PamAccountType,
@@ -15,7 +15,7 @@ import { PamSheetTab } from "@app/hooks/usePamSheetState";
import { AccountAccessibilityBadge } from "../../components/AccountAccessibilityBadge";
import { AccountPlatformIcon } from "../../PamAccessPage/components/AccountPlatformIcon";
-import { AccountActionsMenu } from "./AccountActionsMenu";
+import { AccountRowActions } from "./AccountRowActions";
import { FolderActionsMenu } from "./FolderActionsMenu";
type Props = {
@@ -155,26 +155,14 @@ export const FolderAccountRows = ({
</TableCell>
<TableCell className="w-20">
<div className="flex items-center justify-end">
- <div className="flex items-center gap-0.5">
- <IconButton
- variant="ghost"
- size="xs"
- aria-label="Launch session"
- className="text-muted hover:text-foreground"
- isDisabled={!account.isAccessible}
- onClick={() => onLaunchAccount(launchableAccount)}
- >
- <Rocket className="size-4" />
- </IconButton>
- <AccountActionsMenu
- accountId={account.id}
- accountType={accountType}
- isAccessible={account.isAccessible}
- onLaunch={() => onLaunchAccount(launchableAccount)}
- onOpenTab={(tab) => onOpenAccount(account.id, tab)}
- onDelete={() => onDeleteAccount(account.id, account.name, accountType)}
- />
- </div>
+ <AccountRowActions
+ accountId={account.id}
+ accountType={accountType}
+ isAccessible={account.isAccessible}
+ onLaunch={() => onLaunchAccount(launchableAccount)}
+ onOpenTab={(tab) => onOpenAccount(account.id, tab)}
+ onDelete={() => onDeleteAccount(account.id, account.name, accountType)}
+ />
</div>
</TableCell>
</TableRow>