Skip to content

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

improvements: address feedback

Scott Wilson0b648182707b
diff --git a/frontend/src/views/Alerts/AlertAction.tsx b/frontend/src/views/Alerts/AlertAction.tsx
index f9bc221671..795b4e7f77 100644
--- a/frontend/src/views/Alerts/AlertAction.tsx
+++ b/frontend/src/views/Alerts/AlertAction.tsx
@@ -66,7 +66,9 @@ const formatConditionSummary = (alert: TAlert): string => {
const formatChannelSummary = (alert: TAlert): string =>
Object.values(AlertChannelType)
- .filter((type) => alert.channels.some((channel) => channel.channelType === type))
+ .filter((type) =>
+ alert.channels.some((channel) => channel.channelType === type && channel.enabled)
+ )
.map((type) => ALERT_CHANNEL_TYPE_LABELS[type])
.join(", ");
@@ -111,6 +113,8 @@ export const AlertAction = ({
try {
await deleteAlert.mutateAsync({ alertId: existingAlert.id });
createNotification({ text: "Successfully deleted alert", type: "success" });
+ // Programmatic close bypasses the dialog's onOpenChange reset.
+ setDeleteConfirmation("");
handlePopUpToggle("deleteAlert", false);
} catch {
// MutationCache reports request errors globally; keep the dialog open.
@@ -174,7 +178,9 @@ export const AlertAction = ({
</div>
{!readOnly &&
renderPermissionGate((isAllowed) => (
- <>
+ // Single element (not a fragment): the denied-state gate wraps this in a
+ // tooltip trigger via asChild, which needs one ref-accepting child.
+ <div>
<div className="flex items-center justify-between border-t border-border px-4 py-3">
<Label htmlFor="alert-quick-enable" className="cursor-pointer font-normal">
Enabled
@@ -212,7 +218,7 @@ export const AlertAction = ({
Remove Alert
</Button>
</div>
- </>
+ </div>
))}
</PopoverContent>
</Popover>
diff --git a/frontend/src/views/Alerts/ChannelCard.tsx b/frontend/src/views/Alerts/ChannelCard.tsx
index d5b4145a42..1466045ded 100644
--- a/frontend/src/views/Alerts/ChannelCard.tsx
+++ b/frontend/src/views/Alerts/ChannelCard.tsx
@@ -1,5 +1,6 @@
-import { Controller, useFormContext, useWatch } from "react-hook-form";
-import { SendIcon, TrashIcon } from "lucide-react";
+import { useState } from "react";
+import { Controller, useFormContext, UseFormRegisterReturn, useWatch } from "react-hook-form";
+import { EyeIcon, EyeOffIcon, SendIcon, TrashIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {
@@ -10,6 +11,11 @@ import {
FieldLabel,
IconButton,
Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
+ Label,
Switch
} from "@app/components/v3";
import { useScopeVariant } from "@app/hooks";
@@ -35,6 +41,41 @@ type Props = {
const KEEP_PLACEHOLDER = "•••••••• (leave blank to keep)";
+const ChannelSecretInput = ({
+ id,
+ placeholder,
+ isError,
+ registration
+}: {
+ id: string;
+ placeholder?: string;
+ isError?: boolean;
+ registration: UseFormRegisterReturn;
+}) => {
+ const [isRevealed, setIsRevealed] = useState(false);
+
+ return (
+ <InputGroup>
+ <InputGroupInput
+ {...registration}
+ id={id}
+ type={isRevealed ? "text" : "password"}
+ placeholder={placeholder}
+ autoComplete="off"
+ aria-invalid={Boolean(isError)}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ aria-label={isRevealed ? "Hide value" : "Reveal value"}
+ onClick={() => setIsRevealed((current) => !current)}
+ >
+ {isRevealed ? <EyeOffIcon /> : <EyeIcon />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ );
+};
+
export const ChannelCard = ({
index,
projectId,
@@ -116,18 +157,27 @@ export const ChannelCard = ({
<SendIcon className="size-3.5" />
Send test
</Button>
- <Controller
- control={control}
- name={`channels.${index}.enabled`}
- render={({ field }) => (
- <Switch
- aria-label={`Toggle ${channelLabel} channel`}
- variant={scopeVariant}
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- )}
- />
+ <div className="flex items-center gap-2">
+ <Label
+ htmlFor={`channel-${index}-enabled`}
+ className="cursor-pointer text-xs font-normal text-muted"
+ >
+ Enabled
+ </Label>
+ <Controller
+ control={control}
+ name={`channels.${index}.enabled`}
+ render={({ field }) => (
+ <Switch
+ id={`channel-${index}-enabled`}
+ aria-label={`Toggle ${channelLabel} channel`}
+ variant={scopeVariant}
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ )}
+ />
+ </div>
{canRemove && (
<IconButton aria-label="Remove channel" variant="ghost" size="xs" onClick={onRemove}>
<TrashIcon className="size-4" />
@@ -161,16 +211,15 @@ export const ChannelCard = ({
<Field>
<FieldLabel htmlFor={`channel-${index}-webhookUrl`}>Webhook URL</FieldLabel>
<FieldContent>
- <Input
+ <ChannelSecretInput
id={`channel-${index}-webhookUrl`}
- type="password"
placeholder={
isExisting && channel?.hasWebhookUrl
? KEEP_PLACEHOLDER
: "https://hooks.slack.com/..."
}
isError={Boolean(channelErrors?.webhookUrl)}
- {...register(`channels.${index}.webhookUrl`)}
+ registration={register(`channels.${index}.webhookUrl`)}
/>
<FieldError errors={[channelErrors?.webhookUrl]} />
</FieldContent>
@@ -196,12 +245,11 @@ export const ChannelCard = ({
Signing secret <span className="text-muted">(optional)</span>
</FieldLabel>
<FieldContent>
- <Input
+ <ChannelSecretInput
id={`channel-${index}-signingSecret`}
- type="password"
placeholder={isExisting && channel?.hasSigningSecret ? KEEP_PLACEHOLDER : ""}
isError={Boolean(channelErrors?.signingSecret)}
- {...register(`channels.${index}.signingSecret`)}
+ registration={register(`channels.${index}.signingSecret`)}
/>
<FieldError errors={[channelErrors?.signingSecret]} />
</FieldContent>
@@ -213,16 +261,15 @@ export const ChannelCard = ({
<Field>
<FieldLabel htmlFor={`channel-${index}-integrationKey`}>Integration key</FieldLabel>
<FieldContent>
- <Input
+ <ChannelSecretInput
id={`channel-${index}-integrationKey`}
- type="password"
placeholder={
isExisting && channel?.hasIntegrationKey
? KEEP_PLACEHOLDER
: "32-character integration key"
}
isError={Boolean(channelErrors?.integrationKey)}
- {...register(`channels.${index}.integrationKey`)}
+ registration={register(`channels.${index}.integrationKey`)}
/>
<FieldError errors={[channelErrors?.integrationKey]} />
</FieldContent>
diff --git a/frontend/src/views/Alerts/ChannelsField.tsx b/frontend/src/views/Alerts/ChannelsField.tsx
index 08db2f0171..a022e39cb2 100644
--- a/frontend/src/views/Alerts/ChannelsField.tsx
+++ b/frontend/src/views/Alerts/ChannelsField.tsx
@@ -26,10 +26,9 @@ type Props = {
resourceId?: string | null;
};
-const buildNewChannel = (channelType: AlertChannelType): TChannelForm => ({
+const buildNewChannel = (channelType: AlertChannelType, name: string): TChannelForm => ({
channelType,
- // The name input was dropped from the design; new channels are named after their type.
- name: ALERT_CHANNEL_TYPE_LABELS[channelType],
+ name,
enabled: true,
recipients: [] as { principalType: AlertPrincipalType; principalId: string }[],
webhookUrl: "",
@@ -41,11 +40,24 @@ const buildNewChannel = (channelType: AlertChannelType): TChannelForm => ({
export const ChannelsField = ({ projectId, resourceType, resourceId }: Props) => {
const {
control,
+ getValues,
formState: { errors }
} = useFormContext<TAlertForm>();
const { fields, append, remove } = useFieldArray({ control, name: "channels" });
const rootError = errors.channels?.message || errors.channels?.root?.message;
+ // The name input was dropped from the design; new channels are named after their type,
+ // suffixed to stay unique so multiples remain distinguishable (e.g. in Terraform).
+ const appendChannel = (channelType: AlertChannelType) => {
+ const takenNames = new Set((getValues("channels") ?? []).map((channel) => channel.name));
+ const baseName = ALERT_CHANNEL_TYPE_LABELS[channelType];
+ let name = baseName;
+ for (let suffix = 2; takenNames.has(name); suffix += 1) {
+ name = `${baseName} ${suffix}`;
+ }
+ append(buildNewChannel(channelType, name));
+ };
+
return (
<div className="flex flex-col gap-3">
<div className="flex items-center justify-between">
@@ -71,7 +83,7 @@ export const ChannelsField = ({ projectId, resourceType, resourceId }: Props) =>
{Object.values(AlertChannelType).map((type) => {
const Icon = getChannelIcon(type);
return (
- <DropdownMenuItem key={type} onClick={() => append(buildNewChannel(type))}>
+ <DropdownMenuItem key={type} onClick={() => appendChannel(type)}>
<Icon className="size-4" />
{ALERT_CHANNEL_TYPE_LABELS[type]}
</DropdownMenuItem>