Skip to content

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

misc: hide account path in policy conditions for account

Sheen Capadnganc105bf629dd6
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx
index 7c19122b96..a6da9bfe55 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx
@@ -1,6 +1,10 @@
+import { useMemo } from "react";
+import { useFormContext } from "react-hook-form";
+
import { ProjectPermissionSub } from "@app/context/ProjectPermissionContext/types";
import { ConditionsFields } from "./ConditionsFields";
+import { TFormSchema } from "./ProjectRoleModifySection.utils";
type Props = {
position?: number;
@@ -8,16 +12,38 @@ type Props = {
};
export const PamAccountPermissionConditions = ({ position = 0, isDisabled }: Props) => {
+ const { watch } = useFormContext<TFormSchema>();
+
+ // Check if any existing condition uses accountPath
+ const conditions = watch(
+ `permissions.${ProjectPermissionSub.PamAccounts}.${position}.conditions` as const
+ ) as Array<{ lhs: string; operator: string; rhs: string }> | undefined;
+
+ const hasAccountPathCondition = useMemo(() => {
+ if (!conditions || !Array.isArray(conditions)) return false;
+ return conditions.some((condition) => condition?.lhs === "accountPath");
+ }, [conditions]);
+
+ // Build select options - only include accountPath if it's already being used
+ const selectOptions = useMemo(() => {
+ const options: [{ value: string; label: string }, ...{ value: string; label: string }[]] = [
+ { value: "resourceName", label: "Resource Name" },
+ { value: "accountName", label: "Account Name" }
+ ];
+
+ if (hasAccountPathCondition) {
+ options.push({ value: "accountPath", label: "Account Path (Legacy)" });
+ }
+
+ return options;
+ }, [hasAccountPathCondition]);
+
return (
<ConditionsFields
isDisabled={isDisabled}
subject={ProjectPermissionSub.PamAccounts}
position={position}
- selectOptions={[
- { value: "resourceName", label: "Resource Name" },
- { value: "accountName", label: "Account Name" },
- { value: "accountPath", label: "Account Path" }
- ]}
+ selectOptions={selectOptions}
/>
);
};