mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
Refactor authorize page to move Next.js dependencies into the page shell and have Next.js-agnostic code for the core logic. Add unit tests for authorize screen. ## Summary by CodeRabbit * **New Features** * New end-to-end API authorization UI: loading, error, invalid, approved, and main approval screens. * Organization selector with preselection, create-organization link, MCP warning, expiration handling, and approve/decline actions. * Improved page title handling via layout/head provider. * **Tests** * Added comprehensive component tests covering loading, error, approval flows, organization states, validation, and side effects.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { useTheme } from 'next-themes'
|
|
import Image from 'next/legacy/image'
|
|
import type { PropsWithChildren } from 'react'
|
|
import { Separator } from 'ui'
|
|
|
|
import { Head, type HeadProvider } from '@/components/ui/Head'
|
|
import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
|
|
import { BASE_PATH } from '@/lib/constants'
|
|
|
|
export interface APIAuthorizationLayoutProps {
|
|
HeadProvider: HeadProvider
|
|
}
|
|
|
|
export const APIAuthorizationLayout = ({
|
|
HeadProvider,
|
|
children,
|
|
}: PropsWithChildren<APIAuthorizationLayoutProps>) => {
|
|
const { resolvedTheme } = useTheme()
|
|
const { appTitle } = useCustomContent(['app:title'])
|
|
|
|
return (
|
|
<>
|
|
<Head
|
|
HeadProvider={HeadProvider}
|
|
title={`Authorize API access | ${appTitle || 'Supabase'}`}
|
|
/>
|
|
<main className="h-screen flex flex-col w-full h-full overflow-y-auto">
|
|
<div>
|
|
<div className="mx-auto px-4 sm:px-6">
|
|
<div className="max-w-xl flex justify-between items-center mx-auto py-4">
|
|
<div className="flex justify-start lg:w-0 lg:flex-1 items-center">
|
|
<span className="sr-only">Supabase</span>
|
|
<Image
|
|
src={
|
|
resolvedTheme?.includes('dark')
|
|
? `${BASE_PATH}/img/supabase-dark.svg`
|
|
: `${BASE_PATH}/img/supabase-light.svg`
|
|
}
|
|
alt="Supabase Logo"
|
|
height={20}
|
|
width={105}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<Separator />
|
|
<div className="flex flex-col justify-center flex-grow mx-auto w-[90vw] max-w-[600px] space-y-4">
|
|
{children}
|
|
</div>
|
|
</main>
|
|
</>
|
|
)
|
|
}
|