Skip to content

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

update ui

Thiago Araujo da Silvaf90931415761
diff --git a/backend/src/services/alert/alert-dal.test.ts b/backend/src/services/alert/alert-dal.test.ts
index 741ea568ac..79f47ddb5d 100644
--- a/backend/src/services/alert/alert-dal.test.ts
+++ b/backend/src/services/alert/alert-dal.test.ts
@@ -33,12 +33,12 @@ describe("alert dal", () => {
test("findEnabledByResourceType excludes alerts in soft-deleted projects", async () => {
const { dal, calls } = buildDAL();
- await dal.findEnabledByResourceType("identity.credential");
+ await dal.findEnabledByResourceType("identity.authentication");
expect(calls.leftJoin.some((args) => args[0] === TableName.Project)).toBe(true);
expect(calls.whereNull).toContainEqual(`${TableName.Project}.deleteAfter`);
expect(calls.where).toContainEqual([`${TableName.Alert}.enabled`, true]);
- expect(calls.where).toContainEqual([`${TableName.Alert}.resourceType`, "identity.credential"]);
+ expect(calls.where).toContainEqual([`${TableName.Alert}.resourceType`, "identity.authentication"]);
// the cron sweep must only pick up scheduled alerts, never event-driven ones
expect(calls.where).toContainEqual([`${TableName.Alert}.triggerType`, "scheduled"]);
});
diff --git a/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts b/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts
index 488c665106..60d32de0ef 100644
--- a/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts
+++ b/backend/src/services/alert/providers/identity-credential-alert-provider.test.ts
@@ -4,8 +4,8 @@ import { vi } from "vitest";
import { AlertPermissionAction, TAlertContext } from "../alert-types";
import { TExpiringUaClientSecret } from "./identity-credential-alert-dal";
import {
+ IDENTITY_AUTHENTICATION_RESOURCE_TYPE,
IDENTITY_CREDENTIAL_EXPIRY_EVENT,
- IDENTITY_CREDENTIAL_RESOURCE_TYPE,
identityCredentialAlertProviderFactory,
TIdentityCredentialAlertProviderDep
} from "./identity-credential-alert-provider";
@@ -30,7 +30,7 @@ const alertContext = (overrides: Partial<TAlertContext> = {}): TAlertContext =>
id: "alert-1",
name: "ua-expiry",
orgId: "org-1",
- resourceType: IDENTITY_CREDENTIAL_RESOURCE_TYPE,
+ resourceType: IDENTITY_AUTHENTICATION_RESOURCE_TYPE,
resourceId: null,
eventType: IDENTITY_CREDENTIAL_EXPIRY_EVENT,
condition: { alertBefore: "30d" },
diff --git a/backend/src/services/alert/providers/identity-credential-alert-provider.ts b/backend/src/services/alert/providers/identity-credential-alert-provider.ts
index b17dd95492..ff14aad5b7 100644
--- a/backend/src/services/alert/providers/identity-credential-alert-provider.ts
+++ b/backend/src/services/alert/providers/identity-credential-alert-provider.ts
@@ -20,7 +20,7 @@ import {
} from "../alert-types";
import { TExpiringUaClientSecret, TIdentityCredentialAlertDALFactory } from "./identity-credential-alert-dal";
-export const IDENTITY_CREDENTIAL_RESOURCE_TYPE = "identity.credential";
+export const IDENTITY_AUTHENTICATION_RESOURCE_TYPE = "identity.authentication";
export const IDENTITY_CREDENTIAL_EXPIRY_EVENT = "identity.credential.expiry";
const alertBeforeRegex = new RE2("^\\d+[dwmy]$");
@@ -221,7 +221,7 @@ export const identityCredentialAlertProviderFactory = ({
};
return {
- resourceType: IDENTITY_CREDENTIAL_RESOURCE_TYPE,
+ resourceType: IDENTITY_AUTHENTICATION_RESOURCE_TYPE,
eventTypes: [IDENTITY_CREDENTIAL_EXPIRY_EVENT],
conditionSchema: IdentityCredentialConditionSchema,
findDueTargets,
diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.ts
index 97870dc8b5..d5cbcf8b39 100644
--- a/frontend/src/hooks/api/alerts/types.ts
+++ b/frontend/src/hooks/api/alerts/types.ts
@@ -1,11 +1,9 @@
import { z } from "zod";
-// Resource types an alert can attach to. Only identity credentials are supported for now.
export enum AlertResourceType {
- IdentityCredential = "identity.credential"
+ IdentityAuthentication = "identity.authentication"
}
-// Events an alert can fire on. Only expiration is supported for now.
export enum AlertEventType {
IdentityCredentialExpiry = "identity.credential.expiry"
}
@@ -37,7 +35,7 @@ export const ALERT_TIME_UNIT_LABELS: Record<AlertTimeUnit, string> = {
};
export const ALERT_RESOURCE_TYPE_LABELS: Record<AlertResourceType, string> = {
- [AlertResourceType.IdentityCredential]: "Identity Credential"
+ [AlertResourceType.IdentityAuthentication]: "Machine Identity Authentication"
};
export const ALERT_EVENT_TYPE_LABELS: Record<AlertEventType, string> = {
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx
index 48efb97359..576ea47713 100644
--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx
+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertDetail.tsx
@@ -4,6 +4,7 @@ import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
import { DeleteActionModal } from "@app/components/v2";
import {
+ Badge,
Button,
Detail,
DetailLabel,
@@ -16,7 +17,14 @@ import {
} from "@app/components/v3";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/context";
import { usePopUp } from "@app/hooks";
-import { AlertResourceType, TAlert, useDeleteAlert, useListAlerts } from "@app/hooks/api/alerts";
+import {
+ ALERT_EVENT_TYPE_LABELS,
+ AlertEventType,
+ AlertResourceType,
+ TAlert,
+ useDeleteAlert,
+ useListAlerts
+} from "@app/hooks/api/alerts";
import { AddAlertModal } from "@app/views/AlertsPage/components/AddAlertModal";
type Props = {
@@ -24,13 +32,19 @@ type Props = {
identityName: string;
};
-// "Alert" subsection of the identity Details card. Shows the single alert bound to this identity
-// (name, event, channel icons) and opens the drawer in edit mode when clicked. When none exists it
-// offers a create action pre-bound to the identity. Uniqueness (one alert per resource + event) is
-// enforced by the backend, so at most one alert is ever returned here.
+const TIME_UNIT_WORD: Record<string, string> = { d: "day", w: "week", m: "month", y: "year" };
+
+const formatCondition = (alertBefore?: string): string => {
+ const match = alertBefore?.match(/^(\d+)([dwmy])$/);
+ if (!match) return "";
+ const amount = parseInt(match[1], 10);
+ const word = TIME_UNIT_WORD[match[2]] ?? match[2];
+ return `alert ${amount} ${word}${amount === 1 ? "" : "s"} before`;
+};
+
export const IdentityAlertDetail = ({ identityId, identityName }: Props) => {
const { data: alerts = [] } = useListAlerts({
- resourceType: AlertResourceType.IdentityCredential,
+ resourceType: AlertResourceType.IdentityAuthentication,
resourceId: identityId
});
@@ -40,6 +54,13 @@ export const IdentityAlertDetail = ({ identityId, identityName }: Props) => {
const existingAlert = alerts[0] as TAlert | undefined;
+ const eventLabel = existingAlert
+ ? (ALERT_EVENT_TYPE_LABELS[existingAlert.eventType as AlertEventType] ??
+ existingAlert.eventType)
+ : "";
+ const conditionLabel = formatCondition(existingAlert?.condition?.alertBefore);
+ const summary = [eventLabel, conditionLabel].filter(Boolean).join(" · ");
+
const handleDeleteAlert = async () => {
if (!existingAlert) return;
@@ -57,15 +78,11 @@ export const IdentityAlertDetail = ({ identityId, identityName }: Props) => {
<DetailLabel>Alert</DetailLabel>
<DetailValue>
{existingAlert ? (
- <div className="flex w-full items-center gap-2 rounded-md border border-border p-3">
- <span
- className={`size-2 shrink-0 rounded-full ${existingAlert.enabled ? "bg-success" : "bg-muted"}`}
- title={existingAlert.enabled ? "Enabled" : "Disabled"}
- aria-hidden
- />
- <span className="min-w-0 flex-1 truncate text-xs text-foreground">
- {existingAlert.name}
- </span>
+ <div className="flex w-full items-center gap-2">
+ <Badge variant={existingAlert.enabled ? "success" : "neutral"}>
+ {existingAlert.enabled ? "Enabled" : "Disabled"}
+ </Badge>
+ <span className="min-w-0 flex-1 truncate text-xs text-muted">{summary}</span>
<OrgPermissionCan
I={OrgPermissionIdentityActions.Edit}
a={OrgPermissionSubjects.Identity}
diff --git a/frontend/src/views/AlertsPage/components/AlertForm.tsx b/frontend/src/views/AlertsPage/components/AlertForm.tsx
index 88a20ac37a..3b959407fa 100644
--- a/frontend/src/views/AlertsPage/components/AlertForm.tsx
+++ b/frontend/src/views/AlertsPage/components/AlertForm.tsx
@@ -1,7 +1,7 @@
import { ReactNode } from "react";
import { Controller, FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { CircleHelpIcon, FingerprintIcon, KeyRoundIcon, LockIcon } from "lucide-react";
+import { CircleHelpIcon, FingerprintIcon, KeyRoundIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {
@@ -51,8 +51,6 @@ import { ChannelsField } from "./ChannelsField";
type Props = {
projectId?: string;
scopeName?: string;
- // When set, the alert is bound to a single resource (e.g. one machine identity) rather than
- // watching every credential in the scope. resourceName is used only for display.
resourceId?: string;
resourceName?: string;
alert?: TAlert;
@@ -66,18 +64,10 @@ const SectionHeader = ({ step, title }: { step: number; title: string }) => (
</p>
);
-// Resource type, event, and scope are fixed for this alert type, so they render as read-only cards
-// rather than single-option dropdowns.
const FixedField = ({ label, children }: { label: string; children: ReactNode }) => (
<div className="flex flex-col gap-1.5">
<FieldLabel>{label}</FieldLabel>
- <Card className="flex-row items-center justify-between gap-3">
- <div className="flex items-center gap-3">{children}</div>
- <span className="flex items-center gap-1 text-xs text-muted">
- <LockIcon className="size-3" />
- Fixed
- </span>
- </Card>
+ <Card className="flex-row items-center gap-3">{children}</Card>
</div>
);
@@ -107,7 +97,7 @@ const buildFormDefaults = (alert?: TAlert): TAlertForm => {
return {
name: "",
description: "",
- resourceType: AlertResourceType.IdentityCredential,
+ resourceType: AlertResourceType.IdentityAuthentication,
eventType: AlertEventType.IdentityCredentialExpiry,
alertBeforeValue: 7,
alertBeforeUnit: AlertTimeUnit.Days,
@@ -122,7 +112,8 @@ const buildFormDefaults = (alert?: TAlert): TAlertForm => {
return {
name: alert.name,
description: alert.description ?? "",
- resourceType: (alert.resourceType as AlertResourceType) ?? AlertResourceType.IdentityCredential,
+ resourceType:
+ (alert.resourceType as AlertResourceType) ?? AlertResourceType.IdentityAuthentication,
eventType: (alert.eventType as AlertEventType) ?? AlertEventType.IdentityCredentialExpiry,
alertBeforeValue: value,
alertBeforeUnit: unit,
@@ -206,13 +197,13 @@ export const AlertForm = ({
: "text-org";
// eslint-disable-next-line no-nested-ternary
const scopeTitle = isResourceScope
- ? `Machine Identity · ${resourceName ?? "this identity"}`
+ ? `${resourceName ?? "this identity"}`
: isProjectScope
? `Project · ${scopeName ?? "this project"}`
- : "Organization-wide";
+ : "Organization";
// eslint-disable-next-line no-nested-ternary
const scopeDescription = isResourceScope
- ? "Watches this machine identity's credentials"
+ ? "Watches this machine identity's authentications"
: isProjectScope
? "Watches every identity credential in this project"
: "Watches every identity credential in this organization";
@@ -304,36 +295,48 @@ export const AlertForm = ({
<Controller
control={control}
name="resourceType"
- render={({ field: { value, onChange } }) => (
- <Field>
- <FieldLabel>Resource type</FieldLabel>
- <FieldContent>
- <Select value={value} onValueChange={onChange}>
- <SelectTrigger className="w-full">
- <SelectValue />
- </SelectTrigger>
- <SelectContent position="popper">
- {Object.values(AlertResourceType).map((resourceType) => (
- <SelectItem key={resourceType} value={resourceType}>
- <span className="flex items-center gap-2">
- <KeyRoundIcon className="size-4 text-muted" />
- <span className="font-medium">
- {ALERT_RESOURCE_TYPE_LABELS[resourceType]}
+ render={({ field: { value, onChange } }) =>
+ isResourceScope ? (
+ <FixedField label="Resource type">
+ <KeyRoundIcon className="size-5 text-muted" />
+ <div className="flex items-center gap-2">
+ <span className="text-sm text-foreground">
+ {ALERT_RESOURCE_TYPE_LABELS[value]}
+ </span>
+ <span className="font-mono text-xs text-muted">{value}</span>
+ </div>
+ </FixedField>
+ ) : (
+ <Field>
+ <FieldLabel>Resource type</FieldLabel>
+ <FieldContent>
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {Object.values(AlertResourceType).map((resourceType) => (
+ <SelectItem key={resourceType} value={resourceType}>
+ <span className="flex items-center gap-2">
+ <KeyRoundIcon className="size-4 text-muted" />
+ <span className="font-medium">
+ {ALERT_RESOURCE_TYPE_LABELS[resourceType]}
+ </span>
+ <span className="font-mono text-xs text-muted">{resourceType}</span>
</span>
- <span className="font-mono text-xs text-muted">{resourceType}</span>
- </span>
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </FieldContent>
- </Field>
- )}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </FieldContent>
+ </Field>
+ )
+ }
/>
<FixedField label="Scope">
<ScopeIcon className={`size-5 ${scopeColor}`} />
- <div className="flex flex-col">
+ <div className="flex items-center gap-2">
<span className="text-sm text-foreground">{scopeTitle}</span>
<span className="text-xs text-muted">{scopeDescription}</span>
</div>
@@ -342,37 +345,20 @@ export const AlertForm = ({
<Controller
control={control}
name="eventType"
- render={({ field: { value, onChange } }) => (
- <Field>
- <FieldLabel>Event</FieldLabel>
- <FieldContent>
- <Select value={value} onValueChange={onChange}>
- <SelectTrigger className="w-full">
- <SelectValue />
- </SelectTrigger>
- <SelectContent position="popper">
- {Object.values(AlertEventType).map((eventType) => (
- <SelectItem key={eventType} value={eventType}>
- <span className="flex items-center gap-2">
- <Badge variant="warning">{ALERT_EVENT_TYPE_LABELS[eventType]}</Badge>
- <span className="text-muted">
- Fires as the credential nears expiration
- </span>
- </span>
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </FieldContent>
- </Field>
+ render={({ field: { value } }) => (
+ <FixedField label="Event">
+ <Badge variant="warning">{ALERT_EVENT_TYPE_LABELS[value]}</Badge>
+ <span className="text-xs text-muted">
+ Fires as the credential nears expiration
+ </span>
+ </FixedField>
)}
/>
<div className="flex flex-col gap-1.5">
- <FieldLabel>Condition</FieldLabel>
+ <FieldLabel>Alert before</FieldLabel>
<div className="flex flex-col gap-1">
<div className="flex items-center gap-3">
- <span className="text-sm text-foreground">Alert before</span>
<Input
id="alert-alert-before"
type="number"