From 6ac77f2236944acf1e3bc897908b51150463b826 Mon Sep 17 00:00:00 2001 From: "blinkagent[bot]" <237617714+blinkagent[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 03:56:38 +0000 Subject: [PATCH] feat(site): add query param support to OAuth2 app creation page (#21821) ## Summary Adds support for pre-filling the OAuth2 application creation form via URL query parameters. ## Query Parameters | Parameter | Description | |-----------|-------------| | `name` | Pre-fills the "Application name" field | | `callback_url` | Pre-fills the "Callback URL" field | | `icon` | Pre-fills the "Application icon" field | ## Example ``` /deployment/oauth2-provider/apps/add?name=MyApp&callback_url=https://example.com/callback&icon=/icon/github.svg ``` This allows external tools or documentation to link directly to the OAuth2 app creation page with pre-populated values. Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> --- .../OAuth2AppsSettingsPage/CreateOAuth2AppPage.tsx | 10 +++++++++- .../CreateOAuth2AppPageView.tsx | 7 +++++++ .../OAuth2AppsSettingsPage/OAuth2AppForm.tsx | 12 +++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPage.tsx b/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPage.tsx index b94606809b..cee9d6344b 100644 --- a/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPage.tsx +++ b/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPage.tsx @@ -2,15 +2,22 @@ import { postApp } from "api/queries/oauth2"; import { displayError, displaySuccess } from "components/GlobalSnackbar/utils"; import type { FC } from "react"; import { useMutation, useQueryClient } from "react-query"; -import { useNavigate } from "react-router"; +import { useNavigate, useSearchParams } from "react-router"; import { pageTitle } from "utils/page"; import { CreateOAuth2AppPageView } from "./CreateOAuth2AppPageView"; const CreateOAuth2AppPage: FC = () => { const navigate = useNavigate(); + const [searchParams] = useSearchParams(); const queryClient = useQueryClient(); const postAppMutation = useMutation(postApp(queryClient)); + const defaultValues = { + name: searchParams.get("name") ?? "", + callback_url: searchParams.get("callback_url") ?? "", + icon: searchParams.get("icon") ?? "", + }; + return ( <> {pageTitle("New OAuth2 Application")} @@ -18,6 +25,7 @@ const CreateOAuth2AppPage: FC = () => { { try { const app = await postAppMutation.mutateAsync(req); diff --git a/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPageView.tsx b/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPageView.tsx index c4bcfb25cd..9d59db1269 100644 --- a/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPageView.tsx +++ b/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/CreateOAuth2AppPageView.tsx @@ -16,12 +16,18 @@ type CreateOAuth2AppProps = { isUpdating: boolean; createApp: (req: TypesGen.PostOAuth2ProviderAppRequest) => void; error?: unknown; + defaultValues?: { + name: string; + callback_url: string; + icon: string; + }; }; export const CreateOAuth2AppPageView: FC = ({ isUpdating, createApp, error, + defaultValues, }) => { return ( <> @@ -51,6 +57,7 @@ export const CreateOAuth2AppPageView: FC = ({ onSubmit={createApp} isUpdating={isUpdating} error={error} + defaultValues={defaultValues} /> diff --git a/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/OAuth2AppForm.tsx b/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/OAuth2AppForm.tsx index 0bb08327f5..2801e5fa28 100644 --- a/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/OAuth2AppForm.tsx +++ b/site/src/pages/DeploymentSettingsPage/OAuth2AppsSettingsPage/OAuth2AppForm.tsx @@ -16,6 +16,11 @@ type OAuth2AppFormProps = { error?: unknown; isUpdating: boolean; actions?: ReactNode; + defaultValues?: { + name: string; + callback_url: string; + icon: string; + }; }; export const OAuth2AppForm: FC = ({ @@ -24,6 +29,7 @@ export const OAuth2AppForm: FC = ({ error, isUpdating, actions, + defaultValues, }) => { const apiValidationErrors = isApiValidationError(error) ? mapApiErrorToFieldErrors(error.response.data) @@ -46,7 +52,7 @@ export const OAuth2AppForm: FC = ({ = ({ = ({