Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

address feedback

Alaister Young4100321c3e04
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/HeaderTitle.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/HeaderTitle.tsx
index 81e4bb4566c..9c71dcce12c 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/HeaderTitle.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/HeaderTitle.tsx
@@ -2,7 +2,7 @@ import type { PostgresTable } from '@supabase/postgres-meta'
interface HeaderTitleProps {
schema: string
- table: PostgresTable
+ table?: { name: string }
isDuplicating: boolean
}
@@ -17,13 +17,13 @@ const HeaderTitle = ({ schema, table, isDuplicating }: HeaderTitleProps) => {
if (isDuplicating) {
return (
<>
- Duplicate table <code className="text-sm">{table.name}</code>
+ Duplicate table <code className="text-sm">{table?.name}</code>
</>
)
}
return (
<>
- Update table <code className="text-sm">{table.name}</code>
+ Update table <code className="text-sm">{table?.name}</code>
</>
)
}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index 72262f47ec3..dd97c467436 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -170,11 +170,7 @@ const TableEditor = ({
key="TableEditor"
visible={visible}
header={
- <HeaderTitle
- schema={snap.selectedSchemaName}
- table={table as any}
- isDuplicating={isDuplicating}
- />
+ <HeaderTitle schema={snap.selectedSchemaName} table={table} isDuplicating={isDuplicating} />
}
className={`transition-all duration-100 ease-in ${isImportingSpreadsheet ? ' mr-32' : ''}`}
onCancel={closePanel}
diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
index 323c337ad90..79565b1d54e 100644
--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
@@ -411,7 +411,7 @@ const TableGridEditor = ({
{(isViewSelected || isTableSelected) && <TableDefinition id={selectedTable?.id} />}
</SupabaseGrid>
- {!isUndefined(snap.selectedSchemaName) && (
+ {snap.selectedSchemaName !== undefined && (
<SidePanelEditor
isDuplicating={isDuplicating}
selectedTable={selectedTable as PostgresTable}
diff --git a/studio/data/database/schemas-query.ts b/studio/data/database/schemas-query.ts
index 288edc9d7d0..1d90cf9f95a 100644
--- a/studio/data/database/schemas-query.ts
+++ b/studio/data/database/schemas-query.ts
@@ -1,7 +1,7 @@
-import { PostgresSchema } from '@supabase/postgres-meta'
import { QueryClient, useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'lib/common/fetch'
-import { API_URL } from 'lib/constants'
+
+import { components } from 'data/api'
+import { get } from 'data/fetchers'
import { ResponseError } from 'types'
import { databaseKeys } from './keys'
@@ -10,9 +10,7 @@ export type SchemasVariables = {
connectionString?: string
}
-export type Schema = PostgresSchema
-
-export type SchemasResponse = Schema[] | { error?: any }
+export type Schema = components['schemas']['PostgresSchema']
export async function getSchemas(
{ projectRef, connectionString }: SchemasVariables,
@@ -25,16 +23,24 @@ export async function getSchemas(
let headers = new Headers()
if (connectionString) headers.set('x-connection-encrypted', connectionString)
- const response = (await get(`${API_URL}/pg-meta/${projectRef}/schemas`, {
+ const { data, error } = await get('/platform/pg-meta/{ref}/schemas', {
+ params: {
+ header: {
+ 'x-connection-encrypted': connectionString!,
+ },
+ path: {
+ ref: projectRef,
+ },
+ },
headers: Object.fromEntries(headers),
signal,
- })) as SchemasResponse
+ })
- if (!Array.isArray(response) && response.error) {
- throw response.error
+ if (error) {
+ throw error
}
- return response as PostgresSchema[]
+ return data
}
export type SchemasData = Awaited<ReturnType<typeof getSchemas>>