Files
outline/plugins/webhooks/client/actions.tsx
T
Tom Moor 321b232f17 Move "Webhook" settings to table (#12119)
* Move 'Webhook' settings to table

* Add tests
2026-04-19 19:27:32 -04:00

85 lines
2.3 KiB
TypeScript

import { EditIcon, PlusIcon, TrashIcon } from "outline-icons";
import stores from "~/stores";
import type WebhookSubscription from "~/models/WebhookSubscription";
import { createAction } from "~/actions";
import { SettingsSection } from "~/actions/sections";
import WebhookSubscriptionDeleteDialog from "./components/WebhookSubscriptionDeleteDialog";
import WebhookSubscriptionEdit from "./components/WebhookSubscriptionEdit";
import WebhookSubscriptionNew from "./components/WebhookSubscriptionNew";
export const createWebhookSubscription = createAction({
name: ({ t }) => t("New webhook"),
analyticsName: "New webhook",
section: SettingsSection,
icon: <PlusIcon />,
keywords: "create",
visible: () =>
stores.policies.abilities(stores.auth.team?.id || "")
.createWebhookSubscription,
perform: ({ t, event }) => {
event?.preventDefault();
event?.stopPropagation();
stores.dialogs.openModal({
title: t("New webhook"),
content: (
<WebhookSubscriptionNew onSubmit={stores.dialogs.closeAllModals} />
),
});
},
});
export const editWebhookSubscriptionFactory = ({
webhook,
}: {
webhook: WebhookSubscription;
}) =>
createAction({
name: ({ t }) => `${t("Edit")}…`,
analyticsName: "Edit webhook",
section: SettingsSection,
icon: <EditIcon />,
perform: ({ t, event }) => {
event?.preventDefault();
event?.stopPropagation();
stores.dialogs.openModal({
title: t("Edit webhook"),
content: (
<WebhookSubscriptionEdit
onSubmit={stores.dialogs.closeAllModals}
webhookSubscription={webhook}
/>
),
});
},
});
export const deleteWebhookSubscriptionFactory = ({
webhook,
}: {
webhook: WebhookSubscription;
}) =>
createAction({
name: ({ t }) => `${t("Delete")}…`,
analyticsName: "Delete webhook",
section: SettingsSection,
icon: <TrashIcon />,
keywords: "delete remove",
dangerous: true,
perform: ({ t, event }) => {
event?.preventDefault();
event?.stopPropagation();
stores.dialogs.openModal({
title: t("Delete webhook"),
content: (
<WebhookSubscriptionDeleteDialog
onSubmit={stores.dialogs.closeAllModals}
webhook={webhook}
/>
),
});
},
});