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.

add the installation URL when creating an OAuth app

Kiran K382c39f699ec
diff --git a/apps/web/app/api/oauth/apps/[appId]/route.ts b/apps/web/app/api/oauth/apps/[appId]/route.ts
index 5ad1d2cbd6..a422967b6c 100644
--- a/apps/web/app/api/oauth/apps/[appId]/route.ts
+++ b/apps/web/app/api/oauth/apps/[appId]/route.ts
@@ -58,6 +58,7 @@ export const PATCH = withWorkspace(
slug,
developer,
website,
+ installUrl,
description,
readme,
redirectUris,
@@ -101,6 +102,7 @@ export const PATCH = withWorkspace(
slug,
developer,
website,
+ installUrl,
description,
readme,
screenshots,
@@ -122,6 +124,7 @@ export const PATCH = withWorkspace(
developer: true,
logo: true,
website: true,
+ installUrl: true,
readme: true,
screenshots: true,
verified: true,
diff --git a/apps/web/app/api/oauth/apps/route.ts b/apps/web/app/api/oauth/apps/route.ts
index 964f150d01..dd30997717 100644
--- a/apps/web/app/api/oauth/apps/route.ts
+++ b/apps/web/app/api/oauth/apps/route.ts
@@ -49,6 +49,7 @@ export const POST = withWorkspace(
slug,
developer,
website,
+ installUrl,
description,
readme,
redirectUris,
@@ -91,6 +92,7 @@ export const POST = withWorkspace(
slug,
developer,
website,
+ installUrl,
description,
readme,
screenshots,
@@ -118,6 +120,7 @@ export const POST = withWorkspace(
developer: true,
logo: true,
website: true,
+ installUrl: true,
readme: true,
screenshots: true,
verified: true,
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 7841f6f2e7..68cd834135 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -4,7 +4,7 @@ import { DirectorySyncProviders } from "@boxyhq/saml-jackson";
import { Link, Project } from "@prisma/client";
import { integrationSchema } from "./zod/schemas/integration";
import { createLinkBodySchema } from "./zod/schemas/links";
-import { oAuthAppSchema } from "./zod/schemas/oauth";
+import { createOAuthAppSchema, oAuthAppSchema } from "./zod/schemas/oauth";
import { tokenSchema } from "./zod/schemas/token";
export type LinkProps = Link;
@@ -191,15 +191,7 @@ export type TokenProps = z.infer<typeof tokenSchema>;
export type OAuthAppProps = z.infer<typeof oAuthAppSchema>;
-export type NewOAuthApp = Omit<
- OAuthAppProps,
- | "id"
- | "clientId"
- | "verified"
- | "installations"
- | "screenshots"
- | "installUrl"
->;
+export type NewOAuthApp = z.infer<typeof createOAuthAppSchema>;
export type ExistingOAuthApp = OAuthAppProps;
diff --git a/apps/web/lib/zod/schemas/integration.ts b/apps/web/lib/zod/schemas/integration.ts
index bd44fcd418..e7c7cf8105 100644
--- a/apps/web/lib/zod/schemas/integration.ts
+++ b/apps/web/lib/zod/schemas/integration.ts
@@ -28,6 +28,12 @@ export const createIntegrationSchema = z.object({
message: "website must be a valid URL",
})
.max(100),
+ installUrl: z
+ .string()
+ .url({
+ message: "installUrl must be a valid URL",
+ })
+ .nullish(),
logo: z
.string()
.url({
diff --git a/apps/web/ui/oauth-apps/add-edit-app-form.tsx b/apps/web/ui/oauth-apps/add-edit-app-form.tsx
index 36135de404..5537766eb3 100644
--- a/apps/web/ui/oauth-apps/add-edit-app-form.tsx
+++ b/apps/web/ui/oauth-apps/add-edit-app-form.tsx
@@ -27,12 +27,11 @@ const defaultValues: NewOAuthApp = {
readme: "",
developer: "",
website: "",
- partialClientSecret: "",
+ installUrl: null,
redirectUris: [],
+ screenshots: [],
logo: null,
pkce: true,
- createdAt: new Date(),
- updatedAt: new Date(),
};
export default function AddOAuthAppForm({
@@ -193,6 +192,7 @@ export default function AddOAuthAppForm({
redirectUris,
logo,
pkce,
+ installUrl,
} = data;
const buttonDisabled =
@@ -427,6 +427,33 @@ export default function AddOAuthAppForm({
</div>
</div>
+ <div>
+ <label htmlFor="installUrl" className="flex items-center space-x-2">
+ <h2 className="text-sm font-medium text-gray-900">Install URL</h2>
+ <InfoTooltip content="An optional URL for installing the application" />
+ </label>
+ <div className="relative mt-2 rounded-md shadow-sm">
+ <input
+ className={cn(
+ "block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm",
+ {
+ "cursor-not-allowed bg-gray-50": !canManageApp,
+ },
+ )}
+ type="url"
+ value={installUrl || ""}
+ onChange={(e) =>
+ setData({
+ ...data,
+ installUrl: e.target.value ? e.target.value : null,
+ })
+ }
+ placeholder="https://acme.com/install"
+ disabled={!canManageApp}
+ />
+ </div>
+ </div>
+
<div>
<div className="flex items-center justify-between">
<label