The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Api authorization to add returnTo param when linking to /new for no org empty state (#50166)
Joshen Lim3ac5a6b4f7f3
diff --git a/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsx b/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsxindex c5269d6ecfb..faa3b358aaa 100644--- a/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsx+++ b/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Form.tsx@@ -71,6 +71,7 @@ function isExternalRedirectUrl(url: string): boolean {}export interface ApiAuthorizationMainViewProps {+ auth_id: stringapprovalState: ApprovalStateform: UseFormReturn<IApprovalFormSchema>requester: ApiAuthorizationResponse@@ -83,6 +84,7 @@ export interface ApiAuthorizationMainViewProps {}export function ApiAuthorizationMainView({+ auth_id,approvalState,form,requester,@@ -125,7 +127,7 @@ export function ApiAuthorizationMainView({{organizations._tag === 'error' && (<OrganizationsErrorNotice error={organizations.error} />)}- {organizations._tag === 'empty' && <OrganizationsEmptyState />}+ {organizations._tag === 'empty' && <OrganizationsEmptyState authId={auth_id} />}{organizations._tag === 'not_member' && <NotMemberOfOrganizationNotice />}{organizations._tag === 'success' && (<OrganizationSelector@@ -204,16 +206,21 @@ function OrganizationsErrorNotice({ error }: OrganizationsErrorNoticeProps): Rea)}-function OrganizationsEmptyState(): ReactNode {+interface OrganizationsEmptyStateProps {+ authId: string+}++function OrganizationsEmptyState({ authId }: OrganizationsEmptyStateProps): ReactNode {+ const returnTo = `/authorize?auth_id=${authId}`+return (<Admonitiontype="warning"title="No organizations found"description="Create an organization before authorizing this request."actions={[- // [Joshen] JFYI this is a short term solution to guide users with creating an org from here<Button asChild key="new-org" variant="default">- <Link href="/new">Create an organization</Link>+ <Link href={`/new?returnTo=${encodeURIComponent(returnTo)}`}>Create an organization</Link></Button>,]}/>diff --git a/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Valid.tsx b/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Valid.tsxindex 6d1ab488c80..eb32df05c76 100644--- a/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Valid.tsx+++ b/apps/studio/components/interfaces/ApiAuthorization/ApiAuthorization.Valid.tsx@@ -238,6 +238,7 @@ export function ApiAuthorizationValidScreen({<><Head>{pageTitle && <title>{pageTitle}</title>}</Head><ApiAuthorizationMainView+ auth_id={auth_id}approvalState={effectiveApprovalState}form={form}requester={effectiveRequester}diff --git a/apps/studio/tests/components/ApiAuthorization.test.tsx b/apps/studio/tests/components/ApiAuthorization.test.tsxindex c1046c17aa3..7e31ee0eb80 100644--- a/apps/studio/tests/components/ApiAuthorization.test.tsx+++ b/apps/studio/tests/components/ApiAuthorization.test.tsx@@ -327,6 +327,16 @@ describe('ApiAuthorizationScreen', () => {).not.toBeInTheDocument()})+ test('empty state links back to this authorize request via returnTo', async () => {+ mockBothEndpoints(createMockAuthResponse(), [])+ renderScreen()+ const link = await screen.findByRole('link', { name: 'Create an organization' })+ expect(link).toHaveAttribute(+ 'href',+ `/new?returnTo=${encodeURIComponent('/authorize?auth_id=test-auth-id')}`+ )+ })+test('shows not_member notice when organization_slug does not match any user organization', async () => {mockBothEndpoints()renderScreen({ organization_slug: 'nonexistent-org' })