Skip to content

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

Save the snippet after doing the minimum interaction (create a template, create a quickstart, make a personal copy, write a letter in a new query).

Ivan Vasilovabd56165c716
diff --git a/studio/components/interfaces/SQLEditor/MonacoEditor.tsx b/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
index 04c13ff6dc6..111d1e4e4ed 100644
--- a/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
+++ b/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
@@ -95,6 +95,7 @@ const MonacoEditor = ({
})
if (ref) {
snap.addSnippet(snippet as SqlSnippet, ref)
+ snap.addNeedsSaving(snippet.id!)
router.push(`/project/${ref}/sql/${snippet.id}`, undefined, { shallow: true })
}
}
diff --git a/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index edc189a637b..ab92f9cfd44 100644
--- a/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -241,6 +241,7 @@ const SQLEditor = () => {
project_id: project?.id,
})
snap.addSnippet(snippet as SqlSnippet, ref)
+ snap.addNeedsSaving(snippet.id!)
router.push(`/project/${ref}/sql/${snippet.id}`)
} catch (error: any) {
ui.setNotification({
diff --git a/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx b/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
index 8ee9194a042..b9e26219e30 100644
--- a/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
+++ b/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
@@ -29,8 +29,6 @@ const SQLQuickstarts = observer(() => {
subject: { id: profile?.id },
})
- // [Joshen TODO] Removed optimistic query creation logic for now, need to figure out
- // how to do that after using ids as part of the URL
const handleNewQuery = async (sql: string, name: string) => {
if (!ref) return console.error('Project ref is required')
if (!canCreateSQLSnippet) {
@@ -49,6 +47,7 @@ const SQLQuickstarts = observer(() => {
project_id: project?.id,
})
snap.addSnippet(snippet as SqlSnippet, ref)
+ snap.addNeedsSaving(snippet.id!)
router.push(`/project/${ref}/sql/${snippet.id}`)
} catch (error: any) {
ui.setNotification({
diff --git a/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx b/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
index 45c89cdfac1..8d68d6d1ee2 100644
--- a/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
+++ b/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
@@ -49,6 +49,7 @@ const SQLTemplates = observer(() => {
})
snap.addSnippet(snippet as SqlSnippet, project.ref)
+ snap.addNeedsSaving(snippet.id!)
router.push(`/project/${project.ref}/sql/${snippet.id}`)
} catch (error: any) {
ui.setNotification({
diff --git a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
index 663bf8987bb..d39e9f61c05 100644
--- a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
+++ b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
@@ -171,6 +171,7 @@ const QueryItemActions = observer(({ tabInfo, activeId }: QueryItemActionsProps)
project_id: project?.id,
})
snap.addSnippet(snippet as SqlSnippet, ref)
+ snap.addNeedsSaving(snippet.id!)
router.push(`/project/${ref}/sql/${snippet.id}`)
} catch (error: any) {
ui.setNotification({