Skip to content

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

Address comments

Joshen Lim20ca3f33b527
diff --git a/studio/components/interfaces/App/AppBannerWrapper.tsx b/studio/components/interfaces/App/AppBannerWrapper.tsx
index 581ca0c6669..65f203d560e 100644
--- a/studio/components/interfaces/App/AppBannerWrapper.tsx
+++ b/studio/components/interfaces/App/AppBannerWrapper.tsx
@@ -1,9 +1,22 @@
+import { useMonaco } from '@monaco-editor/react'
+import { useTheme } from 'common'
import IncidentBanner from 'components/layouts/AppLayout/IncidentBanner'
+import { getTheme } from 'components/ui/CodeEditor'
import { useFlag } from 'hooks'
-import { PropsWithChildren } from 'react'
+import { PropsWithChildren, useEffect } from 'react'
const AppBannerWrapper = ({ children }: PropsWithChildren<{}>) => {
+ const monaco = useMonaco()
+ const { isDarkMode } = useTheme()
const ongoingIncident = useFlag('ongoingIncident')
+
+ useEffect(() => {
+ if (monaco) {
+ const theme: any = getTheme(isDarkMode)
+ monaco.editor.defineTheme('supabase', theme)
+ }
+ }, [isDarkMode, monaco])
+
return (
<div className="min-h-full flex flex-col">
{ongoingIncident && <IncidentBanner />}
diff --git a/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx b/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
index 7fff0a15a28..1662ee4ab0d 100644
--- a/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
+++ b/studio/components/interfaces/Database/Indexes/CreateIndexSidePanel.tsx
@@ -57,12 +57,12 @@ const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelProps) =
})
const { mutate: execute, isLoading: isExecuting } = useExecuteSqlMutation({
- onSuccess() {
- refetchIndexes()
+ onSuccess: async () => {
+ await refetchIndexes()
onClose()
ui.setNotification({ category: 'success', message: `Successfully created index` })
},
- onError(error) {
+ onError: (error) => {
ui.setNotification({
error,
category: 'error',
@@ -75,7 +75,7 @@ const CreateIndexSidePanel = ({ visible, onClose }: CreateIndexSidePanelProps) =
() => entities?.pages.flatMap((page) => page.data.entities) || [],
[entities?.pages]
)
- const columns = tableColumns?.result[0].columns ?? []
+ const columns = tableColumns?.result[0]?.columns ?? []
const columnOptions: MultiSelectOption[] = columns.map((column) => {
return { id: column.attname, value: column.attname, name: column.attname, disabled: false }
})
@@ -144,7 +144,11 @@ CREATE INDEX ON "${selectedSchema}"."${selectedEntity}" USING ${selectedIndexTyp
{entityTypes.length === 0 ? (
<div className="space-y-2">
<p className="text-sm text-scale-1100 leading-4">Select a table</p>
- <Input placeholder="No tables available in schema" />
+ <Input
+ disabled
+ placeholder="No tables available in schema"
+ descriptionText="Create a table in this schema via the Table or SQL editor first"
+ />
</div>
) : (
<Listbox
diff --git a/studio/components/interfaces/Database/Indexes/Indexes.tsx b/studio/components/interfaces/Database/Indexes/Indexes.tsx
index 8450e8538f5..fc61add7086 100644
--- a/studio/components/interfaces/Database/Indexes/Indexes.tsx
+++ b/studio/components/interfaces/Database/Indexes/Indexes.tsx
@@ -28,6 +28,7 @@ import CreateIndexSidePanel from './CreateIndexSidePanel'
import ConfirmationModal from 'components/ui/ConfirmationModal'
import { useExecuteSqlMutation } from 'data/sql/execute-sql-mutation'
import { useStore } from 'hooks'
+import MonacoEditor from 'components/interfaces/SQLEditor/MonacoEditor'
const Indexes = () => {
const { ui } = useStore()
@@ -184,7 +185,7 @@ const Indexes = () => {
<>
{sortedIndexes.length === 0 && search.length === 0 && (
<Table.tr>
- <Table.td colSpan={3}>
+ <Table.td colSpan={4}>
<p className="text-sm text-scale-1200">No indexes created yet</p>
<p className="text-sm text-light">
There are no indexes found in the schema "{selectedSchema}"
@@ -194,7 +195,7 @@ const Indexes = () => {
)}
{sortedIndexes.length === 0 && search.length > 0 && (
<Table.tr>
- <Table.td colSpan={3}>
+ <Table.td colSpan={4}>
<p className="text-sm text-scale-1200">No results found</p>
<p className="text-sm text-light">
Your search for "{search}" did not return any results
@@ -236,6 +237,7 @@ const Indexes = () => {
</div>
<SidePanel
+ size="xlarge"
visible={selectedIndex !== undefined}
header={
<>
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
index a20b2bd4c40..ad43e9c951d 100644
--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
@@ -26,7 +26,7 @@ import {
} from './NavigationBar.utils'
import NavigationIconButton from './NavigationIconButton'
-const NavigationBar = ({}) => {
+const NavigationBar = () => {
const router = useRouter()
const { isDarkMode, toggleTheme } = useTheme()
const { ref: projectRef } = useParams()
diff --git a/studio/components/ui/CodeEditor/CodeEditor.tsx b/studio/components/ui/CodeEditor/CodeEditor.tsx
index 080742477c0..6dd28561652 100644
--- a/studio/components/ui/CodeEditor/CodeEditor.tsx
+++ b/studio/components/ui/CodeEditor/CodeEditor.tsx
@@ -5,6 +5,7 @@ import { useRef } from 'react'
import { timeout } from 'lib/helpers'
import Connecting from '../Loading'
import { alignEditor } from './CodeEditor.utils'
+import { cn } from 'ui'
interface CodeEditorProps {
id: string
@@ -38,6 +39,7 @@ const CodeEditor = ({
const editorRef = useRef()
const onMount = async (editor: any, monaco: any) => {
+ editorRef.current = editor
alignEditor(editor)
editor.addAction({
@@ -56,7 +58,6 @@ const CodeEditor = ({
await timeout(500)
if (autofocus) editor?.focus()
- editorRef.current = editor
}
const optionsMerged = merge(
@@ -80,10 +81,10 @@ const CodeEditor = ({
return (
<Editor
- value={value ?? undefined}
path={id}
theme="supabase"
- className={`monaco-editor ${className}`}
+ className={cn(className, 'monaco-editor')}
+ value={value ?? undefined}
defaultLanguage={language}
defaultValue={defaultValue ?? undefined}
loading={loading || <Connecting />}
diff --git a/studio/components/ui/CodeEditor/CodeEditor.utils.ts b/studio/components/ui/CodeEditor/CodeEditor.utils.ts
index 8f34d2d344f..3cf3c882200 100644
--- a/studio/components/ui/CodeEditor/CodeEditor.utils.ts
+++ b/studio/components/ui/CodeEditor/CodeEditor.utils.ts
@@ -12,18 +12,19 @@ export const alignEditor = (editor: any) => {
export const getTheme = (isDarkTheme: boolean) => {
// [TODO] Probably need better theming for light mode
return {
- base: 'vs-dark', // can also be vs-dark or hc-black
+ base: isDarkTheme ? 'vs-dark' : 'vs', // can also be vs-dark or hc-black
inherit: true, // can also be false to completely replace the builtin rules
- colors: {
- 'editor.background': isDarkTheme ? '#1F1F1F' : '#FFFFFF',
- },
rules: [
- { background: isDarkTheme ? '1F1F1F' : 'FFFFFF' },
- { token: '', foreground: isDarkTheme ? 'D4D4D4' : '444444' },
- { token: 'string.sql', foreground: '24B47E' },
+ { background: isDarkTheme ? '1f1f1f' : 'f0f0f0' },
+ {
+ token: '',
+ background: isDarkTheme ? '1f1f1f' : 'f0f0f0',
+ foreground: isDarkTheme ? 'd4d4d4' : '444444',
+ },
+ { token: 'string.sql', foreground: '24b47e' },
{ token: 'comment', foreground: '666666' },
{ token: 'predefined.sql', foreground: isDarkTheme ? 'D4D4D4' : '444444' },
- // { token: '', foreground: 'ffcc00' }, // Trying to figure out how to change the border color of the row selected
],
+ colors: { 'editor.background': isDarkTheme ? '#1f1f1f' : '#f0f0f0' },
}
}
diff --git a/studio/hooks/misc/useStore.tsx b/studio/hooks/misc/useStore.tsx
index 840ebc3ffb5..7abc9c6043a 100644
--- a/studio/hooks/misc/useStore.tsx
+++ b/studio/hooks/misc/useStore.tsx
@@ -1,10 +1,7 @@
-import { useMonaco } from '@monaco-editor/react'
-import { useTheme } from 'common'
import { autorun } from 'mobx'
import { createContext, PropsWithChildren, useContext, useEffect } from 'react'
import toast from 'react-hot-toast'
-import { getTheme } from 'components/ui/CodeEditor'
import SparkBar from 'components/ui/SparkBar'
import { IRootStore } from 'stores'
@@ -23,16 +20,7 @@ interface StoreProvider {
rootStore: IRootStore
}
export const StoreProvider = ({ children, rootStore }: PropsWithChildren<StoreProvider>) => {
- const monaco = useMonaco()
const { ui } = rootStore
- const { isDarkMode } = useTheme()
-
- useEffect(() => {
- if (monaco) {
- const theme: any = getTheme(isDarkMode)
- monaco.editor.defineTheme('supabase', theme)
- }
- }, [isDarkMode, monaco])
useEffect(() => {
autorun(() => {
diff --git a/studio/pages/project/[ref]/sql/[id].tsx b/studio/pages/project/[ref]/sql/[id].tsx
index 1afc3c4ee53..9cf3c7b1225 100644
--- a/studio/pages/project/[ref]/sql/[id].tsx
+++ b/studio/pages/project/[ref]/sql/[id].tsx
@@ -1,5 +1,4 @@
import { useMonaco } from '@monaco-editor/react'
-import { useTheme } from 'common'
import { observer } from 'mobx-react-lite'
import { useEffect, useRef } from 'react'
@@ -18,7 +17,6 @@ import getPgsqlSignatureHelpProvider from 'components/ui/CodeEditor/Providers/Pg
const SqlEditor: NextPageWithLayout = () => {
const monaco = useMonaco()
- const { isDarkMode } = useTheme()
const { project } = useProjectContext()
const { mutateAsync: formatQuery } = useFormatQueryMutation()
@@ -70,21 +68,6 @@ const SqlEditor: NextPageWithLayout = () => {
pgInfoRef.current.functions = functions?.result
}
- useEffect(() => {
- if (monaco) {
- monaco.editor.defineTheme('supabase', {
- base: isDarkMode ? 'vs-dark' : 'vs',
- inherit: true,
- rules: [
- { token: '', background: isDarkMode ? '1f1f1f' : 'f0f0f0' },
- { token: 'string.sql', foreground: '24b47e' },
- { token: 'comment', foreground: '666666' },
- ],
- colors: { 'editor.background': isDarkMode ? '#1f1f1f' : '#f0f0f0' },
- })
- }
- }, [monaco, isDarkMode])
-
// Enable pgsql format
useEffect(() => {
if (monaco) {