Skip to content

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

Hide enum types from excluded schemas in column editor, and dont show user defined enum types in column types if there are none

Joshen Lim5d0b0a2eff5a
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
index b066fba784f..46468d1e946 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
@@ -67,8 +67,6 @@ const ColumnType: FC<Props> = ({
}
}
- console.log('ColumnType', showLabel)
-
return (
<Listbox
label={showLabel ? 'Type' : ''}
@@ -85,40 +83,32 @@ const ColumnType: FC<Props> = ({
---
</Listbox.Option>
- <Listbox.Option disabled key="header-1" value="header-1" label="header-1">
- User-defined Enumerated Types
- </Listbox.Option>
-
{enumTypes.length > 0 ? (
- // @ts-ignore
- enumTypes.map((enumType: PostgresType) => (
- <Listbox.Option
- key={enumType.name}
- value={enumType.name}
- label={enumType.name}
- addOnBefore={() => {
- return <div className="bg-scale-1200 mx-1 h-2 w-2 rounded-full" />
- }}
- >
- <div className="flex items-center space-x-4">
- <p>{enumType.name}</p>
- </div>
+ <>
+ <Listbox.Option disabled key="header-1" value="header-1" label="header-1">
+ User-defined Enumerated Types
</Listbox.Option>
- ))
+ {
+ // @ts-ignore
+ enumTypes.map((enumType: PostgresType) => (
+ <Listbox.Option
+ key={enumType.name}
+ value={enumType.name}
+ label={enumType.name}
+ addOnBefore={() => {
+ return <div className="bg-scale-1200 mx-1 h-2 w-2 rounded-full" />
+ }}
+ >
+ <div className="flex items-center space-x-4">
+ <p>{enumType.name}</p>
+ </div>
+ </Listbox.Option>
+ ))
+ }
+ </>
) : (
- <Listbox.Option
- disabled
- key="no-enums"
- value="no-enums"
- label="no-enums"
- addOnBefore={() => {
- return <div className="mx-1 h-2 w-2 rounded-full bg-gray-500" />
- }}
- >
- <div className="flex items-center space-x-4">
- <p>No enumerated types available</p>
- </div>
- </Listbox.Option>
+ // Listbox cannot have booleans within it, hence why return as fragment (and not use &&)
+ <></>
)}
<Listbox.Option disabled value="header-2" label="header-2">
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 2bf463db4ae..2e7bc1dc527 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@ -1,7 +1,13 @@
-import { FC, useState, useEffect } from 'react'
+import { FC, useState } from 'react'
import { find, isUndefined } from 'lodash'
import { Query, Dictionary } from '@supabase/grid'
-import { PostgresRelationship, PostgresTable, PostgresColumn } from '@supabase/postgres-meta'
+import { Modal } from '@supabase/ui'
+import {
+ PostgresRelationship,
+ PostgresTable,
+ PostgresColumn,
+ PostgresType,
+} from '@supabase/postgres-meta'
import { useStore } from 'hooks'
import { RowEditor, ColumnEditor, TableEditor } from '.'
@@ -9,8 +15,6 @@ import { ImportContent } from './TableEditor/TableEditor.types'
import { ColumnField, CreateColumnPayload, UpdateColumnPayload } from './SidePanelEditor.types'
import ConfirmationModal from 'components/ui/ConfirmationModal'
-import { Modal } from '@supabase/ui'
-
interface Props {
selectedSchema: string
selectedTable?: PostgresTable
@@ -49,7 +53,11 @@ const SidePanelEditor: FC<Props> = ({
const [isClosingPanel, setIsClosingPanel] = useState<boolean>(false)
const tables = meta.tables.list()
- const enumTypes = meta.types.list()
+ const enumTypes = meta.types.list(
+ (type: PostgresType) => !meta.excludedSchemas.includes(type.schema)
+ )
+
+ console.log(enumTypes)
const saveRow = async (
payload: any,
diff --git a/studio/stores/pgmeta/MetaStore.ts b/studio/stores/pgmeta/MetaStore.ts
index e839ade9ef1..01539696585 100644
--- a/studio/stores/pgmeta/MetaStore.ts
+++ b/studio/stores/pgmeta/MetaStore.ts
@@ -129,6 +129,7 @@ export default class MetaStore implements IMetaStore {
'realtime',
'storage',
'supabase_functions',
+ 'graphql',
]
constructor(rootStore: IRootStore, options: { projectRef: string; connectionString: string }) {