Skip to content

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

only show sometimes

Andrey302d6b014bbd
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.ts
index 5fddff29a6..73e55a3b22 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -783,7 +783,8 @@ export const ACCOUNT_TYPE_CONFIGS = {
serviceAccountEmail: {
label: "Service Account Email",
description:
- 'With Impersonation, the service account ID must end with "{{organizationIdPrefix}}", e.g. service-account-{{organizationIdPrefix}}@my-project.iam.gserviceaccount.com'
+ 'The service account ID must end with "{{organizationIdPrefix}}", e.g. service-account-{{organizationIdPrefix}}@my-project.iam.gserviceaccount.com',
+ descriptionWhen: { field: "credentials.authMethod", equals: GcpServiceAccountAuthMethod.Impersonation }
},
authMethod: {
label: "Auth Method",
@@ -997,6 +998,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
forceWhen?: readonly TFieldForcedRuleHint[];
tooltip?: string;
description?: string;
+ descriptionWhen?: TFieldConditionHint;
options?: { label: string; value: string; docsUrl?: string }[];
}
>;
@@ -1352,7 +1354,10 @@ export const PamFieldDescriptorSchema = z.object({
tooltip: z.string().optional(),
// Help text shown under the field
- description: z.string().optional()
+ description: z.string().optional(),
+
+ // Only show the description when the referenced field equals this value
+ descriptionWhen: PamFieldConditionSchema.optional()
});
type PamFieldDescriptor = z.infer<typeof PamFieldDescriptorSchema>;
@@ -1383,6 +1388,7 @@ type TFieldUiHint = {
forceWhen?: readonly TFieldForcedRuleHint[];
tooltip?: string;
description?: string;
+ descriptionWhen?: TFieldConditionHint;
options?: { label: string; value: string; docsUrl?: string }[];
};
@@ -1450,7 +1456,8 @@ const describeField = (
...(resolvedShowWhen ? { showWhen: resolvedShowWhen } : {}),
...(hint.forceWhen ? { forceWhen: [...hint.forceWhen] } : {}),
...(hint.tooltip ? { tooltip: hint.tooltip } : {}),
- ...(hint.description ? { description: hint.description } : {})
+ ...(hint.description ? { description: hint.description } : {}),
+ ...(hint.descriptionWhen ? { descriptionWhen: hint.descriptionWhen } : {})
};
};
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index dced0b1ce6..8eeb4d67cd 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -167,6 +167,7 @@ export type TPamFieldDescriptor = {
forceWhen?: { when: TPamFieldCondition; value: string | number | boolean; reason: string }[];
tooltip?: string;
description?: string;
+ descriptionWhen?: TPamFieldCondition;
};
export type TPamPolicyDescriptor = {
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx
index 461b57833a..b6f3d3db47 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx
@@ -31,6 +31,7 @@ import { useOrganization } from "@app/context";
import { PamFieldWidget, TPamFieldDescriptor } from "@app/hooks/api/pam";
import {
+ isDescriptionVisible,
isFieldVisible,
resolveForcedRule,
TAccountFormValues,
@@ -249,7 +250,9 @@ export const PamSchemaFields = ({ control, setValue, namePrefix, fields, smartPa
isDisabled={Boolean(forcedRule)}
smartPaste={smartPaste?.fieldKey === descriptor.key ? smartPaste : undefined}
/>
- <FieldHelpText text={descriptor.description} />
+ {isDescriptionVisible(descriptor, namePrefix, values) && (
+ <FieldHelpText text={descriptor.description} />
+ )}
{selectedDocsUrl && (
<FieldDescription>
<a
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts b/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts
index c31ec06b5f..7b12e1a131 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts
+++ b/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts
@@ -99,6 +99,12 @@ export const isFieldVisible = (
values: TPamFieldGroupValues
) => !field.showWhen || conditionHolds(field.showWhen, group, values);
+export const isDescriptionVisible = (
+ field: TPamFieldDescriptor,
+ group: TPamFieldGroup,
+ values: TPamFieldGroupValues
+) => !field.descriptionWhen || conditionHolds(field.descriptionWhen, group, values);
+
export const getMissingRequiredFields = (
fields: TPamFieldDescriptor[],
group: TPamFieldGroup,