Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(frontend): give the MCP consent card one width, centered on the viewport
zchpeteraa99241b7e05
diff --git a/frontend/src/app/layouts/SplashLayout.tsx b/frontend/src/app/layouts/SplashLayout.tsxindex ec3f627d9e..b2668a6f2a 100644--- a/frontend/src/app/layouts/SplashLayout.tsx+++ b/frontend/src/app/layouts/SplashLayout.tsx@@ -9,6 +9,11 @@ import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";// Two-column auth chrome: an optional branding illustration on the left (shown// unless the workspace is on a non-trialing enterprise plan) and the routed// auth page on the right.+//+// The right column owns the gutter and the page's share of the viewport (all+// of it below lg, half from lg). A routed page fills the column up to its own+// cap (`w-full max-w-*`) and adds no width fraction or side padding of its+// own, which would compound with the column's.export function SplashLayout() {const matches = useMatches();const currentRouteName = (diff --git a/frontend/src/app/router/routes/auth.tsx b/frontend/src/app/router/routes/auth.tsxindex 312aa0f2da..14fdb0bde3 100644--- a/frontend/src/app/router/routes/auth.tsx+++ b/frontend/src/app/router/routes/auth.tsx@@ -19,17 +19,11 @@ import { lazyPage } from "@/app/router/lazyPage";export const authRoutes: RouteObject[] = [{path: "/oauth2/consent",- element: <SplashLayout />,- children: [- {- index: true,- handle: { name: OAUTH2_CONSENT_MODULE },- lazy: lazyPage(- () => import("@/routes/auth/OAuth2ConsentPage"),- (m) => m.OAuth2ConsentPage- ),- },- ],+ handle: { name: OAUTH2_CONSENT_MODULE },+ lazy: lazyPage(+ () => import("@/routes/auth/OAuth2ConsentPage"),+ (m) => m.OAuth2ConsentPage+ ),},{path: "/auth",diff --git a/frontend/src/routes/auth/MCPConsentDisabled.tsx b/frontend/src/routes/auth/MCPConsentDisabled.tsxindex d0c9758791..12b2261507 100644--- a/frontend/src/routes/auth/MCPConsentDisabled.tsx+++ b/frontend/src/routes/auth/MCPConsentDisabled.tsx@@ -33,7 +33,7 @@ export function MCPConsentDisabled({return (<div className="flex flex-col gap-6">- <div className="text-center flex flex-col gap-2">+ <div className="text-center text-balance flex flex-col gap-2"><h1 className="text-xl font-semibold text-main">{t("oauth2.consent.mcp.disabled.title")}</h1>diff --git a/frontend/src/routes/auth/MCPConsentUndisclosed.tsx b/frontend/src/routes/auth/MCPConsentUndisclosed.tsxindex e5dfb3cc69..132096e55d 100644--- a/frontend/src/routes/auth/MCPConsentUndisclosed.tsx+++ b/frontend/src/routes/auth/MCPConsentUndisclosed.tsx@@ -43,7 +43,7 @@ export function MCPConsentUndisclosed({return (<div className="flex flex-col gap-6">- <div className="text-center flex flex-col gap-2">+ <div className="text-center text-balance flex flex-col gap-2"><h1 className="text-xl font-semibold text-main">{t(`${key}.title`)}</h1><p className="text-control">{t(`${key}.description`)}</p></div>diff --git a/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx b/frontend/src/routes/auth/OAuth2ConsentPage.test.tsxindex bfa8331b84..c99616ff29 100644--- a/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx+++ b/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx@@ -609,20 +609,6 @@ describe("OAuth2ConsentPage", () => {unmount();});- test("uses the broad responsive consent-card width", async () => {- const { container, unmount } = await renderWithCeiling({ capability: 3 });-- expect(container.firstElementChild).toHaveClass(- "w-full",- "max-w-5xl",- "px-4",- "md:w-3/5",- "lg:w-1/2",- "lg:px-0"- );- unmount();- });-test("each ceiling states the shared policy bound", async () => {const readOnly = await renderWithCeiling({ capability: 3 });expect(readOnly.container.textContent).toContain(diff --git a/frontend/src/routes/auth/OAuth2ConsentPage.tsx b/frontend/src/routes/auth/OAuth2ConsentPage.tsxindex a9259dfa67..4bc4cdc1d1 100644--- a/frontend/src/routes/auth/OAuth2ConsentPage.tsx+++ b/frontend/src/routes/auth/OAuth2ConsentPage.tsx@@ -312,7 +312,7 @@ export function OAuth2ConsentPage() {}return (<div className="flex flex-col gap-6">- <div className="text-center">+ <div className="text-center text-balance"><h1 className="text-xl font-semibold text-main mb-2">{t("oauth2.consent.title")}</h1>@@ -362,13 +362,15 @@ export function OAuth2ConsentPage() {};return (- // SplashLayout's root is overflow-hidden, so this column carries its own- // scroll: the ceiling panel and its caution make the card taller than a- // short viewport, and the part that clips is Allow and Deny. The auto- // margins keep it centred while it still fits.- <div className="h-full overflow-y-auto flex flex-col mx-auto w-full max-w-5xl px-4 py-8 md:w-3/5 lg:w-1/2 lg:px-0">- <BytebaseLogo className="mx-auto mb-8 mt-auto shrink-0" />- <div className="rounded-sm border border-control-border bg-background p-6 mb-auto shrink-0">+ // An interstitial centered on the whole viewport: the card keeps one width+ // wherever it fits and narrows only on narrower screens. SplashLayout's+ // half-width column would narrow it on screens 1024px to 1727px wide.+ <div className="min-h-screen flex flex-col items-center justify-center gap-8 px-4 py-12">+ <BytebaseLogo />+ <div+ data-testid="oauth2-consent-card"+ className="w-full max-w-2xl rounded-sm border border-control-border bg-background p-6"+ >{consentBody()}</div></div>diff --git a/frontend/tests/e2e/framework/api-client.ts b/frontend/tests/e2e/framework/api-client.tsindex 8eccb7cc7e..3ca8e24a40 100644--- a/frontend/tests/e2e/framework/api-client.ts+++ b/frontend/tests/e2e/framework/api-client.ts@@ -137,6 +137,19 @@ export class BytebaseApiClient {}}+ // OAuth2 dynamic client registration (RFC 7591), the call an MCP client makes+ // before sending its user to the consent page. The backend accepts only+ // localhost, known hosted-client, and allowlisted app-scheme redirect URIs.+ async registerOAuth2Client(+ clientName: string,+ redirectURIs: string[],+ ): Promise<{ client_id: string }> {+ return this.request<{ client_id: string }>("POST", "/api/oauth2/register", {+ client_name: clientName,+ redirect_uris: redirectURIs,+ });+ }+// Creates a new project with the given resourceId and title. Used by the// seed-test-data fixture to ensure tests have ≥ 2 projects (the// project-switcher CUJ in connection.spec.ts needs an alternative to thediff --git a/frontend/tests/e2e/oauth2-consent/oauth2-consent.spec.ts b/frontend/tests/e2e/oauth2-consent/oauth2-consent.spec.tsnew file mode 100644index 0000000000..eaa4be6120--- /dev/null+++ b/frontend/tests/e2e/oauth2-consent/oauth2-consent.spec.ts@@ -0,0 +1,77 @@+// OAuth2 consent (/oauth2/consent): the page an MCP client sends its user to+// before the client is granted a session.++import { expect, test } from "@playwright/test";+import { loadTestEnv } from "../framework/env";++// The card's design: centered in the viewport at one width (max-w-2xl), and+// narrower only when the viewport minus the page gutters (px-4) cannot hold it.+const CARD_WIDTH = 672;+const GUTTER = 16;++const VIEWPORTS = [+ { width: 390, height: 844 },+ { width: 700, height: 900 },+ { width: 900, height: 1000 },+ { width: 1024, height: 768 },+ { width: 1280, height: 800 },+ { width: 1440, height: 900 },+ { width: 1920, height: 1080 },+];++const REDIRECT_URI = "http://localhost:33418/callback";++let consentURL: string;++test.beforeAll(async () => {+ const env = loadTestEnv();+ // No teardown: registration has no delete endpoint, and a client nobody+ // authorizes grants nothing.+ const { client_id } = await env.api.registerOAuth2Client(+ "E2E consent layout",+ [REDIRECT_URI]+ );+ consentURL = `${env.baseURL}/oauth2/consent?${new URLSearchParams({+ client_id,+ redirect_uri: REDIRECT_URI,+ state: "e2e",+ // The page only requires a challenge; the authorize POST verifies it, and+ // this spec never sends one.+ code_challenge: "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",+ code_challenge_method: "S256",+ })}`;+});++test.describe("OAuth2 consent card", () => {+ for (const viewport of VIEWPORTS) {+ test(`keeps its width unless the viewport is narrower, at ${viewport.width}px`, async ({+ page,+ }) => {+ await page.setViewportSize(viewport);+ await page.goto(consentURL);+ const card = page.getByTestId("oauth2-consent-card");+ // Every branch that has loaded its client renders a level-1 heading.+ await expect(card.getByRole("heading", { level: 1 })).toBeVisible();++ // clientWidth rather than the requested width, so a classic scrollbar+ // is not counted as room.+ const measured = await card.evaluate((el) => {+ const rect = el.getBoundingClientRect();+ return {+ viewport: document.documentElement.clientWidth,+ left: rect.left,+ width: rect.width,+ };+ });+ const expected = Math.min(CARD_WIDTH, measured.viewport - 2 * GUTTER);+ expect(+ Math.abs(measured.width - expected),+ `card ${measured.width}px in a ${measured.viewport}px viewport`+ ).toBeLessThanOrEqual(1);+ expect(+ Math.abs(measured.left - (measured.viewport - measured.width) / 2),+ `card starts at ${measured.left}px`+ ).toBeLessThanOrEqual(1);+ });+ }+});