The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat/sql editor support bulk deletes (#21004)
Joshen Lim53c5500be4ea
diff --git a/apps/studio/components/grid/components/grid/Grid.tsx b/apps/studio/components/grid/components/grid/Grid.tsxindex 07ecdd73d73..3b849262131 100644--- a/apps/studio/components/grid/components/grid/Grid.tsx+++ b/apps/studio/components/grid/components/grid/Grid.tsx@@ -1,22 +1,23 @@/* eslint-disable react/display-name */-import 'react-data-grid/lib/styles.css'-import DataGrid, { DataGridHandle, RowsChangeData } from 'react-data-grid'import AwesomeDebouncePromise from 'awesome-debounce-promise'import { forwardRef, useRef } from 'react'+import DataGrid, { DataGridHandle, RowsChangeData } from 'react-data-grid'+import 'react-data-grid/lib/styles.css'import { memo } from 'react-tracked'+import { Button } from 'ui'++import { formatClipboardValue } from 'components/grid/utils'import { ForeignRowSelectorProps } from 'components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/ForeignRowSelector'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import AlertError from 'components/ui/AlertError'import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import { useForeignKeyConstraintsQuery } from 'data/database/foreign-key-constraints-query'import { useKeyboardShortcuts, useUrlState } from 'hooks'-import { Button } from 'ui'+import { copyToClipboard } from 'lib/helpers'import { useDispatch, useTrackedState } from '../../store'import { Filter, GridProps, SupaRow } from '../../types'import RowRenderer from './RowRenderer'-import { formatClipboardValue } from 'components/grid/utils'-import { copyToClipboard } from 'lib/helpers'const rowKeyGetter = (row: SupaRow) => {return row?.idx ?? -1@@ -210,8 +211,6 @@ export const Grid = memo(Add rows to your table to get started.</p><div className="flex items-center space-x-2 mt-4">- {/* [Joshen] Leaving this as a placeholder */}- {/* <Button type="outline">Generate random data</Button> */}{onAddRow !== undefined && onImportData !== undefined && (<Button type="default" onClick={onImportData}>Import data via CSVdiff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx b/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsxindex e2dfae21c65..c369d26505f 100644--- a/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.SavedQueriesItem.tsx@@ -44,7 +44,7 @@ const SavedQueriesItem = ({ item }: SavedQueriesItemProps) => {console.error('Invalid project reference')return}- await deleteContent({ projectRef: ref, id: item.id })+ await deleteContent({ projectRef: ref, ids: [item.id] })setShowConfirmModal(false)toast.success('Query deleted')} catch (error) {diff --git a/apps/studio/components/layouts/ProjectLayout/ProductMenuBar.tsx b/apps/studio/components/layouts/ProjectLayout/ProductMenuBar.tsxindex 9ef6665a7ad..8c0c63f9956 100644--- a/apps/studio/components/layouts/ProjectLayout/ProductMenuBar.tsx+++ b/apps/studio/components/layouts/ProjectLayout/ProductMenuBar.tsx@@ -9,8 +9,8 @@ const ProductMenuBar = ({ title, children }: PropsWithChildren<ProductMenuBarPro<divclassName={['hide-scrollbar flex w-64 flex-col border-r', // Layout- 'border-default ','bg-background',+ 'border-default ',].join(' ')}><div@@ -19,9 +19,7 @@ const ProductMenuBar = ({ title, children }: PropsWithChildren<ProductMenuBarPro><h4 className="text-lg">{title}</h4></div>- <div className="flex-grow overflow-y-auto" style={{ maxHeight: 'calc(100vh - 96px)' }}>- {children}- </div>+ <div className="flex-grow overflow-y-auto">{children}</div></div>)}diff --git a/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx b/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsxindex 32218fbf595..df50924b80d 100644--- a/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx+++ b/apps/studio/components/layouts/SQLEditorLayout/QueryItem.tsx@@ -1,29 +1,19 @@-import { PermissionAction } from '@supabase/shared-types/out/constants'import clsx from 'clsx'import { useParams } from 'common'-import { observer } from 'mobx-react-lite'+import { noop } from 'lodash'import Link from 'next/link'import { useRouter } from 'next/router'import { useEffect, useRef, useState } from 'react'+import toast from 'react-hot-toast'import {AlertDescription_Shadcn_,AlertTitle_Shadcn_,Alert_Shadcn_,- Button,- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuSeparator,- DropdownMenuTrigger,+ Checkbox,+ Checkbox_Shadcn_,IconAlertCircle,IconAlertTriangle,- IconChevronDown,- IconCopy,- IconDownload,- IconEdit2,IconEye,- IconShare,- IconTrash,IconUnlock,Modal,TooltipContent_Shadcn_,@@ -33,183 +23,75 @@ import {import DownloadSnippetModal from 'components/interfaces/SQLEditor/DownloadSnippetModal'import RenameQueryModal from 'components/interfaces/SQLEditor/RenameQueryModal'-import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'import ConfirmationModal from 'components/ui/ConfirmationModal'import CopyButton from 'components/ui/CopyButton'import { useContentDeleteMutation } from 'data/content/content-delete-mutation'import { SqlSnippet } from 'data/content/sql-snippets-query'-import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'-import { IS_PLATFORM } from 'lib/constants'-import { uuidv4 } from 'lib/helpers'-import { useProfile } from 'lib/profile'import { useSqlEditorStateSnapshot } from 'state/sql-editor'+import { QueryItemActions } from './QueryItemActions'export interface QueryItemProps {tabInfo: SqlSnippet+ isSelected?: boolean+ hasQueriesSelected?: boolean+ onSelectQuery?: (isShiftHeld: boolean) => void+ onDeleteQuery?: (ids: string[]) => void}-const QueryItem = ({ tabInfo }: QueryItemProps) => {+const QueryItem = ({+ tabInfo,+ isSelected = false,+ hasQueriesSelected = false,+ onSelectQuery = noop,+ onDeleteQuery = noop,+}: QueryItemProps) => {+ const [open, setOpen] = useState(false)+ const [renameModalOpen, setRenameModalOpen] = useState(false)+ const [shareModalOpen, setShareModalOpen] = useState(false)+ const [deleteModalOpen, setDeleteModalOpen] = useState(false)+ const [isDownloadSnippetModalOpen, setIsDownloadSnippetModalOpen] = useState(false)+const { ref, id: activeId } = useParams()- const { id, name, description, content } = tabInfo || {}+ const snap = useSqlEditorStateSnapshot()+ const { id, name, description, content, visibility } = tabInfo || {}const isActive = id === activeIdconst activeItemRef = useRef<HTMLElement | null>(null)- useEffect(() => {- // scroll to active item- if (isActive && activeItemRef.current) {- // race condition hack- setTimeout(() => {- activeItemRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })- }, 0)- }- })-- return (- <Tooltip_Shadcn_ delayDuration={100}>- <TooltipTrigger_Shadcn_ asChild>- <div- key={id}- className={clsx(- 'flex items-center justify-between rounded-md group',- isActive ? 'bg-surface-300' : 'hover:bg-surface-200'- )}- ref={isActive ? (activeItemRef as React.RefObject<HTMLDivElement>) : null}- >- <Link href={`/project/${ref}/sql/${id}`} className="py-1 px-3 w-full overflow-hidden">- <p- title={description || name}- className={clsx(- isActive- ? 'text-foreground'- : 'text-foreground-light group-hover:text-foreground/80',- 'text-sm transition overflow-hidden text-ellipsis'- )}- >- {name}- </p>- </Link>- <div className="pr-1">{<QueryItemActions tabInfo={tabInfo} activeId={activeId} />}</div>- </div>- </TooltipTrigger_Shadcn_>- {!isActive && (- <TooltipContent_Shadcn_- side="right"- align="start"- className="w-96 flex flex-col gap-y-2 py-3 -translate-y-[4px]"- >- <p className="text-xs">Query preview:</p>- <div className="bg-surface-300 py-2 px-3 rounded relative">- {content.sql.trim() ? (- <SimpleCodeBlock- showCopy={false}- className="sql"- parentClassName="!p-0 [&>div>span]:text-xs [&>div>span]:tracking-tighter"- >- {content.sql.replaceAll('\n', ' ').replaceAll(/\s+/g, ' ').slice(0, 43) +- `${content.sql.length > 43 ? '...' : ''}`}- </SimpleCodeBlock>- ) : (- <p className="text-xs text-foreground-lighter">This query is empty</p>- )}- {content.sql.trim() && (- <CopyButton- iconOnly- type="default"- className="px-1 absolute top-1.5 right-1.5"- text={content.sql}- />- )}- </div>- </TooltipContent_Shadcn_>- )}- </Tooltip_Shadcn_>- )-}--export default QueryItem--interface QueryItemActionsProps {- tabInfo: SqlSnippet- activeId: string | undefined-}--const QueryItemActions = observer(({ tabInfo, activeId }: QueryItemActionsProps) => {- const { ui } = useStore()- const { ref } = useParams()- const router = useRouter()- const { profile } = useProfile()-- const snap = useSqlEditorStateSnapshot()- const project = useSelectedProject()-- const { id: snippetID } = tabInfo || {}- const snippet =- snippetID !== undefined && snap.snippets && snap.snippets[snippetID] !== undefined- ? snap.snippets[snippetID]- : null-- const isSnippetOwner = profile?.id === snippet?.snippet.owner_id+ const hideTooltip =+ open ||+ isActive ||+ renameModalOpen ||+ shareModalOpen ||+ deleteModalOpen ||+ isDownloadSnippetModalOpenconst { mutate: deleteContent, isLoading: isDeleting } = useContentDeleteMutation({- onSuccess(data) {- if (data.id) snap.removeSnippet(data.id)-- const existingSnippetIds = (snap.orders[ref!] ?? []).filter((x) => x !== id)- if (existingSnippetIds.length === 0) {- router.push(`/project/${ref}/sql/new`)- } else {- router.push(`/project/${ref}/sql/${existingSnippetIds[0]}`)- }- },- onError(error, data) {+ onSuccess: (data) => onDeleteQuery(data),+ onError: (error, data) => {if (error.code === 404 && error.message.includes('Content not found')) {- if (data.id) snap.removeSnippet(data.id)- const existingSnippetIds = (snap.orders[ref!] ?? []).filter((x) => x !== id)- if (existingSnippetIds.length === 0) {- router.push(`/project/${ref}/sql/new`)- } else {- router.push(`/project/${ref}/sql/${existingSnippetIds[0]}`)- }+ onDeleteQuery(data.ids)} else {- ui.setNotification({- category: 'error',- message: `Failed to delete query: ${error.message}`,- })+ toast.error(`Failed to delete query: ${error.message}`)}},})- const { id, name, visibility, content } = tabInfo || {}- const [renameModalOpen, setRenameModalOpen] = useState(false)- const [shareModalOpen, setShareModalOpen] = useState(false)- const [deleteModalOpen, setDeleteModalOpen] = useState(false)- const [isDownloadSnippetModalOpen, setIsDownloadSnippetModalOpen] = useState(false)- const isActive = id === activeId-- const canCreateSQLSnippet = useCheckPermissions(PermissionAction.CREATE, 'user_content', {- resource: { type: 'sql', owner_id: profile?.id },- subject: { id: profile?.id },- })-- const onCloseRenameModal = () => {- setRenameModalOpen(false)- }-- const onClickRename = (e: any) => {- e.stopPropagation()- setRenameModalOpen(true)- }-- const onClickShare = (e: any) => {- e.stopPropagation()- setShareModalOpen(true)+ const onConfirmDelete = async () => {+ if (!ref) return console.error('Project ref is required')+ if (!id) return console.error('Snippet ID is required')+ deleteContent({ projectRef: ref, ids: [id] })}- const onClickDelete = (e: any) => {- e.stopPropagation()- setDeleteModalOpen(true)- }+ useEffect(() => {+ // scroll to active item+ if (isActive && activeItemRef.current) {+ // race condition hack+ setTimeout(() => {+ activeItemRef.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })+ }, 0)+ }+ })const onConfirmShare = async () => {if (id) {@@ -217,110 +99,107 @@ const QueryItemActions = observer(({ tabInfo, activeId }: QueryItemActionsProps)snap.shareSnippet(id, 'project')return Promise.resolve()} catch (error: any) {- ui.setNotification({- error,- category: 'error',- message: `Failed to share query: ${error.message}`,- })+ toast.error(`Failed to share query: ${error.message}`)}}}- const onConfirmDelete = async () => {- if (!ref) return console.error('Project ref is required')- if (!id) return console.error('Snippet ID is required')- deleteContent({ projectRef: ref, id })- }-- const createPersonalCopy = async () => {- if (!ref) return console.error('Project ref is required')- if (!id) return console.error('Snippet ID is required')- try {- const snippet = createSqlSnippetSkeleton({- id: uuidv4(),- name,- sql: content.sql,- owner_id: profile?.id,- 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({- category: 'error',- message: `Failed to create a personal copy of this query: ${error.message}`,- })- }- }-return (- <div className="group [div&>button[data-state='open']>span]:text-foreground-lighter flex items-center">- {IS_PLATFORM ? (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <span- className={clsx(- 'rounded p-1',- isActive- ? 'text-foreground-light hover:bg-border-stronger'- : 'text-background hover:bg-overlay-hover group-hover:text-foreground-light'- )}- >- <IconChevronDown size="tiny" strokeWidth={2} />- </span>- </DropdownMenuTrigger>- <DropdownMenuContent side="bottom" align="end" className=" w-52 translate-x-[4px]">- {isSnippetOwner && (- <DropdownMenuItem onClick={onClickRename} className="space-x-2">- <IconEdit2 size="tiny" />- <p>Rename query</p>- </DropdownMenuItem>+ <>+ <Tooltip_Shadcn_ delayDuration={100}>+ <TooltipTrigger_Shadcn_ asChild>+ <div+ key={id}+ className={clsx(+ 'h-7 pl-3 pr-2',+ 'flex items-center justify-between rounded-md group relative',+ isActive ? 'bg-surface-300' : 'hover:bg-surface-200')}-- {visibility === 'user' && canCreateSQLSnippet && (- <DropdownMenuItem onClick={onClickShare} className="space-x-2">- <IconShare size="tiny" />- <p>Share query</p>- </DropdownMenuItem>- )}- {visibility === 'project' && canCreateSQLSnippet && (- <DropdownMenuItem onClick={createPersonalCopy} className="space-x-2">- <IconCopy size="tiny" />- <p>Duplicate personal copy</p>- </DropdownMenuItem>+ ref={isActive ? (activeItemRef as React.RefObject<HTMLDivElement>) : null}+ >+ {visibility === 'user' && (+ <Checkbox+ className={clsx(+ 'transition absolute left-2.5 [&>input]:border-foreground-lighter',+ hasQueriesSelected ? '' : 'opacity-0 group-hover:opacity-100'+ )}+ checked={isSelected}+ onChange={(event) => {+ onSelectQuery((event.nativeEvent as KeyboardEvent).shiftKey)+ }}+ />)}-- {IS_PLATFORM && (- <DropdownMenuItem- onClick={() => setIsDownloadSnippetModalOpen(!isDownloadSnippetModalOpen)}- className="space-x-2"+ <div className="flex items-center justify-between w-full gap-x-2">+ <Link+ title={description || name}+ href={`/project/${ref}/sql/${id}`}+ className={clsx(+ 'w-full overflow-hidden truncate',+ isActive+ ? 'text-foreground'+ : 'text-foreground-light group-hover:text-foreground/80',+ 'text-sm transition-all overflow-hidden text-ellipsis',+ hasQueriesSelected && visibility === 'user'+ ? 'ml-5'+ : visibility === 'user'+ ? 'group-hover:ml-5'+ : ''+ )}>- <IconDownload size="tiny" />- <p>Download as migration file</p>- </DropdownMenuItem>- )}- {isSnippetOwner && (- <>- <DropdownMenuSeparator />- <DropdownMenuItem onClick={onClickDelete} className="space-x-2">- <IconTrash size="tiny" />- <p>Delete query</p>- </DropdownMenuItem>- </>- )}- </DropdownMenuContent>- </DropdownMenu>- ) : (- <Button asChild disabled type="text" style={{ padding: '3px' }}>- <span></span>- </Button>- )}+ {name}+ </Link>+ {!hasQueriesSelected && (+ <QueryItemActions+ tabInfo={tabInfo}+ activeId={activeId}+ open={open}+ setOpen={setOpen}+ onSelectDeleteQuery={() => setDeleteModalOpen(true)}+ onSelectRenameQuery={() => setRenameModalOpen(true)}+ onSelectShareQuery={() => setShareModalOpen(true)}+ onSelectDownloadQuery={() => setIsDownloadSnippetModalOpen(true)}+ />+ )}+ </div>+ </div>+ </TooltipTrigger_Shadcn_>+ {!hideTooltip && (+ <TooltipContent_Shadcn_+ side="right"+ align="start"+ className="w-96 flex flex-col gap-y-2 py-3 -translate-y-[4px]"+ >+ <p className="text-xs">Query preview:</p>+ <div className="bg-surface-300 py-2 px-3 rounded relative">+ {content.sql.trim() ? (+ <SimpleCodeBlock+ showCopy={false}+ className="sql"+ parentClassName="!p-0 [&>div>span]:text-xs [&>div>span]:tracking-tighter"+ >+ {content.sql.replaceAll('\n', ' ').replaceAll(/\s+/g, ' ').slice(0, 43) ++ `${content.sql.length > 43 ? '...' : ''}`}+ </SimpleCodeBlock>+ ) : (+ <p className="text-xs text-foreground-lighter">This query is empty</p>+ )}+ {content.sql.trim() && (+ <CopyButton+ iconOnly+ type="default"+ className="px-1 absolute top-1.5 right-1.5"+ text={content.sql}+ />+ )}+ </div>+ </TooltipContent_Shadcn_>+ )}+ </Tooltip_Shadcn_><RenameQueryModalsnippet={tabInfo}visible={renameModalOpen}- onCancel={onCloseRenameModal}- onComplete={onCloseRenameModal}+ onCancel={() => setRenameModalOpen(false)}+ onComplete={() => setRenameModalOpen(false)}/><ConfirmationModalheader="Confirm to delete query"@@ -393,6 +272,8 @@ const QueryItemActions = observer(({ tabInfo, activeId }: QueryItemActionsProps)visible={isDownloadSnippetModalOpen}onCancel={() => setIsDownloadSnippetModalOpen(false)}/>- </div>+ </>)-})+}++export default QueryItemdiff --git a/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsx b/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsxnew file mode 100644index 00000000000..a01b5a7c930--- /dev/null+++ b/apps/studio/components/layouts/SQLEditorLayout/QueryItemActions.tsx@@ -0,0 +1,164 @@+import { PermissionAction } from '@supabase/shared-types/out/constants'+import clsx from 'clsx'+import { IS_PLATFORM, useParams } from 'common'+import { useRouter } from 'next/router'+import {+ Button,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+ IconChevronDown,+ IconCopy,+ IconDownload,+ IconEdit2,+ IconShare,+ IconTrash,+} from 'ui'++import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'+import { SqlSnippet } from 'data/content/sql-snippets-query'+import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'+import { uuidv4 } from 'lib/helpers'+import { useProfile } from 'lib/profile'+import { useSqlEditorStateSnapshot } from 'state/sql-editor'++interface QueryItemActionsProps {+ tabInfo: SqlSnippet+ activeId: string | undefined+ open: boolean+ setOpen: (value: boolean) => void+ onSelectRenameQuery: () => void+ onSelectDeleteQuery: () => void+ onSelectShareQuery: () => void+ onSelectDownloadQuery: () => void+}++export const QueryItemActions = ({+ tabInfo,+ activeId,+ open,+ setOpen,+ onSelectRenameQuery,+ onSelectDeleteQuery,+ onSelectShareQuery,+ onSelectDownloadQuery,+}: QueryItemActionsProps) => {+ const { ui } = useStore()+ const { ref } = useParams()+ const router = useRouter()+ const { profile } = useProfile()++ const snap = useSqlEditorStateSnapshot()+ const project = useSelectedProject()++ const { id, name, visibility, content } = tabInfo || {}++ const canCreateSQLSnippet = useCheckPermissions(PermissionAction.CREATE, 'user_content', {+ resource: { type: 'sql', owner_id: profile?.id },+ subject: { id: profile?.id },+ })++ const { id: snippetID } = tabInfo || {}+ const snippet =+ snippetID !== undefined && snap.snippets && snap.snippets[snippetID] !== undefined+ ? snap.snippets[snippetID]+ : null++ const isSnippetOwner = profile?.id === snippet?.snippet.owner_id++ const onClickRename = (e: any) => {+ e.stopPropagation()+ onSelectRenameQuery()+ }++ const onClickShare = (e: any) => {+ e.stopPropagation()+ onSelectShareQuery()+ }++ const onClickDelete = (e: any) => {+ e.stopPropagation()+ onSelectDeleteQuery()+ }++ const createPersonalCopy = async () => {+ if (!ref) return console.error('Project ref is required')+ if (!id) return console.error('Snippet ID is required')+ try {+ const snippet = createSqlSnippetSkeleton({+ id: uuidv4(),+ name,+ sql: content.sql,+ owner_id: profile?.id,+ 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({+ category: 'error',+ message: `Failed to create a personal copy of this query: ${error.message}`,+ })+ }+ }++ return (+ <div className="group [div&>button[data-state='open']>span]:text-foreground-lighter flex items-center">+ {IS_PLATFORM ? (+ <DropdownMenu open={open} onOpenChange={setOpen}>+ <DropdownMenuTrigger asChild>+ <Button+ type="text"+ className="px-1 opacity-50 hover:opacity-100"+ icon={<IconChevronDown size="tiny" strokeWidth={2} />}+ />+ </DropdownMenuTrigger>+ <DropdownMenuContent side="bottom" align="end" className=" w-52 translate-x-2">+ {isSnippetOwner && (+ <DropdownMenuItem onClick={onClickRename} className="space-x-2">+ <IconEdit2 size="tiny" />+ <p>Rename query</p>+ </DropdownMenuItem>+ )}++ {visibility === 'user' && canCreateSQLSnippet && (+ <DropdownMenuItem onClick={onClickShare} className="space-x-2">+ <IconShare size="tiny" />+ <p>Share query</p>+ </DropdownMenuItem>+ )}+ {visibility === 'project' && canCreateSQLSnippet && (+ <DropdownMenuItem onClick={createPersonalCopy} className="space-x-2">+ <IconCopy size="tiny" />+ <p>Duplicate personal copy</p>+ </DropdownMenuItem>+ )}++ {IS_PLATFORM && (+ <DropdownMenuItem onClick={() => onSelectDownloadQuery()} className="space-x-2">+ <IconDownload size="tiny" />+ <p>Download as migration file</p>+ </DropdownMenuItem>+ )}+ {isSnippetOwner && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem onClick={onClickDelete} className="space-x-2">+ <IconTrash size="tiny" />+ <p>Delete query</p>+ </DropdownMenuItem>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ ) : (+ <Button asChild disabled type="text" style={{ padding: '3px' }}>+ <span />+ </Button>+ )}+ </div>+ )+}diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.utils.ts b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.utils.tsnew file mode 100644index 00000000000..f11d4973e29--- /dev/null+++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorLayout.utils.ts@@ -0,0 +1,23 @@+import { uniq } from 'lodash'++export const selectItemsInRange = (id: string, snippets: any[], selectedSnippets: string[]) => {+ const lastSelectedItemIndex = snippets.findIndex(+ (x) => x.id === selectedSnippets[selectedSnippets.length - 1]+ )+ const selectedItemIndex = snippets.findIndex((x) => x.id === id)++ // Get the start and end index of the range to select+ const start = Math.min(selectedItemIndex, lastSelectedItemIndex)+ const end = Math.max(selectedItemIndex, lastSelectedItemIndex)++ // Get the range to select and reverse the order if necessary+ const rangeToSelect = snippets.slice(start, end + 1)+ if (selectedItemIndex < lastSelectedItemIndex) rangeToSelect.reverse()++ if (selectedSnippets.includes(id)) {+ const rangeToDeselectIds = rangeToSelect.map((item) => item.id)+ return selectedSnippets.filter((x) => x === id || !rangeToDeselectIds.includes(x))+ } else {+ return uniq(selectedSnippets.concat(rangeToSelect.map((x) => x.id) as string[]))+ }+}diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsxindex f186c21f9d2..2be0ab6e683 100644--- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx+++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx@@ -3,32 +3,50 @@ import { useParams } from 'common'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'import { useMemo, useState } from 'react'-import { Button, IconPlus, IconSearch, IconX, Input, Menu, cn } from 'ui'+import toast from 'react-hot-toast'+import {+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Alert_Shadcn_,+ Button,+ IconPlus,+ IconSearch,+ IconX,+ Input,+ Menu,+ Modal,+ Separator,+ TooltipContent_Shadcn_,+ TooltipTrigger_Shadcn_,+ Tooltip_Shadcn_,+} from 'ui'import { untitledSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'+import ConfirmationModal from 'components/ui/ConfirmationModal'+import { WarningIcon } from 'components/ui/Icons'import ProductMenuItem from 'components/ui/ProductMenu/ProductMenuItem'import ShimmeringLoader from 'components/ui/ShimmeringLoader'+import { useContentDeleteMutation } from 'data/content/content-delete-mutation'import { SqlSnippet, useSqlSnippetsQuery } from 'data/content/sql-snippets-query'import { useCheckPermissions, useSelectedProject, useStore } from 'hooks'import { uuidv4 } from 'lib/helpers'import { useProfile } from 'lib/profile'import { useSnippets, useSqlEditorStateSnapshot } from 'state/sql-editor'import QueryItem from './QueryItem'+import { partition, uniq, uniqBy } from 'lodash'+import { selectItemsInRange } from './SQLEditorLayout.utils'const SideBarContent = observer(() => {const { ui } = useStore()- const { ref } = useParams()+ const { ref, id: activeId } = useParams()const router = useRouter()const { profile } = useProfile()const project = useSelectedProject()- const [personalSnippetsFilterString, setPersonalSnippetsFilterString] = useState('')- const [projectSnippetsFilterString, setProjectSnippetsFilterString] = useState('')- const [favoritesFilterString, setFavoritesFilterString] = useState('')- const [isPersonalSnippetsFilterOpen, setIsPersonalSnippetsFilterOpen] = useState(false)- const [isProjectSnippetsFilterOpen, setIsProjectSnippetsFilterOpen] = useState(false)- const [isFavoritesFilterOpen, setIsFavoritesFilterOpen] = useState(false)+ const [searchText, setSearchText] = useState('')+ const [showDeleteModal, setShowDeleteModal] = useState(false)+ const [selectedQueries, setSelectedQueries] = useState<string[]>([])const snap = useSqlEditorStateSnapshot()const { isLoading, isSuccess } = useSqlSnippetsQuery(ref, {@@ -39,6 +57,29 @@ const SideBarContent = observer(() => {},})+ const { mutate: deleteContent, isLoading: isDeleting } = useContentDeleteMutation({+ onSuccess: (data) => postDeleteCleanup(data),+ onError: (error, data) => {+ if (error.code === 404 && error.message.includes('Content not found')) {+ postDeleteCleanup(data.ids)+ } else {+ toast.error(`Failed to delete queries: ${error.message}`)+ }+ },+ })++ const postDeleteCleanup = (ids: string[]) => {+ setShowDeleteModal(false)+ setSelectedQueries([])+ if (ids.length > 0) ids.forEach((id) => snap.removeSnippet(id))+ const existingSnippetIds = (snap.orders[ref!] ?? []).filter((x) => !ids.includes(x))+ if (existingSnippetIds.length === 0) {+ router.push(`/project/${ref}/sql/new`)+ } else if (ids.includes(activeId as string)) {+ router.push(`/project/${ref}/sql/${existingSnippetIds[0]}`)+ }+ }+const snippets = useSnippets(ref)const projectSnippets = useMemo(() => {@@ -46,45 +87,90 @@ const SideBarContent = observer(() => {}, [snippets])const filteredProjectSnippets = useMemo(() => {- if (projectSnippetsFilterString.length > 0) {+ if (searchText.length > 0) {return projectSnippets.filter((tab) =>- tab.name.toLowerCase().includes(projectSnippetsFilterString.toLowerCase())+ tab.name.toLowerCase().includes(searchText.toLowerCase()))}return projectSnippets- }, [projectSnippets, projectSnippetsFilterString])+ }, [projectSnippets, searchText])const personalSnippets = useMemo(() => {const ss = snippets.filter((snippet) => snippet.visibility === 'user' && !snippet.content.favorite)- if (personalSnippetsFilterString.length > 0) {- return ss.filter((tab) =>- tab.name.toLowerCase().includes(personalSnippetsFilterString.toLowerCase())- )+ if (searchText.length > 0) {+ return ss.filter((tab) => tab.name.toLowerCase().includes(searchText.toLowerCase()))}return ss- }, [personalSnippetsFilterString, snippets])+ }, [searchText, snippets])const favoriteSnippets = useMemo(() => {return snippets.filter((snippet) => snippet.content.favorite)}, [snippets])const filteredFavoriteSnippets = useMemo(() => {- if (favoritesFilterString.length > 0) {+ if (searchText.length > 0) {return favoriteSnippets.filter((tab) =>- tab.name.toLowerCase().includes(favoritesFilterString.toLowerCase())+ tab.name.toLowerCase().includes(searchText.toLowerCase()))}return favoriteSnippets- }, [favoriteSnippets, favoritesFilterString])+ }, [favoriteSnippets, searchText])const canCreateSQLSnippet = useCheckPermissions(PermissionAction.CREATE, 'user_content', {resource: { type: 'sql', owner_id: profile?.id },subject: { id: profile?.id },})+ const onSelectQuery = (id?: string, isShiftHeld: boolean = false) => {+ if (id === undefined) return++ if (isShiftHeld) {+ const [selectedFavSnippets, selectedOtherSnippets] = partition(+ selectedQueries,+ (id) => snippets.find((x) => x.id === id)?.content.favorite+ )+ const selectedSnippet = snippets.find((x) => x.id === id)+ const isFavourite = selectedSnippet?.content.favorite++ if (isFavourite) {+ if (selectedFavSnippets.length > 0) {+ const updatedSelectedFavSnippets = selectItemsInRange(+ id,+ filteredFavoriteSnippets,+ selectedFavSnippets+ )+ setSelectedQueries(updatedSelectedFavSnippets.concat(selectedOtherSnippets))+ } else {+ selectQuery(id)+ }+ } else {+ if (selectedOtherSnippets.length > 0) {+ const updatedSelectedOtherSnippets = selectItemsInRange(+ id,+ personalSnippets,+ selectedOtherSnippets+ )+ setSelectedQueries(updatedSelectedOtherSnippets.concat(selectedFavSnippets))+ } else {+ selectQuery(id)+ }+ }+ } else {+ selectQuery(id)+ }+ }++ const selectQuery = (id: string) => {+ if (selectedQueries.includes(id)) {+ setSelectedQueries(selectedQueries.filter((x) => x !== id))+ } else {+ setSelectedQueries(selectedQueries.concat([id]))+ }+ }+const handleNewQuery = async () => {if (!ref) return console.error('Project is required')if (!profile) return console.error('Profile is required')@@ -106,13 +192,7 @@ const SideBarContent = observer(() => {snap.addSnippet(snippet as SqlSnippet, ref)router.push(`/project/${ref}/sql/${snippet.id}`)- // reset all search inputs when a new query is added- setPersonalSnippetsFilterString('')- setProjectSnippetsFilterString('')- setFavoritesFilterString('')- setIsPersonalSnippetsFilterOpen(false)- setIsProjectSnippetsFilterOpen(false)- setIsFavoritesFilterOpen(false)+ setSearchText('')} catch (error: any) {ui.setNotification({category: 'error',@@ -121,254 +201,206 @@ const SideBarContent = observer(() => {}}+ const onConfirmDelete = async () => {+ if (!ref) return console.error('Project ref is required')+ deleteContent({ projectRef: ref, ids: selectedQueries })+ }+return (- <div className="mt-6">- <Menu type="pills">- {isLoading ? (- <div className="px-5 my-4 space-y-2">- <ShimmeringLoader />- <ShimmeringLoader className="w-3/4" />- <ShimmeringLoader className="w-1/2" />- </div>- ) : isSuccess ? (- <div className="space-y-6">- <div className="px-3 flex flex-col gap-2">- <Button- type="default"- className="mx-3 justify-start"- onClick={() => {- handleNewQuery()- }}- icon={<IconPlus size="tiny" />}- >- New query- </Button>+ <>+ <div className="mt-6">+ <Menu type="pills">+ {isLoading ? (+ <div className="px-5 my-4 space-y-2">+ <ShimmeringLoader />+ <ShimmeringLoader className="w-3/4" />+ <ShimmeringLoader className="w-1/2" /></div>- <div className="space-y-6 px-3">- <div>- <ProductMenuItem- name="Templates"- isActive={router.asPath === `/project/${ref}/sql/templates`}- url={`/project/${ref}/sql/templates`}- />- <ProductMenuItem- name="Quickstarts"- isActive={router.asPath === `/project/${ref}/sql/quickstarts`}- url={`/project/${ref}/sql/quickstarts`}+ ) : isSuccess ? (+ <div className="space-y-6">+ <div className="px-4 flex flex-col gap-2">+ <Button+ type="default"+ className="justify-start"+ onClick={() => handleNewQuery()}+ icon={<IconPlus size="tiny" />}+ >+ New query+ </Button>+ <Input+ className="table-editor-search border-none"+ icon={+ <IconSearch className="text-foreground-lighter" size={12} strokeWidth={1.5} />+ }+ placeholder="Search queries"+ onChange={(e) => setSearchText(e.target.value.trim())}+ value={searchText}+ size="tiny"+ actions={+ searchText && (+ <Button type="text" className="px-1" onClick={() => setSearchText('')}>+ <IconX size={12} strokeWidth={2} />+ </Button>+ )+ }/></div>- {favoriteSnippets.length >= 1 && (- <div className="editor-product-menu">- <div className="flex flex-row justify-between">- <Menu.Group title="Favorites" />- <button- className="flex items-center w-4 h-4 cursor-pointer mr-3"- onClick={() => {- setIsFavoritesFilterOpen(!isFavoritesFilterOpen)- }}- >- <IconSearch- className={cn(- 'w-4',- 'h-4',- 'cursor-pointer',- isFavoritesFilterOpen ? 'text-foreground' : 'text-foreground-lighter'- )}- onClick={() => {- setFavoritesFilterString('')- setIsFavoritesFilterOpen((state) => !state)- }}- />- </button>+ <div className="flex flex-col gap-y-6 px-2">+ {searchText.length === 0 && (+ <div>+ <ProductMenuItem+ name="Templates"+ isActive={router.asPath === `/project/${ref}/sql/templates`}+ url={`/project/${ref}/sql/templates`}+ />+ <ProductMenuItem+ name="Quickstarts"+ isActive={router.asPath === `/project/${ref}/sql/quickstarts`}+ url={`/project/${ref}/sql/quickstarts`}+ /></div>- {isFavoritesFilterOpen && (- <div className="pl-3 mb-2 mr-3">- <Input- autoFocus- size="tiny"- icon={<IconSearch size="tiny" />}- placeholder="Filter"- disabled={isLoading}- onChange={(e) => setFavoritesFilterString(e.target.value)}- value={favoritesFilterString}- onKeyDown={(e) => {- if (e.key === 'Escape') {- setIsFavoritesFilterOpen(false)- setFavoritesFilterString('')- }- }}- actions={- favoritesFilterString && (- <IconX- size={'tiny'}- className="mr-2 cursor-pointer"- onClick={() => setFavoritesFilterString('')}- />- )- }- />- </div>- )}- {filteredFavoriteSnippets.length > 0 ? (- <div className="space-y-1">- {filteredFavoriteSnippets.map((tabInfo) => {- const { id } = tabInfo || {}- return <QueryItem key={id} tabInfo={tabInfo} />- })}- </div>- ) : (- <div className="text-foreground text-sm h-32 border border-dashed flex flex-col gap-3 items-center justify-center px-3 mx-3 rounded">- <span className="text-foreground-lighter">No queries found</span>+ )}++ {searchText.length > 0 &&+ filteredFavoriteSnippets.length === 0 &&+ filteredProjectSnippets.length === 0 &&+ personalSnippets.length === 0 && (+ <div className="h-32 border border-dashed flex flex-col gap-y-3 items-center justify-center rounded px-3">+ <div className="flex flex-col gap-y-1 items-center justify-center">+ <p className="text-xs text-foreground">No queries found</p>+ <p className="text-xs text-foreground-light text-center">+ Your search for "{searchText}" did not return any results+ </p>+ </div>+ <Button type="default" onClick={() => handleNewQuery()}>+ New query+ </Button></div>)}- </div>- )}- {projectSnippets.length >= 1 && (- <div className="editor-product-menu">- <div className="flex flex-row justify-between">+ {filteredProjectSnippets.length > 0 ? (+ <div className="editor-product-menu"><Menu.Group title="Project queries" />- <button- className="flex items-center w-4 h-4 cursor-pointer mr-3"- onClick={() => {- setIsProjectSnippetsFilterOpen(!isProjectSnippetsFilterOpen)- }}- >- <IconSearch- className={cn(- 'w-4',- 'h-4',- 'cursor-pointer',- isProjectSnippetsFilterOpen- ? 'text-foreground'- : 'text-foreground-lighter'- )}- onClick={() => {- setProjectSnippetsFilterString('')- setIsProjectSnippetsFilterOpen((state) => !state)- }}- />- </button>- </div>- {isProjectSnippetsFilterOpen && (- <div className="pl-3 mb-2 mr-3">- <Input- autoFocus- size="tiny"- icon={<IconSearch size="tiny" />}- placeholder="Filter"- disabled={isLoading}- onChange={(e) => setProjectSnippetsFilterString(e.target.value)}- value={projectSnippetsFilterString}- onKeyDown={(e) => {- if (e.key === 'Escape') {- setIsProjectSnippetsFilterOpen(false)- setProjectSnippetsFilterString('')- }- }}- actions={- projectSnippetsFilterString && (- <IconX- size={'tiny'}- className="mr-2 cursor-pointer"- onClick={() => setProjectSnippetsFilterString('')}- />- )- }- />- </div>- )}- {filteredProjectSnippets.length > 0 ? (+<div className="space-y-1">{filteredProjectSnippets.map((tabInfo) => {const { id } = tabInfo || {}- return <QueryItem key={id} tabInfo={tabInfo} />+ return (+ <QueryItem+ key={id}+ tabInfo={tabInfo}+ hasQueriesSelected={selectedQueries.length > 0}+ />+ )})}</div>- ) : (- <div className="text-foreground text-sm h-32 border border-dashed flex flex-col gap-3 items-center justify-center px-3 mx-3 rounded">- <span className="text-foreground-lighter">No queries found</span>+ </div>+ ) : null}++ {selectedQueries.length > 0 && (+ <>+ <Separator />+ <div className="px-2 flex items-center gap-x-2">+ <Button block type="default" onClick={() => setShowDeleteModal(true)}>+ Delete {selectedQueries.length.toLocaleString()} quer+ {selectedQueries.length > 1 ? 'ies' : 'y'}+ </Button>+ <Tooltip_Shadcn_ delayDuration={100}>+ <TooltipTrigger_Shadcn_ asChild>+ <Button+ type="default"+ className="px-1"+ icon={<IconX />}+ onClick={() => setSelectedQueries([])}+ />+ </TooltipTrigger_Shadcn_>+ <TooltipContent_Shadcn_ side="bottom">+ Clear selection+ </TooltipContent_Shadcn_>+ </Tooltip_Shadcn_></div>- )}- </div>- )}+ </>+ )}- <div className="editor-product-menu">- <div className="flex flex-row justify-between">- <Menu.Group title="Your queries" />- <button- className="flex items-center w-4 h-4 cursor-pointer mr-3"- onClick={() => {- setIsPersonalSnippetsFilterOpen(!isPersonalSnippetsFilterOpen)- }}- >- <IconSearch- className={cn(- 'w-4',- 'h-4',- 'cursor-pointer',- isPersonalSnippetsFilterOpen ? 'text-foreground' : 'text-foreground-lighter'- )}- onClick={() => {- setPersonalSnippetsFilterString('')- setIsPersonalSnippetsFilterOpen((state) => !state)- }}- />- </button>- </div>- {isPersonalSnippetsFilterOpen && (- <div className="pl-3 mb-2 mr-3">- <Input- autoFocus- size="tiny"- icon={<IconSearch size="tiny" />}- placeholder="Filter"- disabled={isLoading}- onChange={(e) => setPersonalSnippetsFilterString(e.target.value)}- value={personalSnippetsFilterString}- onKeyDown={(e) => {- if (e.key === 'Escape') {- setIsPersonalSnippetsFilterOpen(false)- setPersonalSnippetsFilterString('')- }- }}- actions={- personalSnippetsFilterString && (- <IconX- size={'tiny'}- className="mr-2 cursor-pointer"- onClick={() => setPersonalSnippetsFilterString('')}+ {filteredFavoriteSnippets.length > 0 ? (+ <div className="editor-product-menu">+ <Menu.Group title="Favorites" />+ <div className="space-y-1">+ {filteredFavoriteSnippets.map((tabInfo) => {+ const { id } = tabInfo || {}+ return (+ <QueryItem+ key={id}+ tabInfo={tabInfo}+ isSelected={selectedQueries.includes(id as string)}+ hasQueriesSelected={selectedQueries.length > 0}+ onSelectQuery={(isShiftHeld) => onSelectQuery(id, isShiftHeld)}+ onDeleteQuery={postDeleteCleanup}/>)- }- />+ })}+ </div></div>- )}+ ) : null}+{personalSnippets.length > 0 ? (- <div className="space-y-1 pb-8">- {personalSnippets.map((tabInfo) => {- const { id } = tabInfo || {}- return <QueryItem key={id} tabInfo={tabInfo} />- })}- </div>- ) : (- <div className="text-foreground text-sm h-32 border border-dashed flex flex-col gap-3 items-center justify-center px-3 mx-3 rounded">- {filteredFavoriteSnippets.length === 0 && (- <span className="text-foreground-lighter">No queries found</span>- )}- <Button type="default" onClick={() => handleNewQuery()}>- New Query- </Button>+ <div className="editor-product-menu">+ <Menu.Group title="Your queries" />+ <div className="space-y-1 pb-8">+ {personalSnippets.map((tabInfo) => {+ const { id } = tabInfo || {}+ return (+ <QueryItem+ key={id}+ tabInfo={tabInfo}+ isSelected={selectedQueries.includes(id as string)}+ hasQueriesSelected={selectedQueries.length > 0}+ onSelectQuery={(isShiftHeld) => onSelectQuery(id, isShiftHeld)}+ onDeleteQuery={postDeleteCleanup}+ />+ )+ })}+ </div></div>- )}+ ) : null}+ </div>+ </div>+ ) : (+ <div></div>+ )}+ </Menu>+ </div>+ <ConfirmationModal+ header="Confirm to delete query"+ buttonLabel="Delete query"+ buttonLoadingLabel="Deleting query"+ size="medium"+ loading={isDeleting}+ visible={showDeleteModal}+ onSelectConfirm={onConfirmDelete}+ onSelectCancel={() => setShowDeleteModal(false)}+ >+ <Modal.Content>+ <div className="my-6">+ <div className="text-sm text-foreground-light grid gap-4">+ <div className="grid gap-y-4">+ <Alert_Shadcn_ variant="destructive">+ <WarningIcon />+ <AlertTitle_Shadcn_>This action cannot be undone</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ The selected SQL snippets cannot be recovered once deleted+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ <p>+ Are you sure you want to delete the selected {selectedQueries.length} quer+ {selectedQueries.length > 1 ? 'ies' : 'y'}?+ </p></div></div></div>- ) : (- <div></div>- )}- </Menu>- </div>+ </Modal.Content>+ </ConfirmationModal>+ </>)})diff --git a/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsxindex c371007a0a3..8a1a498e4ad 100644--- a/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx+++ b/apps/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx@@ -191,7 +191,7 @@ const TableEditorMenu = () => {size="tiny"actions={searchText && (- <Button size="tiny" type="text" onClick={() => setSearchText('')}>+ <Button type="text" className="px-1" onClick={() => setSearchText('')}><IconX size={12} strokeWidth={2} /></Button>)diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerHeaderSelection.tsxindex ceb23b01f9e..06d4de34363 100644--- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx+++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerHeaderSelection.tsx@@ -13,13 +13,13 @@ const FileExplorerHeaderSelection = () => {} = storageExplorerStorereturn (- <div className="z-10 flex h-[40px] items-center rounded-t-md bg-brand-400 px-2 py-1 shadow [[data-theme*=dark]_&]:bg-brand-600">+ <div className="z-10 flex h-[40px] items-center rounded-t-md bg-brand-400 px-2 py-1 shadow [[data-theme*=dark]_&]:bg-brand-500"><Buttonicon={<IconX size={16} strokeWidth={2} />}type="text"onClick={() => clearSelectedItems()}/>- <div className="ml-4 flex items-center space-x-3">+ <div className="ml-1 flex items-center space-x-3"><p className="mb-0 text-sm text-foreground"><span style={{ fontVariantNumeric: 'tabular-nums' }}>{selectedItems.length}</span> itemsselected@@ -37,7 +37,7 @@ const FileExplorerHeaderSelection = () => {>Download</Button>- <div className="border-r border-green-800 py-3 opacity-50" />+ <div className="border-r border-green-900 py-3 opacity-50" /><Buttonicon={<IconTrash2 size={16} strokeWidth={2} />}type="primary"diff --git a/apps/studio/data/content/content-delete-mutation.ts b/apps/studio/data/content/content-delete-mutation.tsindex d8586d70129..91dc03c343f 100644--- a/apps/studio/data/content/content-delete-mutation.ts+++ b/apps/studio/data/content/content-delete-mutation.ts@@ -1,30 +1,30 @@import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'import toast from 'react-hot-toast'-import { delete_, isResponseOk } from 'lib/common/fetch'-import { API_URL } from 'lib/constants'-import { ResponseError, UserContent } from 'types'++import { del } from 'data/fetchers'+import { ResponseError } from 'types'import { contentKeys } from './keys'-type DeleteContentVariables = { projectRef: string; id: string }+type DeleteContentVariables = { projectRef: string; ids: string[] }-export async function deleteContent(- { projectRef, id }: DeleteContentVariables,+export async function deleteContents(+ { projectRef, ids }: DeleteContentVariables,signal?: AbortSignal) {- const response = await delete_<UserContent>(- `${API_URL}/projects/${projectRef}/content?id=${id}`,- undefined,- { signal }- )-- if (!isResponseOk(response)) {- throw response.error- }+ const { data, error } = await del('/platform/projects/{ref}/content', {+ headers: { Version: '2' },+ params: {+ path: { ref: projectRef },+ query: { ids },+ },+ signal,+ })- return response+ if (error) throw error+ return data.map((x) => x.id)}-type DeleteContentData = Awaited<ReturnType<typeof deleteContent>>+type DeleteContentData = Awaited<ReturnType<typeof deleteContents>>export const useContentDeleteMutation = ({onSuccess,@@ -37,7 +37,7 @@ export const useContentDeleteMutation = ({const queryClient = useQueryClient()return useMutation<DeleteContentData, ResponseError, DeleteContentVariables>(- (args) => deleteContent(args),+ (args) => deleteContents(args),{async onSuccess(data, variables, context) {const { projectRef } = variables@@ -46,7 +46,7 @@ export const useContentDeleteMutation = ({},async onError(data, variables, context) {if (onError === undefined) {- toast.error(`Failed to delete content: ${data.message}`)+ toast.error(`Failed to delete contents: ${data.message}`)} else {onError(data, variables, context)}