Skip to content

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

improvement: migrate webhook ui to v3 components

Scott Wilson24fdf69a311c
diff --git a/frontend/src/components/notifications/Notifications.tsx b/frontend/src/components/notifications/Notifications.tsx
index c108b766e3..f7bbd7e12a 100644
--- a/frontend/src/components/notifications/Notifications.tsx
+++ b/frontend/src/components/notifications/Notifications.tsx
@@ -9,7 +9,7 @@ import { Toaster } from "@app/components/v3/generic/Toast";
import { Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3/generic/Tooltip";
import { useTimedReset } from "@app/hooks";
-export type NotificationType = "success" | "error" | "info" | "warning" | "default";
+export type NotificationType = "success" | "error" | "info" | "warning" | "loading" | "default";
export type TNotification = {
title?: string;
@@ -100,6 +100,7 @@ const toastByType = {
error: toast.error,
info: toast.info,
warning: toast.warning,
+ loading: toast.loading,
default: toast.message
} satisfies Record<NotificationType, typeof toast.message>;
@@ -120,7 +121,7 @@ export const createNotification = (
const hasBody = Boolean(bodyText || children || callToAction || copyActions);
const duration =
- options.autoClose === false
+ type === "loading" || options.autoClose === false
? Infinity
: (options.duration ?? options.autoClose ?? (type === "error" ? 8000 : 3000));
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/submenus.ts b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/submenus.ts
index 22cc8e996c..55a0b90c6b 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/submenus.ts
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/submenus.ts
@@ -30,7 +30,8 @@ import {
ShieldUser,
User,
Users,
- Video
+ Video,
+ Webhook
} from "lucide-react";
import { SubOrgIcon } from "@app/components/v3";
@@ -109,7 +110,7 @@ export const SM_SETTINGS_SUBMENU: Submenu = {
{ label: "Secrets Management", icon: FileKey, tab: "tab-secret-general" },
{ label: "Encryption", icon: Lock, tab: "tab-project-encryption" },
{ label: "Workflow Integrations", icon: Plug, tab: "tab-workflow-integrations" },
- { label: "Webhooks", icon: Cable, tab: "tab-project-webhooks" }
+ { label: "Webhooks", icon: Webhook, tab: "tab-project-webhooks" }
]
};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx
index c9050cc509..3e6423b605 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx
@@ -11,15 +11,25 @@ import {
AccordionItem,
AccordionTrigger,
Button,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
FilterableSelect,
- FormControl,
Input,
- Modal,
- ModalContent,
+ SecretPathInput,
Select,
- SelectItem
-} from "@app/components/v2";
-import { SecretPathInput } from "@app/components/v2/SecretPathInput";
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Sheet,
+ SheetClose,
+ SheetContent,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle
+} from "@app/components/v3";
import {
WEBHOOK_EVENT_METADATA,
WEBHOOK_EVENTS,
@@ -47,7 +57,7 @@ const OptionWithDescription = (props: OptionProps<TWebhookEventOption>) => {
<div className="flex flex-row items-center justify-between">
<div className="min-w-0 flex-1">
<p className="truncate font-medium">{children}</p>
- <p className="truncate text-xs leading-4 text-mineshaft-400">{data.description}</p>
+ <p className="truncate text-xs leading-4 text-muted">{data.description}</p>
</div>
{isSelected && <CheckIcon className="ml-2 size-4 shrink-0" />}
</div>
@@ -116,48 +126,49 @@ export const AddWebhookForm = ({
const generalFormFields = (
<>
- <FormControl
- label="Secret Key"
- isError={Boolean(errors?.webhookSecretKey)}
- errorText={errors?.webhookSecretKey?.message}
- helperText="To generate webhook signature for verification"
- >
- <Input placeholder="Provided during webhook setup" {...register("webhookSecretKey")} />
- </FormControl>
- <FormControl
- label="Webhook URL"
- isRequired
- isError={Boolean(errors?.webhookUrl)}
- errorText={errors?.webhookUrl?.message}
- >
- <Input {...register("webhookUrl")} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="webhook-secret-key">Secret Key</FieldLabel>
+ <Input
+ id="webhook-secret-key"
+ placeholder="Provided during webhook setup"
+ isError={Boolean(errors?.webhookSecretKey)}
+ {...register("webhookSecretKey")}
+ />
+ <FieldError>{errors?.webhookSecretKey?.message}</FieldError>
+ <FieldDescription>To generate webhook signature for verification</FieldDescription>
+ </Field>
+ <Field>
+ <FieldLabel htmlFor="webhook-url">Webhook URL</FieldLabel>
+ <Input id="webhook-url" isError={Boolean(errors?.webhookUrl)} {...register("webhookUrl")} />
+ <FieldError>{errors?.webhookUrl?.message}</FieldError>
+ </Field>
</>
);
const slackFormFields = (
- <FormControl
- label="Incoming Webhook URL"
- isRequired
- isError={Boolean(errors?.webhookUrl)}
- errorText={errors?.webhookUrl?.message}
- >
- <Input placeholder="https://hooks.slack.com/services/..." {...register("webhookUrl")} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="webhook-url">Incoming Webhook URL</FieldLabel>
+ <Input
+ id="webhook-url"
+ placeholder="https://hooks.slack.com/services/..."
+ isError={Boolean(errors?.webhookUrl)}
+ {...register("webhookUrl")}
+ />
+ <FieldError>{errors?.webhookUrl?.message}</FieldError>
+ </Field>
);
const microsoftTeamsFormFields = (
- <FormControl
- label="Incoming Webhook URL"
- isRequired
- isError={Boolean(errors?.webhookUrl)}
- errorText={errors?.webhookUrl?.message}
- >
+ <Field>
+ <FieldLabel htmlFor="webhook-url">Incoming Webhook URL</FieldLabel>
<Input
+ id="webhook-url"
placeholder="https://<tenant>.webhook.office.com/webhookb2/..."
+ isError={Boolean(errors?.webhookUrl)}
{...register("webhookUrl")}
/>
- </FormControl>
+ <FieldError>{errors?.webhookUrl?.message}</FieldError>
+ </Field>
);
const renderFormFields = () => {
@@ -186,154 +197,166 @@ export const AddWebhookForm = ({
}, [isOpen]);
return (
- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
- <ModalContent ref={modalContainer} title="Create a new webhook">
- <form onSubmit={handleSubmit(onCreateWebhook)}>
- <div>
- <Controller
- control={control}
- name="type"
- render={({ field: { onChange, ...field }, fieldState: { error } }) => (
- <FormControl
- label="Type"
- isRequired
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
- className="w-full"
- >
- <SelectItem value={WebhookType.GENERAL} key={WebhookType.GENERAL}>
- General
- </SelectItem>
- <SelectItem value={WebhookType.SLACK} key={WebhookType.SLACK}>
- Slack
- </SelectItem>
- <SelectItem
- value={WebhookType.MICROSOFT_TEAMS}
- key={WebhookType.MICROSOFT_TEAMS}
- >
- Microsoft Teams
- </SelectItem>
- </Select>
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="environment"
- defaultValue={environments?.[0]?.slug}
- render={({ field: { onChange, ...field }, fieldState: { error } }) => (
- <FormControl
- label="Environment"
- isRequired
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
- className="w-full"
- >
- {environments.map(({ name, slug }) => (
- <SelectItem value={slug} key={slug}>
- {name}
- </SelectItem>
- ))}
- </Select>
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="secretPath"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Secret Path"
- isRequired
- isError={Boolean(error)}
- errorText={error?.message}
- helperText="Enter `/` to match all secret paths in the selected environment."
- >
- <SecretPathInput {...field} environment={selectedEnvironment} placeholder="/" />
- </FormControl>
- )}
- />
- {renderFormFields()}
- <Accordion type="single" collapsible className="w-full">
- <AccordionItem value="advanced-settings" className="data-[state=open]:border-none">
- <AccordionTrigger className="h-fit flex-none pl-1 text-sm">
- <div className="order-1 ml-3">Advanced Settings</div>
- </AccordionTrigger>
- <AccordionContent childrenClassName="p-0 pt-2">
- <Controller
- control={control}
- name="enabledEvents"
- render={({ field: { value, onChange } }) => {
- const selectedOptions = EVENT_OPTIONS.filter(
- (option) => value?.[option.value]
- );
- const hasSelection = selectedOptions.length > 0;
-
- const handleChange = (selected: readonly TWebhookEventOption[]) => {
- const next = WEBHOOK_EVENTS.reduce<Record<WebhookEvent, boolean>>(
- (acc, event) => {
- acc[event] = false;
- return acc;
- },
- {} as Record<WebhookEvent, boolean>
+ <Sheet open={isOpen} onOpenChange={onOpenChange}>
+ <SheetContent className="sm:max-w-lg">
+ <div ref={modalContainer} className="flex h-full min-h-0 flex-col">
+ <form onSubmit={handleSubmit(onCreateWebhook)} className="flex h-full min-h-0 flex-col">
+ <SheetHeader>
+ <SheetTitle>Create a new webhook</SheetTitle>
+ </SheetHeader>
+ <div className="flex thin-scrollbar flex-1 flex-col gap-4 overflow-y-auto px-4">
+ <Controller
+ control={control}
+ name="type"
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="webhook-type">Type</FieldLabel>
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger
+ id="webhook-type"
+ className="w-full"
+ aria-invalid={Boolean(error)}
+ >
+ <SelectValue placeholder="Select a type" />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value={WebhookType.GENERAL}>General</SelectItem>
+ <SelectItem value={WebhookType.SLACK}>Slack</SelectItem>
+ <SelectItem value={WebhookType.MICROSOFT_TEAMS}>Microsoft Teams</SelectItem>
+ </SelectContent>
+ </Select>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="environment"
+ defaultValue={environments?.[0]?.slug}
+ render={({ field: { onChange, value }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="webhook-environment">Environment</FieldLabel>
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger
+ id="webhook-environment"
+ className="w-full"
+ aria-invalid={Boolean(error)}
+ >
+ <SelectValue placeholder="Select an environment" />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {environments.map(({ name, slug }) => (
+ <SelectItem value={slug} key={slug}>
+ {name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="secretPath"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="webhook-secret-path">Secret Path</FieldLabel>
+ <SecretPathInput
+ {...field}
+ id="webhook-secret-path"
+ environment={selectedEnvironment}
+ placeholder="/"
+ isError={Boolean(error)}
+ />
+ <FieldError>{error?.message}</FieldError>
+ <FieldDescription>
+ Enter `/` to match all secret paths in the selected environment.
+ </FieldDescription>
+ </Field>
+ )}
+ />
+ {renderFormFields()}
+ <Accordion type="single" collapsible variant="ghost" className="w-full">
+ <AccordionItem value="advanced-settings">
+ <AccordionTrigger>Advanced Settings</AccordionTrigger>
+ <AccordionContent>
+ <Controller
+ control={control}
+ name="enabledEvents"
+ render={({ field: { value, onChange } }) => {
+ const selectedOptions = EVENT_OPTIONS.filter(
+ (option) => value?.[option.value]
);
- selected.forEach((option) => {
- next[option.value] = true;
- });
- onChange(next);
- };
+ const hasSelection = selectedOptions.length > 0;
+
+ const handleChange = (selected: readonly TWebhookEventOption[]) => {
+ const next = WEBHOOK_EVENTS.reduce<Record<WebhookEvent, boolean>>(
+ (acc, event) => {
+ acc[event] = false;
+ return acc;
+ },
+ {} as Record<WebhookEvent, boolean>
+ );
+ selected.forEach((option) => {
+ next[option.value] = true;
+ });
+ onChange(next);
+ };
- return (
- <FormControl
- label="Events"
- helperText={
- !hasSelection
- ? "No events selected — the webhook will fire on all events."
- : "Select which events will trigger this webhook."
- }
- >
- <FilterableSelect
- isMulti
- options={EVENT_OPTIONS}
- value={selectedOptions}
- onChange={(selected) =>
- handleChange(selected as readonly TWebhookEventOption[])
- }
- getOptionValue={(option) => option.value}
- getOptionLabel={(option) => option.label}
- placeholder="Select events..."
- menuPortalTarget={modalContainer.current}
- menuPlacement="bottom"
- closeMenuOnSelect={false}
- hideSelectedOptions={false}
- components={{ Option: OptionWithDescription }}
- />
- </FormControl>
- );
- }}
- />
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- </div>
- <div className="mt-8 flex items-center justify-end">
- <Button type="submit" isDisabled={isSubmitting} isLoading={isSubmitting}>
- Create webhook
- </Button>
- </div>
- </form>
- </ModalContent>
- </Modal>
+ return (
+ <Field>
+ <FieldLabel htmlFor="webhook-events">Events</FieldLabel>
+ <FilterableSelect
+ isMulti
+ inputId="webhook-events"
+ options={EVENT_OPTIONS}
+ value={selectedOptions}
+ onChange={(selected) =>
+ handleChange(selected as readonly TWebhookEventOption[])
+ }
+ getOptionValue={(option) => option.value}
+ getOptionLabel={(option) => option.label}
+ placeholder="Select events..."
+ menuPortalTarget={modalContainer.current}
+ menuPosition="fixed"
+ menuPlacement="bottom"
+ closeMenuOnSelect={false}
+ hideSelectedOptions={false}
+ components={{ Option: OptionWithDescription }}
+ />
+ <FieldDescription>
+ {!hasSelection
+ ? "No events selected. The webhook will fire on all events."
+ : "Select which events will trigger this webhook."}
+ </FieldDescription>
+ </Field>
+ );
+ }}
+ />
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
+ <SheetFooter className="justify-end border-t">
+ <SheetClose asChild>
+ <Button type="button" variant="ghost">
+ Cancel
+ </Button>
+ </SheetClose>
+ <Button
+ type="submit"
+ variant="project"
+ isPending={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create webhook
+ </Button>
+ </SheetFooter>
+ </form>
+ </div>
+ </SheetContent>
+ </Sheet>
);
};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/EditWebhookEventsModal.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/EditWebhookEventsModal.tsx
index 68e99c988e..f39b5498f7 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/EditWebhookEventsModal.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/EditWebhookEventsModal.tsx
@@ -1,8 +1,21 @@
-import { FormEvent, useEffect, useMemo, useRef, useState } from "react";
+import { FormEvent, useEffect, useMemo, useState } from "react";
import { components, OptionProps } from "react-select";
import { CheckIcon } from "lucide-react";
-import { Button, FilterableSelect, FormControl, Modal, ModalContent } from "@app/components/v2";
+import {
+ Button,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldDescription,
+ FieldLabel,
+ FilterableSelect
+} from "@app/components/v3";
import {
TWebhook,
WEBHOOK_EVENT_METADATA,
@@ -39,7 +52,7 @@ const OptionWithDescription = (props: OptionProps<TWebhookEventOption>) => {
<div className="flex flex-row items-center justify-between">
<div className="min-w-0 flex-1">
<p className="truncate font-medium">{children}</p>
- <p className="truncate text-xs leading-4 text-mineshaft-400">{data.description}</p>
+ <p className="truncate text-xs leading-4 text-muted">{data.description}</p>
</div>
{isSelected && <CheckIcon className="ml-2 size-4 shrink-0" />}
</div>
@@ -74,7 +87,6 @@ export const EditWebhookEventsModal = ({
[]
);
const [eventSettings, setEventSettings] = useState<TWebhookEventSettings>(defaultSettings);
- const modalContainer = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!isOpen) return;
@@ -119,52 +131,53 @@ export const EditWebhookEventsModal = ({
};
return (
- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
- <ModalContent
- ref={modalContainer}
- title="Edit Webhook Events"
- subTitle="Select which events should trigger this webhook."
- >
- <form onSubmit={handleSave}>
- <FormControl
- label="Events"
- helperText={
- !hasSelection
- ? "No events selected. The webhook will trigger on all events by default."
- : undefined
- }
- >
+ <Dialog open={isOpen} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-xl">
+ <DialogHeader>
+ <DialogTitle>Edit Webhook Events</DialogTitle>
+ <DialogDescription>Select which events should trigger this webhook.</DialogDescription>
+ </DialogHeader>
+
+ <form onSubmit={handleSave} className="flex flex-col gap-6">
+ <Field>
+ <FieldLabel htmlFor="webhook-events">Events</FieldLabel>
<FilterableSelect
isMulti
+ inputId="webhook-events"
options={EVENT_OPTIONS}
value={selectedOptions}
onChange={(selected) => handleChange(selected as readonly TWebhookEventOption[])}
getOptionValue={(option) => option.value}
getOptionLabel={(option) => option.label}
placeholder="Select events..."
- menuPortalTarget={modalContainer.current}
menuPlacement="bottom"
closeMenuOnSelect={false}
hideSelectedOptions={false}
components={{ Option: OptionWithDescription }}
/>
- </FormControl>
-
- <div className="mt-6 flex items-center justify-end space-x-4">
+ {!hasSelection && (
+ <FieldDescription>
+ No events selected. The webhook will trigger on all events by default.
+ </FieldDescription>
+ )}
+ </Field>
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button type="button" variant="ghost">
+ Cancel
+ </Button>
+ </DialogClose>
<Button
- type="button"
- variant="plain"
- colorSchema="secondary"
- onClick={() => onOpenChange(false)}
+ type="submit"
+ variant="project"
+ isPending={isSubmitting}
+ isDisabled={isSubmitting}
>
- Cancel
- </Button>
- <Button type="submit" isDisabled={isSubmitting} isLoading={isSubmitting}>
Save Changes
</Button>
- </div>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/WebhooksTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/WebhooksTab.tsx
index b5407c7e79..115f07a3e9 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/WebhooksTab.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/WebhooksTab.tsx
@@ -1,39 +1,55 @@
import { useTranslation } from "react-i18next";
-import {
- faEllipsisV,
- faInfoCircle,
- faPencil,
- faPlug,
- faPlus,
- faToggleOff,
- faToggleOn,
- faTrash
-} from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { format } from "date-fns";
+import {
+ Info,
+ MoreHorizontal,
+ Pencil,
+ Plus,
+ Send,
+ ToggleLeft,
+ ToggleRight,
+ Trash2
+} from "lucide-react";
-import { createNotification } from "@app/components/notifications";
+import { createNotification, dismissNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogMedia,
+ AlertDialogTitle,
+ Badge,
Button,
- DeleteActionModal,
+ Card,
+ CardAction,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
- EmptyState,
+ Empty,
+ EmptyHeader,
+ EmptyTitle,
IconButton,
+ Skeleton,
Table,
- TableContainer,
- TableSkeleton,
- TBody,
- Td,
- Th,
- THead,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
Tooltip,
- Tr
-} from "@app/components/v2";
-import { Badge } from "@app/components/v3";
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { withProjectPermission } from "@app/hoc";
import { usePopUp } from "@app/hooks";
@@ -116,7 +132,7 @@ export const WebhooksTab = withProjectPermission(
webhookId: string,
settings: Record<WebhookEvent, boolean>
) => {
- // eventsFilter is the allowlist — every checked event goes in.
+ // eventsFilter is the allowlist; every checked event goes in.
const eventsFilter = WEBHOOK_EVENTS.filter((event) => settings[event]).map((event) => ({
eventName: event
}));
@@ -147,69 +163,92 @@ export const WebhooksTab = withProjectPermission(
};
const handleWebhookTest = async (webhookId: string) => {
- await testWebhook({
- webhookId,
- projectId
- });
- createNotification({
- type: "success",
- text: "Successfully triggered webhook"
+ const toastId = createNotification({
+ type: "loading",
+ text: "Triggering webhook..."
});
+ try {
+ await testWebhook({
+ webhookId,
+ projectId
+ });
+ createNotification({
+ type: "success",
+ text: "Successfully triggered webhook"
+ });
+ } finally {
+ dismissNotification(toastId);
+ }
};
return (
- <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex justify-between">
- <p className="text-xl font-medium text-mineshaft-100">{t("settings.webhooks.title")}</p>
- <ProjectPermissionCan
- I={ProjectPermissionActions.Create}
- a={ProjectPermissionSub.Webhooks}
- >
- {(isAllowed) => (
- <Button
- onClick={() => handlePopUpOpen("addWebhook")}
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- isDisabled={!isAllowed}
- >
- Create
- </Button>
- )}
- </ProjectPermissionCan>
- </div>
- <p className="mb-8 text-gray-400">{t("settings.webhooks.description")}</p>
- <div>
- <TableContainer>
+ <Card>
+ <CardHeader>
+ <CardTitle>{t("settings.webhooks.title")}</CardTitle>
+ <CardDescription>{t("settings.webhooks.description")}</CardDescription>
+ <CardAction>
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Create}
+ a={ProjectPermissionSub.Webhooks}
+ >
+ {(isAllowed) => (
+ <Button
+ variant="project"
+ size="sm"
+ onClick={() => handlePopUpOpen("addWebhook")}
+ isDisabled={!isAllowed}
+ >
+ <Plus />
+ Add Webhook
+ </Button>
+ )}
+ </ProjectPermissionCan>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
+ {!isWebhooksLoading && webhooks && webhooks.length === 0 ? (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyTitle>No webhooks found</EmptyTitle>
+ <EmptyTitle>Add a webhook to get started.</EmptyTitle>
+ </EmptyHeader>
+ </Empty>
+ ) : (
<Table>
- <THead>
- <Tr>
- <Th className="w-1/3">URL</Th>
- <Th className="w-1/5">Environment</Th>
- <Th className="w-1/5">Secret Path</Th>
- <Th>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-[40%]">URL</TableHead>
+ <TableHead className="w-1/5">Environment</TableHead>
+ <TableHead className="w-1/5">Secret Path</TableHead>
+ <TableHead>
<div className="flex items-center gap-1">
<span>Events</span>
- <Tooltip content="Events that are configured to trigger this webhook.">
- <FontAwesomeIcon
- icon={faInfoCircle}
- size="xs"
- className="text-mineshaft-400"
- />
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span>
+ <Info className="size-3.5 text-muted" />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
+ Events that are configured to trigger this webhook.
+ </TooltipContent>
</Tooltip>
</div>
- </Th>
- <Th>Status</Th>
- <Th />
- </Tr>
- </THead>
- <TBody>
- {isWebhooksLoading && <TableSkeleton columns={6} innerKey="webhooks-loading" />}
- {!isWebhooksLoading && webhooks && webhooks?.length === 0 && (
- <Tr>
- <Td colSpan={6}>
- <EmptyState title="No webhooks found" icon={faPlug} />
- </Td>
- </Tr>
- )}
+ </TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead className="w-px text-right" aria-label="Actions" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {isWebhooksLoading &&
+ Array.from({ length: 3 }).map((_, idx) => (
+ // eslint-disable-next-line react/no-array-index-key
+ <TableRow key={`webhook-skeleton-${idx}`}>
+ <TableCell colSpan={6}>
+ <Skeleton className="h-5 w-full" />
+ </TableCell>
+ </TableRow>
+ ))}
{!isWebhooksLoading &&
webhooks?.map((webhook) => {
const {
@@ -223,7 +262,7 @@ export const WebhooksTab = withProjectPermission(
lastRunErrorMessage
} = webhook;
- // eventsFilter is the allowlist — empty means every event is enabled.
+ // eventsFilter is the allowlist; empty means every event is enabled.
const filteredSet = new Set(webhook.eventsFilter.map((e) => e.eventName));
const enabledEvents =
webhook.eventsFilter.length === 0
@@ -234,28 +273,41 @@ export const WebhooksTab = withProjectPermission(
const allEventsEnabled = enabledEventsCount === WEBHOOK_EVENTS.length;
return (
- <Tr key={id}>
- <Td className="max-w-0">
- <Tooltip
- className="max-w-2xl"
- content={<span className="break-all">{url}</span>}
- >
- <div>
- <p className="truncate">{url}</p>
- <p className="truncate text-xs text-mineshaft-400">{id}</p>
- </div>
+ <TableRow key={id} className="h-12">
+ <TableCell className="max-w-0">
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <div className="min-w-0">
+ <p className="truncate">{url}</p>
+ <p className="truncate text-xs text-muted">{id}</p>
+ </div>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-2xl">
+ <span className="break-all">{url}</span>
+ </TooltipContent>
</Tooltip>
- </Td>
- <Td className="max-w-0">
+ </TableCell>
+ <TableCell className="max-w-0">
<p className="truncate">{environment.slug}</p>
- </Td>
- <Td className="max-w-0">
+ </TableCell>
+ <TableCell className="max-w-0">
<p className="truncate">{secretPath}</p>
- </Td>
- <Td>
- <Tooltip
- content={
- hasEnabledEvents ? (
+ </TableCell>
+ <TableCell>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span>
+ <Badge variant="neutral">
+ {allEventsEnabled && "All Events"}
+ {!hasEnabledEvents && "No Events"}
+ {hasEnabledEvents &&
+ !allEventsEnabled &&
+ `${enabledEventsCount} Event${enabledEventsCount === 1 ? "" : "s"}`}
+ </Badge>
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
+ {hasEnabledEvents ? (
<div className="text-xs">
<p className="mb-1 font-medium">Enabled Events:</p>
<ul className="list-disc space-y-0.5 pl-4">
@@ -266,92 +318,76 @@ export const WebhooksTab = withProjectPermission(
</div>
) : (
"This webhook is not triggered by any events."
- )
- }
- >
- <Badge variant="neutral">
- {allEventsEnabled && "All Events"}
- {!hasEnabledEvents && "No Events"}
- {hasEnabledEvents &&
- !allEventsEnabled &&
- `${enabledEventsCount} Event${enabledEventsCount === 1 ? "" : "s"}`}
- </Badge>
+ )}
+ </TooltipContent>
</Tooltip>
- </Td>
- <Td>
+ </TableCell>
+ <TableCell>
{/* eslint-disable-next-line no-nested-ternary */}
{isDisabled ? (
<Badge variant="neutral">Disabled</Badge>
) : !lastStatus ? (
- "-"
+ <span className="text-muted">-</span>
) : (
- <div className="inline-flex w-min items-center rounded-sm bg-mineshaft-600 px-2 py-0.5 text-sm">
- {lastStatus}{" "}
- <Tooltip
- content={
+ <Badge
+ variant={lastStatus === "failed" ? "danger" : "success"}
+ className="capitalize"
+ >
+ {lastStatus}
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span>
+ <Info />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>
<div className="text-xs">
<div>
Updated At:{" "}
{format(new Date(updatedAt), "yyyy-MM-dd, hh:mm aaa")}
</div>
{lastRunErrorMessage && (
- <div className="mt-2 text-red">
+ <div className="mt-2 text-danger">
Error: {lastRunErrorMessage}
</div>
)}
</div>
- }
- >
- <FontAwesomeIcon
- className={`ml-1 ${
- lastStatus === "failed" ? "text-red" : "text-green"
- }`}
- icon={faInfoCircle}
- />
+ </TooltipContent>
</Tooltip>
- </div>
+ </Badge>
)}
- </Td>
- <Td>
- <div className="flex items-center justify-end space-x-2">
- <ProjectPermissionCan
- I={ProjectPermissionActions.Edit}
- a={ProjectPermissionSub.Webhooks}
- >
- {(isAllowed) => (
- <Button
- variant="star"
- size="xs"
- onClick={() => handleWebhookTest(id)}
- isDisabled={
- (isTestWebhookSubmitting &&
- testWebhookVars?.webhookId === id) ||
- !isAllowed
- }
- isLoading={
- isTestWebhookSubmitting && testWebhookVars?.webhookId === id
- }
- >
- Test
- </Button>
- )}
- </ProjectPermissionCan>
+ </TableCell>
+ <TableCell>
+ <div className="flex items-center justify-end gap-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton
- ariaLabel="Options"
- colorSchema="secondary"
- className="w-6"
- variant="plain"
+ variant="ghost"
+ size="xs"
+ aria-label={`Actions for webhook ${url}`}
>
- <FontAwesomeIcon icon={faEllipsisV} />
+ <MoreHorizontal />
</IconButton>
</DropdownMenuTrigger>
- <DropdownMenuContent
- sideOffset={2}
- align="end"
- className="min-w-48 p-1"
- >
+ <DropdownMenuContent align="end" className="w-44">
+ <ProjectPermissionCan
+ I={ProjectPermissionActions.Edit}
+ a={ProjectPermissionSub.Webhooks}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ onClick={() => handleWebhookTest(id)}
+ isDisabled={
+ (isTestWebhookSubmitting &&
+ testWebhookVars?.webhookId === id) ||
+ !isAllowed
+ }
+ >
+ <Send />
+ Test
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
<ProjectPermissionCan
I={ProjectPermissionActions.Edit}
a={ProjectPermissionSub.Webhooks}
@@ -360,8 +396,8 @@ export const WebhooksTab = withProjectPermission(
<DropdownMenuItem
onClick={() => handlePopUpOpen("editWebhook", webhook)}
isDisabled={!isAllowed}
- icon={<FontAwesomeIcon icon={faPencil} />}
>
+ <Pencil />
Edit
</DropdownMenuItem>
)}
@@ -378,12 +414,8 @@ export const WebhooksTab = withProjectPermission(
updateWebhookVars?.webhookId === id) ||
!isAllowed
}
- icon={
- <FontAwesomeIcon
- icon={isDisabled ? faToggleOn : faToggleOff}
- />
- }
>
+ {isDisabled ? <ToggleRight /> : <ToggleLeft />}
{isDisabled ? "Enable" : "Disable"}
</DropdownMenuItem>
)}
@@ -394,10 +426,11 @@ export const WebhooksTab = withProjectPermission(
>
{(isAllowed) => (
<DropdownMenuItem
+ variant="danger"
onClick={() => handlePopUpOpen("deleteWebhook", id)}
isDisabled={!isAllowed}
- icon={<FontAwesomeIcon icon={faTrash} />}
>
+ <Trash2 />
Delete
</DropdownMenuItem>
)}
@@ -405,28 +438,42 @@ export const WebhooksTab = withProjectPermission(
</DropdownMenuContent>
</DropdownMenu>
</div>
- </Td>
- </Tr>
+ </TableCell>
+ </TableRow>
);
})}
- </TBody>
+ </TableBody>
</Table>
- </TableContainer>
- </div>
+ )}
+ </CardContent>
<AddWebhookForm
environments={currentProject?.environments}
isOpen={popUp?.addWebhook?.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("addWebhook", isOpen)}
onCreateWebhook={handleWebhookCreate}
/>
- <DeleteActionModal
- isOpen={popUp.deleteWebhook.isOpen}
- deleteKey="remove"
- title="Are you sure you want to delete this webhook?"
- onChange={(isOpen) => handlePopUpToggle("deleteWebhook", isOpen)}
- onClose={() => handlePopUpClose("deleteWebhook")}
- onDeleteApproved={handleWebhookDelete}
- />
+ <AlertDialog
+ open={popUp.deleteWebhook.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("deleteWebhook", isOpen)}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogMedia>
+ <Trash2 />
+ </AlertDialogMedia>
+ <AlertDialogTitle>Delete this webhook?</AlertDialogTitle>
+ <AlertDialogDescription>
+ This webhook will stop receiving events. This action cannot be undone.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction variant="danger" onClick={handleWebhookDelete}>
+ Delete
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
<EditWebhookEventsModal
isOpen={popUp.editWebhook.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("editWebhook", isOpen)}
@@ -441,7 +488,7 @@ export const WebhooksTab = withProjectPermission(
await handleWebhookEventsUpdate(webhookId, settings);
}}
/>
- </div>
+ </Card>
);
},
{ action: ProjectPermissionActions.Read, subject: ProjectPermissionSub.Webhooks }