Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Merge branch 'webhooks-ga' into segment

Kiran K3a559764e901
diff --cc apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/page-client.tsx
index 8bb0543c99,fe080759bd..f1f43fbbce
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/page-client.tsx
@@@ -299,8 -289,10 +299,7 @@@ export default function IntegrationPage
</Markdown>
)}
</div>
--
- {integration.installed && integration.id === SLACK_INTEGRATION_ID && (
- <SlackWebhookSettings webhookId={integration.credentials?.webhookId!} />
- )}
+ {SettingsComponent && <SettingsComponent {...integration} />}
</MaxWidthWrapper>
);
}
diff --cc apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/page.tsx
index 3f8f4d54c0,a7ec2f33b7..c80caa7bb0
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/integrations/[integrationSlug]/page.tsx
@@@ -48,15 -45,17 +50,16 @@@ export default async function Integrati
}
const installed = integration.installations.length > 0;
- let credentials: Record<string, string> = {};
- if (integration.id === SLACK_INTEGRATION_ID && installed) {
- const slackCredentials = integration.installations[0]
- .credentials as SlackCredential;
+ const credentials = installed
+ ? integration.installations[0]?.credentials
+ : undefined;
+
+ const webhookId = installed
+ ? integration.installations[0]?.webhook?.id
+ : undefined;
- credentials = {
- webhookId: slackCredentials?.incomingWebhook?.webhookId,
- };
- }
+
return (
<IntegrationPageClient
integration={{
diff --cc apps/web/lib/integrations/slack/uninstall.ts
index 997aa81ae9,62e788667f..549a012e9a
--- a/apps/web/lib/integrations/slack/uninstall.ts
+++ b/apps/web/lib/integrations/slack/uninstall.ts
@@@ -9,8 -10,18 +10,17 @@@ export const uninstallSlackIntegration
installation: InstalledIntegration;
}) => {
const env = getSlackEnv();
-
const credentials = installation.credentials as SlackCredential;
+ // Remove the webhook added by the Slack integration
+ if (credentials.incomingWebhook.webhookId) {
+ await prisma.webhook.delete({
+ where: {
+ id: credentials.incomingWebhook.webhookId,
+ },
+ });
+ }
+
const response = await fetch("https://slack.com/api/apps.uninstall", {
method: "POST",
headers: {
diff --cc apps/web/ui/webhooks/webhook-header.tsx
index addf1a1032,a4b19fda3f..82b496d10f
--- a/apps/web/ui/webhooks/webhook-header.tsx
+++ b/apps/web/ui/webhooks/webhook-header.tsx
@@@ -35,6 -35,17 +36,17 @@@ export default function WebhookHeader(
const selectedLayoutSegment = useSelectedLayoutSegment();
const page = selectedLayoutSegment === null ? "" : selectedLayoutSegment;
+ const [openPopover, setOpenPopover] = useState(false);
+
+ const {
+ data: webhook,
+ isLoading,
+ mutate,
+ } = useSWR<WebhookProps>(
+ `/api/webhooks/${webhookId}?workspaceId=${workspaceId}`,
+ fetcher,
+ );
-
++
const { DeleteWebhookModal, setDeleteWebhookModal } = useDeleteWebhookModal({
webhook,
});