Skip to content

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

Chore/sql editor fix deleting project snippet (#21973)

Joshen Lim1ea12bfed0ef
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
index 796d1ca9fe5..3ea37fda3dc 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
@@ -1,34 +1,29 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
+import { Keyboard } from 'lucide-react'
+import toast from 'react-hot-toast'
+
+import { RoleImpersonationPopover } from 'components/interfaces/RoleImpersonationSelector'
+import DatabaseSelector from 'components/ui/DatabaseSelector'
+import { useLocalStorageQuery, useSelectedProject } from 'hooks'
import { IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'
import { detectOS } from 'lib/helpers'
+import { useSqlEditorStateSnapshot } from 'state/sql-editor'
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuSeparator,
DropdownMenuTrigger,
IconAlignLeft,
IconCheck,
IconCommand,
IconCornerDownLeft,
IconLoader,
- IconSettings,
- Toggle_Shadcn,
TooltipContent_Shadcn_,
TooltipTrigger_Shadcn_,
Tooltip_Shadcn_,
- cn,
} from 'ui'
-
-import { RoleImpersonationPopover } from 'components/interfaces/RoleImpersonationSelector'
-import DatabaseSelector from 'components/ui/DatabaseSelector'
-import { useLocalStorageQuery, useSelectedProject } from 'hooks'
import FavoriteButton from './FavoriteButton'
import SavingIndicator from './SavingIndicator'
-import toast from 'react-hot-toast'
-import { FileCog, Keyboard, SlidersHorizontal } from 'lucide-react'
-import { useSqlEditorStateSnapshot } from 'state/sql-editor'
export type UtilityActionsProps = {
id: string
@@ -59,6 +54,8 @@ const UtilityActions = ({
return (
<div className="inline-flex items-center justify-end gap-x-2">
+ {IS_PLATFORM && <SavingIndicator id={id} />}
+
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
diff --git a/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx b/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
index 1fe0481e0e6..d260d20d1a5 100644
--- a/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
+++ b/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
@@ -10,7 +10,6 @@ import {
HoverCardContent_Shadcn_,
HoverCardTrigger_Shadcn_,
HoverCard_Shadcn_,
- IconAlertCircle,
IconAlertTriangle,
IconEye,
IconUnlock,
@@ -27,6 +26,7 @@ import CopyButton from 'components/ui/CopyButton'
import { useContentDeleteMutation } from 'data/content/content-delete-mutation'
import type { SqlSnippet } from 'data/content/sql-snippets-query'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
+import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { QueryItemActions } from './QueryItemActions'
export interface QueryItemProps {
@@ -65,7 +65,9 @@ const QueryItem = ({
isDownloadSnippetModalOpen
const { mutate: deleteContent, isLoading: isDeleting } = useContentDeleteMutation({
- onSuccess: (data) => onDeleteQuery(data),
+ onSuccess: (data) => {
+ onDeleteQuery(data)
+ },
onError: (error, data) => {
if (error.message.includes('Contents not found')) {
onDeleteQuery(data.ids)
@@ -198,7 +200,7 @@ const QueryItem = ({
<Modal.Content className="my-6 grid gap-1 text-sm text-foreground-light grid gap-4">
{visibility === 'project' && (
<Alert_Shadcn_ variant="destructive">
- <IconAlertCircle strokeWidth={2} />
+ <CriticalIcon />
<AlertTitle_Shadcn_>This SQL snippet will be lost forever</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
Deleting this query will remove it for all members of the project team.
@@ -219,7 +221,7 @@ const QueryItem = ({
>
<Modal.Content className="my-6 text-sm text-foreground-light grid gap-4 grid gap-1">
<Alert_Shadcn_ variant="warning">
- <IconAlertTriangle strokeWidth={2} />
+ <WarningIcon />
<AlertTitle_Shadcn_>
This SQL query will become public to all team members
</AlertTitle_Shadcn_>
diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
index b2308f3fc59..7bce16ac041 100644
--- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
+++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx
@@ -273,6 +273,7 @@ const SideBarContent = () => {
<QueryItem
key={tabInfo.id}
tabInfo={tabInfo}
+ onDeleteQuery={postDeleteCleanup}
hasQueriesSelected={selectedQueries.length > 0}
/>
))}
diff --git a/packages/ui-patterns/Icons/StatusIcons.tsx b/packages/ui-patterns/Icons/StatusIcons.tsx
index b38da610a0f..075fd1179a4 100644
--- a/packages/ui-patterns/Icons/StatusIcons.tsx
+++ b/packages/ui-patterns/Icons/StatusIcons.tsx
@@ -67,9 +67,9 @@ const CriticalIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
)}
>
<path
- fill-rule="evenodd"
+ fillRule="evenodd"
d="M6.701 2.25c.577-1 2.02-1 2.598 0l5.196 9a1.5 1.5 0 0 1-1.299 2.25H2.804a1.5 1.5 0 0 1-1.3-2.25l5.197-9ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 1 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
- clip-rule="evenodd"
+ clipRule="evenodd"
/>
</svg>
)
@@ -93,9 +93,9 @@ const WarningIcon: React.FC<SVGProps<SVGSVGElement> & StatusIconProps> = ({
)}
>
<path
- fill-rule="evenodd"
+ fillRule="evenodd"
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
- clip-rule="evenodd"
+ clipRule="evenodd"
/>
</svg>
)