Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions apps/web/app/api/integrations/uninstall/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,31 @@ export const DELETE = withWorkspace(
});
}

const { integrationId, webhook } = await prisma.installedIntegration.delete(
{
const { integrationId, webhooks } =
await prisma.installedIntegration.delete({
where: {
id: installationId,
},
select: {
integrationId: true,
webhook: {
webhooks: {
select: {
id: true,
triggers: true,
},
},
},
},
);
});

waitUntil(
Promise.all([
...(integrationId === SLACK_INTEGRATION_ID
? [uninstallSlackIntegration({ installation })]
: []),

...(webhook && isLinkLevelWebhook(webhook)
? [webhookCache.delete(webhook.id)]
: []),
...webhooks.map((webhook) =>
isLinkLevelWebhook(webhook) ? webhookCache.delete(webhook.id) : null,
),
]),
);

Expand Down
4 changes: 0 additions & 4 deletions apps/web/app/api/workspaces/[idOrSlug]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export const GET = withWorkspace(
take: 100,
});

const flags = await getFeatureFlags({
workspaceId: workspace.id,
});

return NextResponse.json(
{
...WorkspaceSchemaExtended.parse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async function IntegrationPage({
image: true,
},
},
webhook: {
webhooks: {
select: {
id: true,
},
Expand Down Expand Up @@ -62,8 +62,10 @@ export default async function IntegrationPage({
? integration.installations[0]?.credentials
: undefined;

// TODO:
// Fix this, we only displaying the first webhook only
const webhookId = installed
? integration.installations[0]?.webhook?.id
? integration.installations[0]?.webhooks[0]?.id
: undefined;

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { IntegrationLogo } from "@/ui/integrations/integration-logo";
import LayoutLoader from "@/ui/layout/layout-loader";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
import { BackLink } from "@/ui/shared/back-link";
import { prisma } from "@dub/prisma";
import { Avatar } from "@dub/ui";
import { Avatar, ConnectedDots } from "@dub/ui";
import { cn, formatDate, truncate } from "@dub/utils";
import { ChevronRight } from "lucide-react";
import Link from "next/link";
import { Suspense } from "react";

export const dynamic = "force-dynamic";
export const revalidate = 0;

export default function EnabledIntegrationsPage({
params,
Expand All @@ -22,7 +25,7 @@ export default function EnabledIntegrationsPage({
<h1 className="text-2xl font-semibold tracking-tight text-black">
Enabled Integrations
</h1>
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={<LayoutLoader />}>
<EnabledIntegrationsPageRSC slug={params.slug} />
</Suspense>
</div>
Expand Down Expand Up @@ -55,6 +58,22 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
},
});

if (!integrations || integrations.length === 0) {
return (
<AnimatedEmptyState
title="No integrations enabled"
description="When you enable an integration, it will appear here."
cardContent={
<>
<ConnectedDots className="size-4 text-neutral-700" />
<div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
</>
}
className="min-h-[400px]"
/>
);
}

return (
<ul className="flex flex-col gap-2">
{integrations.map((integration) => {
Expand Down Expand Up @@ -99,11 +118,7 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
) : null}
{formatDate(installation.createdAt, {
month: "short",
year:
installation.createdAt.getFullYear() ===
new Date().getFullYear()
? undefined
: "numeric",
year: "numeric",
})}
</span>
)}
Expand Down
5 changes: 5 additions & 0 deletions apps/web/lib/api/partners/create-and-enroll-partner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const createAndEnrollPartner = async ({
tenantId,
status = "approved",
skipEnrollmentCheck = false,
enrolledAt,
}: {
program: Pick<
ProgramProps,
Expand All @@ -46,6 +47,7 @@ export const createAndEnrollPartner = async ({
tenantId?: string;
status?: ProgramEnrollmentStatus;
skipEnrollmentCheck?: boolean;
enrolledAt?: Date;
}) => {
if (!skipEnrollmentCheck && partner.email) {
const programEnrollment = await prisma.programEnrollment.findFirst({
Expand Down Expand Up @@ -107,6 +109,9 @@ export const createAndEnrollPartner = async ({
discountId !== program.defaultDiscountId && {
discountId,
}),
...(enrolledAt && {
createdAt: enrolledAt,
}),
},
},
};
Expand Down
3 changes: 3 additions & 0 deletions apps/web/lib/integrations/zapier/ui/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const ZapierSettings = (props: InstalledIntegrationInfoProps) => {
"link.updated",
"link.deleted",
"link.clicked",
"lead.created",
"sale.created",
"partner.enrolled",
]}
/>
)}
Expand Down
31 changes: 26 additions & 5 deletions apps/web/scripts/partners/import-partners.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { prisma } from "@dub/prisma";
import { nanoid } from "@dub/utils";
import slugify from "@sindresorhus/slugify";
import "dotenv-flow/config";
import * as fs from "fs";
import * as Papa from "papaparse";
Expand All @@ -7,19 +9,35 @@ import { createPartnerLink } from "../../lib/api/partners/create-partner-link";

const programId = "xxx";
const userId = "xxx";
const partnersToImport: { email: string; slug: string }[] = [];
const partnersToImport: { email: string; slug: string; enrolledAt: Date }[] =
[];

async function main() {
Papa.parse(fs.createReadStream("affiliates.csv", "utf-8"), {
header: true,
skipEmptyLines: true,
step: (result: { data: { email: string; slug: string } }) => {
step: (result: {
data: { payment_email?: string; date_registered: string };
}) => {
const email = result.data.payment_email;
if (!email) {
return;
}

let slug = slugify(email.split("@")[0]);
// check if slug is already used by another partner in partnersToImport
while (partnersToImport.some((partner) => partner.slug === slug)) {
slug = `${slug}-${nanoid(4).toLowerCase()}`;
}

partnersToImport.push({
email: result.data.email,
slug: result.data.slug.slice(1),
email,
slug,
enrolledAt: new Date(result.data.date_registered),
});
},
complete: async () => {
console.table(partnersToImport);
const program = await prisma.program.findUniqueOrThrow({
where: {
id: programId,
Expand Down Expand Up @@ -57,9 +75,12 @@ async function main() {
link: partnerLink,
workspace: program.workspace,
partner: partnerToCreate,
enrolledAt: partner.enrolledAt,
});

console.log(enrolledPartner);
console.log(
`Created and enrolled partner ${enrolledPartner.email} with link ${enrolledPartner?.links?.[0]?.shortLink}`,
);
}
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/prisma/schema/integration.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ model InstalledIntegration {
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
refreshTokens OAuthRefreshToken[]
accessTokens RestrictedToken[]
webhook Webhook?
webhooks Webhook[]

@@unique([userId, integrationId, projectId])
@@index([projectId])
Expand Down
5 changes: 3 additions & 2 deletions packages/prisma/schema/webhook.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum WebhookReceiver {
model Webhook {
id String @id @default(cuid())
projectId String
installationId String? @unique // indicates which integration installation added the webhook
installationId String? // indicates which integration installation added the webhook
receiver WebhookReceiver @default(user)
name String
url String @db.LongText
Expand All @@ -25,7 +25,8 @@ model Webhook {
installedIntegration InstalledIntegration? @relation(fields: [installationId], references: [id], onDelete: Cascade)
links LinkWebhook[]

@@index([projectId])
@@index(projectId)
@@index(installationId)
}

model LinkWebhook {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dub/ui",
"description": "UI components for Dub",
"version": "0.2.47",
"version": "0.2.48",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
32 changes: 32 additions & 0 deletions packages/ui/src/icons/nucleo/brackets-curly.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { SVGProps } from "react";

export function BracketsCurly(props: SVGProps<SVGSVGElement>) {
return (
<svg
height="18"
width="18"
viewBox="0 0 18 18"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<g fill="currentColor">
<path
d="M6.25,15.25h-1c-1.105,0-2-.895-2-2v-2.625c0-.897-.728-1.625-1.625-1.625,.897,0,1.625-.728,1.625-1.625v-2.625c0-1.105,.895-2,2-2h1"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<path
d="M11.75,15.25h1c1.105,0,2-.895,2-2v-2.625c0-.897,.728-1.625,1.625-1.625-.897,0-1.625-.728-1.625-1.625v-2.625c0-1.105-.895-2-2-2h-1"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
}
43 changes: 43 additions & 0 deletions packages/ui/src/icons/nucleo/brush.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SVGProps } from "react";

export function Brush(props: SVGProps<SVGSVGElement>) {
return (
<svg
height="18"
width="18"
viewBox="0 0 18 18"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<g fill="currentColor">
<line
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
x1="10.75"
x2="10.75"
y1="1.75"
y2="5.25"
/>
<path
d="M3.75,8.75V3.75c0-1.105,.895-2,2-2H14.25v7"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
<path
d="M3.75,8.75v1.5c0,1.104,.895,2,2,2h2l-.25,3.5c0,.828,.672,1.5,1.5,1.5s1.5-.672,1.5-1.5l-.25-3.5h2c1.105,0,2-.896,2-2v-1.5H3.75Z"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
/>
</g>
</svg>
);
}
4 changes: 4 additions & 0 deletions packages/ui/src/icons/nucleo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export * from "./book2-fill";
export * from "./book2-small";
export * from "./books2";
export * from "./box-archive";
export * from "./brackets-curly";
export * from "./brush";
export * from "./bullet-list";
export * from "./bullet-list-fill";
export * from "./calendar";
Expand Down Expand Up @@ -186,6 +188,7 @@ export * from "./tag";
export * from "./tags";
export * from "./timer2";
export * from "./toggle2-fill";
export * from "./toggles";
export * from "./trash";
export * from "./triangle-warning";
export * from "./tv";
Expand All @@ -194,6 +197,7 @@ export * from "./user";
export * from "./user-check";
export * from "./user-crown";
export * from "./user-delete";
export * from "./user-focus";
export * from "./user-plus";
export * from "./users";
export * from "./users-fill";
Expand Down
Loading