The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
refactor(studio): migrate all react-contexify usage to ContextMenu_Shadcn_ (#44520)
Ivan Vasilov3f9765e2f81c
diff --git a/apps/studio/components/grid/SupabaseGrid.tsx b/apps/studio/components/grid/SupabaseGrid.tsxindex 6ab669ebfbf..98095f87fba 100644--- a/apps/studio/components/grid/SupabaseGrid.tsx+++ b/apps/studio/components/grid/SupabaseGrid.tsx@@ -1,10 +1,9 @@import { keepPreviousData } from '@tanstack/react-query'import { useParams } from 'common'-import { PropsWithChildren, useEffect, useRef, useState } from 'react'+import { PropsWithChildren, useRef } from 'react'import { DataGridHandle } from 'react-data-grid'import { DndProvider } from 'react-dnd'import { HTML5Backend } from 'react-dnd-html5-backend'-import { createPortal } from 'react-dom'import { useIsTableFilterBarEnabled } from '../interfaces/App/FeaturePreview/FeaturePreviewContext'import { Shortcuts } from './components/common/Shortcuts'@@ -12,7 +11,6 @@ import { Footer } from './components/footer/Footer'import { Grid } from './components/grid/Grid'import { Header, HeaderProps } from './components/header/Header'import { HeaderNew } from './components/header/HeaderNew'-import { RowContextMenu } from './components/menu/RowContextMenu'import { useTableFilter } from './hooks/useTableFilter'import { useTableSort } from './hooks/useTableSort'import { validateMsSqlSorting } from './MsSqlValidation'@@ -46,7 +44,6 @@ export const SupabaseGrid = ({const preflightCheck = !tableEditorSnap.tablesToIgnorePreflightCheck.includes(tableId ?? -1)const gridRef = useRef<DataGridHandle>(null)- const [mounted, setMounted] = useState(false)const newFilterBarEnabled = useIsTableFilterBarEnabled()@@ -89,10 +86,6 @@ export const SupabaseGrid = ({})- useEffect(() => {- if (!mounted) setMounted(true)- }, [])-const operations = (tableEditorSnap.operationQueue.operations as QueuedOperation[]).filter((op) => op.tableId === tableId)@@ -128,8 +121,6 @@ export const SupabaseGrid = ({<Shortcuts gridRef={gridRef} rows={rows} /></>)}-- {mounted && createPortal(<RowContextMenu rows={rows} />, document.body)}</div></DndProvider>)diff --git a/apps/studio/components/grid/components/grid/Grid.tsx b/apps/studio/components/grid/components/grid/Grid.tsxindex 903821c97ac..6bc23b5e0aa 100644--- a/apps/studio/components/grid/components/grid/Grid.tsx+++ b/apps/studio/components/grid/components/grid/Grid.tsx@@ -10,7 +10,7 @@ import type { GridProps, SupaRow } from '../../types'import { isPendingAddRow, isPendingDeleteRow } from '../../types'import { useOnRowsChange } from './Grid.utils'import { GridError } from './GridError'-import { RowRenderer } from './RowRenderer'+import { RowContextMenuProvider, RowRenderer } from './RowRenderer'import { useTableFilterNew } from '@/components/grid/hooks/useTableFilterNew'import { handleCopyCell } from '@/components/grid/SupabaseGrid.utils'import { useIsTableFilterBarEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'@@ -324,26 +324,28 @@ export const Grid = memo(</div>)}- <DataGrid- ref={ref}- className={`${gridClass} flex-grow`}- rowClass={computedRowClass}- columns={columnsWithDirtyCellClass}- rows={rows ?? []}- renderers={{ renderRow: RowRenderer }}- rowKeyGetter={rowKeyGetter}- selectedRows={snap.selectedRows}- onColumnResize={snap.updateColumnSize}- onRowsChange={onRowsChange}- onSelectedCellChange={onSelectedCellChange}- onSelectedRowsChange={onSelectedRowsChange}- onCellDoubleClick={(props) => {- if (typeof props.column.name === 'string') {- onRowDoubleClick(props.row, { name: props.column.name })- }- }}- onCellKeyDown={handleCopyCell}- />+ <RowContextMenuProvider>+ <DataGrid+ ref={ref}+ className={`${gridClass} flex-grow`}+ rowClass={computedRowClass}+ columns={columnsWithDirtyCellClass}+ rows={rows ?? []}+ renderers={{ renderRow: RowRenderer }}+ rowKeyGetter={rowKeyGetter}+ selectedRows={snap.selectedRows}+ onColumnResize={snap.updateColumnSize}+ onRowsChange={onRowsChange}+ onSelectedCellChange={onSelectedCellChange}+ onSelectedRowsChange={onSelectedRowsChange}+ onCellDoubleClick={(props) => {+ if (typeof props.column.name === 'string') {+ onRowDoubleClick(props.row, { name: props.column.name })+ }+ }}+ onCellKeyDown={handleCopyCell}+ />+ </RowContextMenuProvider></div>)}diff --git a/apps/studio/components/grid/components/grid/RowRenderer.tsx b/apps/studio/components/grid/components/grid/RowRenderer.tsxindex 8a9cbb8f1d5..f854b927f4c 100644--- a/apps/studio/components/grid/components/grid/RowRenderer.tsx+++ b/apps/studio/components/grid/components/grid/RowRenderer.tsx@@ -1,22 +1,66 @@-import type { Key } from 'react'-import { TriggerEvent, useContextMenu } from 'react-contexify'+import { createContext, useCallback, useContext, useRef, useState } from 'react'+import type { Key, ReactNode } from 'react'import { RenderRowProps, Row } from 'react-data-grid'+import { flushSync } from 'react-dom'+import { ContextMenu_Shadcn_, ContextMenuTrigger_Shadcn_ } from 'ui'-import { ROW_CONTEXT_MENU_ID } from '@/components/grid/constants'+import { RowContextMenuContent } from '../menu/RowContextMenu'import { SupaRow } from '@/components/grid/types'-/**- * TODO: Refactor to use CellContextMenuWrapper instead of react-contexify- */-export function RowRenderer(key: Key, props: RenderRowProps<SupaRow>) {- const { show: showContextMenu } = useContextMenu()+type RowContextMenuContextValue = {+ onRowContextMenu: (e: React.MouseEvent, row: SupaRow) => void+}++const RowContextMenuContext = createContext<RowContextMenuContextValue | null>(null)- function displayMenu(e: TriggerEvent) {- showContextMenu(e, {- id: ROW_CONTEXT_MENU_ID,- props: { rowIdx: props.rowIdx },- })- }+export function RowContextMenuProvider({ children }: { children: ReactNode }) {+ const triggerRef = useRef<HTMLDivElement>(null)+ const [menuKey, setMenuKey] = useState(0)+ const [activeRow, setActiveRow] = useState<SupaRow | null>(null)++ const onRowContextMenu = useCallback((e: React.MouseEvent, row: SupaRow) => {+ e.preventDefault()+ flushSync(() => setActiveRow(row))+ setMenuKey((prev) => prev + 1)+ const trigger = triggerRef.current+ if (!trigger) return+ trigger.style.left = `${e.clientX}px`+ trigger.style.top = `${e.clientY}px`+ trigger.dispatchEvent(+ new MouseEvent('contextmenu', {+ bubbles: true,+ clientX: e.clientX,+ clientY: e.clientY,+ })+ )+ }, [])++ return (+ <RowContextMenuContext.Provider value={{ onRowContextMenu }}>+ <ContextMenu_Shadcn_ modal={false}>+ <ContextMenuTrigger_Shadcn_ asChild>+ <div ref={triggerRef} className="fixed pointer-events-none w-0 h-0" />+ </ContextMenuTrigger_Shadcn_>+ {activeRow && <RowContextMenuContent key={menuKey} row={activeRow} />}+ </ContextMenu_Shadcn_>+ {children}+ </RowContextMenuContext.Provider>+ )+}- return <Row key={key} {...props} onContextMenu={displayMenu} />+function RowWithContextMenu({ row, ...props }: RenderRowProps<SupaRow>) {+ const ctx = useContext(RowContextMenuContext)++ const handleContextMenu = useCallback(+ (e: React.MouseEvent) => {+ ctx?.onRowContextMenu(e, row)+ },+ [ctx, row]+ )++ return <Row row={row} {...props} onContextMenu={handleContextMenu} />+}++export function RowRenderer(key: Key, props: RenderRowProps<SupaRow>) {+ return <RowWithContextMenu key={key} {...props} />}diff --git a/apps/studio/components/grid/components/menu/RowContextMenu.tsx b/apps/studio/components/grid/components/menu/RowContextMenu.tsxindex cc754943281..ef032e2f2d3 100644--- a/apps/studio/components/grid/components/menu/RowContextMenu.tsx+++ b/apps/studio/components/grid/components/menu/RowContextMenu.tsx@@ -1,154 +1,115 @@+import { ContextMenuContent } from '@ui/components/shadcn/ui/context-menu'import { Copy, Edit, ListFilter, Trash } from 'lucide-react'import { useCallback } from 'react'-import { Item, ItemParams, Menu } from 'react-contexify'import { toast } from 'sonner'-import { copyToClipboard, DialogSectionSeparator } from 'ui'+import { ContextMenuItem_Shadcn_, ContextMenuSeparator_Shadcn_, copyToClipboard } from 'ui'import { useTableRowOperations } from '../../hooks/useTableRowOperations'import { formatClipboardValue } from '../../utils/common'import { buildFilterFromCellValue, isComplexValue } from '../header/filter/FilterPopoverNew.utils'-import { ROW_CONTEXT_MENU_ID } from '@/components/grid/constants'import type { SupaRow } from '@/components/grid/types'import { useIsTableFilterBarEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'import { useTableEditorStateSnapshot } from '@/state/table-editor'import { useTableEditorTableStateSnapshot } from '@/state/table-editor-table'-type RowContextMenuProps = {- rows: SupaRow[]+type RowContextMenuContentProps = {+ row: SupaRow}-type RowContextMenuItemProps = ItemParams<{ rowIdx: number }, string>--export const RowContextMenu = ({ rows }: RowContextMenuProps) => {+export const RowContextMenuContent = ({ row }: RowContextMenuContentProps) => {const tableEditorSnap = useTableEditorStateSnapshot()const snap = useTableEditorTableStateSnapshot()const isTableFilterBarEnabled = useIsTableFilterBarEnabled()const { deleteRows } = useTableRowOperations()- function onDeleteRow(p: RowContextMenuItemProps) {- const rowIdx = p.props?.rowIdx- if (rowIdx === undefined || rowIdx === null) return-- const row = rows[rowIdx]+ const onDeleteRow = useCallback(() => {if (!row) {toast.error('Row not found')return}-deleteRows({ rows: [row], table: snap.originalTable })- }+ }, [row, snap.originalTable, deleteRows])- function onEditRowClick(p: RowContextMenuItemProps) {- const rowIdx = p.props?.rowIdx- if (rowIdx === undefined || rowIdx === null) return-- const row = rows[rowIdx]+ const onEditRowClick = useCallback(() => {tableEditorSnap.onEditRow(row)- }-- const onCopyCellContent = useCallback(- (p: RowContextMenuItemProps) => {- const rowIdx = p.props?.rowIdx- if (!snap.selectedCellPosition || rowIdx === undefined || rowIdx === null) return-- const row = rows[rowIdx]- const columnKey = snap.gridColumns[snap.selectedCellPosition.idx as number].key+ }, [row, tableEditorSnap])- const value = row[columnKey]- const text = formatClipboardValue(value)+ const onCopyCellContent = useCallback(() => {+ if (!snap.selectedCellPosition) return- copyToClipboard(text)- toast.success('Copied cell value to clipboard')- },- [rows, snap.gridColumns, snap.selectedCellPosition]- )-- const onCopyRowContent = useCallback(- (p: RowContextMenuItemProps) => {- const rowIdx = p.props?.rowIdx- if (rowIdx === undefined || rowIdx === null) return+ const columnKey = snap.gridColumns[snap.selectedCellPosition.idx as number].key+ const value = row[columnKey]+ const text = formatClipboardValue(value)- const row = rows[rowIdx]- copyToClipboard(JSON.stringify(row))- toast.success('Copied row to clipboard')- },- [rows]- )+ copyToClipboard(text)+ toast.success('Copied cell value to clipboard')+ }, [row, snap.gridColumns, snap.selectedCellPosition])- const getRowAndColumn = useCallback(- (rowIdx: number | undefined | null) => {- if (!snap.selectedCellPosition || rowIdx === undefined || rowIdx === null) {- return null- }+ const onCopyRowContent = useCallback(() => {+ copyToClipboard(JSON.stringify(row))+ toast.success('Copied row to clipboard')+ }, [row])- const row = rows[rowIdx]- const column = snap.gridColumns[snap.selectedCellPosition.idx as number]+ const getRowAndColumn = useCallback(() => {+ if (!snap.selectedCellPosition) return null- if (!row || !column) return null+ const column = snap.gridColumns[snap.selectedCellPosition.idx as number]+ if (!row || !column) return null- return { row, column }- },- [rows, snap.selectedCellPosition, snap.gridColumns]- )+ return { row, column }+ }, [row, snap.selectedCellPosition, snap.gridColumns])- const onFilterByValue = useCallback(- (p: RowContextMenuItemProps) => {- const result = getRowAndColumn(p.props?.rowIdx)- if (!result) return+ const onFilterByValue = useCallback(() => {+ const result = getRowAndColumn()+ if (!result) return- const { row, column } = result- const newFilter = buildFilterFromCellValue(column.key, row[column.key])- snap.setFilters([...snap.filters, newFilter])+ const { row, column } = result+ const newFilter = buildFilterFromCellValue(column.key, row[column.key])+ snap.setFilters([...snap.filters, newFilter])- const displayValue = newFilter.value === 'null' ? 'NULL' : newFilter.value- toast.success(`Filtering ${column.name} by ${displayValue}`)- },- [getRowAndColumn, snap]- )+ const displayValue = newFilter.value === 'null' ? 'NULL' : newFilter.value+ toast.success(`Filtering ${column.name} by ${displayValue}`)+ }, [getRowAndColumn, snap])- const isFilterByValueHidden = useCallback(- ({ props: itemProps }: { props?: { rowIdx: number } }) => {- if (!isTableFilterBarEnabled) return true+ const isFilterByValueVisible = useCallback(() => {+ if (!isTableFilterBarEnabled) return false- const result = getRowAndColumn(itemProps?.rowIdx)- if (!result) return true+ const result = getRowAndColumn()+ if (!result) return false- return isComplexValue(result.row[result.column.key])- },- [isTableFilterBarEnabled, getRowAndColumn]- )+ return !isComplexValue(result.row[result.column.key])+ }, [isTableFilterBarEnabled, getRowAndColumn])return (- <Menu id={ROW_CONTEXT_MENU_ID} animation={false} className="!min-w-36">- <Item onClick={onCopyCellContent}>+ <ContextMenuContent className="!min-w-36">+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onCopyCellContent}><Copy size={12} />- <span className="ml-2 text-xs">Copy cell</span>- </Item>- <Item onClick={onCopyRowContent}>+ <span className="text-xs">Copy cell</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onCopyRowContent}><Copy size={12} />- <span className="ml-2 text-xs">Copy row</span>- </Item>- <Item onClick={onFilterByValue} hidden={isFilterByValueHidden}>- <ListFilter size={12} />- <span className="ml-2 text-xs">Filter by value</span>- </Item>-- {/* We can't just wrap this entire section in a fragment conditional- on snap.editable because of a bug in react-contexify. Only the- top-level children of Menu are cloned with the necessary bound props,- so Items must be direct children of Menu:- https://github.com/fkhadra/react-contexify/blob/8d9fc63ac13040d3250e8eefd593d50a3ebdd1e6/src/components/Menu.tsx#L295- */}- {snap.editable && <DialogSectionSeparator className="my-1.5" />}- <Item onClick={onEditRowClick} hidden={!snap.editable} data="edit">- <Edit size={12} />- <span className="ml-2 text-xs">Edit row</span>- </Item>- {snap.editable && <DialogSectionSeparator className="my-1.5" />}- <Item onClick={onDeleteRow} hidden={!snap.editable} data="delete">- <Trash size={12} />- <span className="ml-2 text-xs">Delete row</span>- </Item>- </Menu>+ <span className="text-xs">Copy row</span>+ </ContextMenuItem_Shadcn_>+ {isFilterByValueVisible() && (+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onFilterByValue}>+ <ListFilter size={12} />+ <span className="text-xs">Filter by value</span>+ </ContextMenuItem_Shadcn_>+ )}+ {snap.editable && (+ <>+ <ContextMenuSeparator_Shadcn_ />+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onEditRowClick}>+ <Edit size={12} />+ <span className="text-xs">Edit row</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuSeparator_Shadcn_ />+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onDeleteRow}>+ <Trash size={12} />+ <span className="text-xs">Delete row</span>+ </ContextMenuItem_Shadcn_>+ </>+ )}+ </ContextMenuContent>)}diff --git a/apps/studio/components/grid/constants.ts b/apps/studio/components/grid/constants.tsindex 4494d5bd573..cc99ab00137 100644--- a/apps/studio/components/grid/constants.ts+++ b/apps/studio/components/grid/constants.ts@@ -12,5 +12,3 @@ const RLS_ACKNOWLEDGED_KEY = 'supabase-acknowledge-rls-warning'export const rlsAcknowledgedKey = (tableID?: string | number) =>`${RLS_ACKNOWLEDGED_KEY}-${String(tableID)}`--export const ROW_CONTEXT_MENU_ID = 'row-context-menu-id'diff --git a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsxindex 4bf6e8edb81..61ec36fe5f3 100644--- a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx+++ b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx@@ -1,16 +1,18 @@import { PermissionAction } from '@supabase/shared-types/out/constants'+import { ContextMenuContent } from '@ui/components/shadcn/ui/context-menu'import { IS_PLATFORM, useParams } from 'common'import { isEqual } from 'lodash'-import { Copy, Eye, EyeOff, Play, X as XIcon } from 'lucide-react'+import { Copy, Eye, EyeOff, Play } from 'lucide-react'import { Key, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'-import { Item, Menu, useContextMenu } from 'react-contexify'import DataGrid, { Column, RenderRowProps, Row } from 'react-data-grid'-import { createPortal } from 'react-dom'import { toast } from 'sonner'import {Button,Checkbox_Shadcn_,cn,+ ContextMenu_Shadcn_,+ ContextMenuItem_Shadcn_,+ ContextMenuTrigger_Shadcn_,copyToClipboard,ResizableHandle,ResizablePanel,@@ -92,13 +94,30 @@ export const LogTable = ({const { ref } = useParams()const { profile } = useProfile()const [selectedLogId] = useSelectedLog()- const { show: showContextMenu } = useContextMenu()-- const [cellPosition, setCellPosition] = useState<any>()const [selectedRow, setSelectedRow] = useState<LogData | null>(null)const [selectedRows, setSelectedRows] = useState<Set<string>>(new Set())- const [anchorRowId, setAnchorRowId] = useState<string | null>(null)const [copiedFormat, setCopiedFormat] = useState<'json' | 'markdown' | null>(null)+ const triggerRef = useRef<HTMLDivElement>(null)+ const [activeRow, setActiveRow] = useState<LogData | null>(null)+ const [contextMenuKey, setContextMenuKey] = useState(0)++ const handleRowContextMenu = useCallback((e: React.MouseEvent, row: LogData) => {+ e.preventDefault()+ setActiveRow(row)+ // Force re-render of ContextMenuContent to update the current position.+ setContextMenuKey((prev) => prev + 1)+ const trigger = triggerRef.current+ if (!trigger) return+ trigger.style.left = `${e.clientX}px`+ trigger.style.top = `${e.clientY}px`+ trigger.dispatchEvent(+ new MouseEvent('contextmenu', {+ bubbles: true,+ clientX: e.clientX,+ clientY: e.clientY,+ })+ )+ }, [])const { can: canCreateLogQuery } = useAsyncCheckPermissions(PermissionAction.CREATE,@@ -125,8 +144,6 @@ export const LogTable = ({const panelContentMinSize = 40const panelContentMaxSize = 60- const LOGS_EXPLORER_CONTEXT_MENU_ID = 'logs-explorer-context-menu'-const getRowKey = useCallback((row: LogData): string => {if (!hasId) return JSON.stringify(row)@@ -177,7 +194,6 @@ export const LogTable = ({next.add(key)}setSelectedRows(next)- setAnchorRowId(key)if (next.size > 0) {setSelectedRow(null)onSelectedLogChange?.(null)@@ -209,17 +225,7 @@ export const LogTable = ({name: v as string,resizable: true,renderCell: ({ row }) => {- return (- <span- onContextMenu={(e) => {- e.preventDefault()- setCellPosition({ row, column: { name: v } })- showContextMenu(e, { id: LOGS_EXPLORER_CONTEXT_MENU_ID })- }}- >- {formatCellValue(row?.[v])}- </span>- )+ return <span>{formatCellValue(row?.[v])}</span>},renderHeaderCell: () => {return <div className="flex items-center">{v}</div>@@ -267,15 +273,18 @@ export const LogTable = ({columns = [checkboxColumn, ...columns]}+ const onRowClick = useCallback(+ (row: LogData) => {+ // Regular single click — clear multi-select, open side panel+ setSelectedRows(new Set())+ setSelectedRow(row)+ onSelectedLogChange?.(row)+ },+ [onSelectedLogChange]+ )+const RowRenderer = useCallback<(key: Key, props: RenderRowProps<LogData, unknown>) => ReactNode>((key, props) => {- const handleContextMenu = (e: React.MouseEvent) => {- const firstDataColumn = columns.find((c) => c.key !== 'multi-select')- if (firstDataColumn) {- setCellPosition({ row: props.row, column: firstDataColumn })- }- showContextMenu(e, { id: LOGS_EXPLORER_CONTEXT_MENU_ID })- }const handleClick = (e: React.MouseEvent) => {// Check if clicking on the checkbox column - let that handler handle itconst target = e.target as HTMLElement@@ -288,12 +297,12 @@ export const LogTable = ({{...props}isRowSelected={false}selectedCellIdx={undefined}- onContextMenu={handleContextMenu}onClick={handleClick}+ onContextMenu={(e) => handleRowContextMenu(e, props.row)}/>)},- [columns, showContextMenu]+ [handleRowContextMenu, onRowClick])const formatCellValue = (value: any) => {@@ -304,29 +313,10 @@ export const LogTable = ({: String(value)}- const onCopyCell = () => {- if (!cellPosition) return- const eventMessage = cellPosition.row.event_message- copyToClipboard(eventMessage, () => {- toast.success('Copied to clipboard')- })- }-- function onRowClick(row: LogData) {- const key = getRowKey(row)-- // Regular single click — clear multi-select, open side panel- setSelectedRows(new Set())- setAnchorRowId(key)- setSelectedRow(row)- onSelectedLogChange?.(row)- }-const handleKeyDown = useCallback((event: KeyboardEvent) => {if (event.key === 'Escape') {setSelectedRows(new Set())- setAnchorRowId(null)return}@@ -371,7 +361,6 @@ export const LogTable = ({useEffect(() => {if (isLoading) {setSelectedRows(new Set())- setAnchorRowId(null)}}, [isLoading])@@ -510,10 +499,30 @@ export const LogTable = ({sqlQuery={sqlQuery}onClear={() => {setSelectedRows(new Set())- setAnchorRowId(null)}}/></div>+ <ContextMenu_Shadcn_ modal={false}>+ <ContextMenuTrigger_Shadcn_ asChild>+ <div ref={triggerRef} className="fixed pointer-events-none w-0 h-0" />+ </ContextMenuTrigger_Shadcn_>+ <ContextMenuContent key={contextMenuKey}>+ <ContextMenuItem_Shadcn_+ className="gap-x-2"+ onSelect={() => {+ const eventMessage = activeRow?.event_message+ if (eventMessage) {+ copyToClipboard(eventMessage, () => {+ toast.success('Copied to clipboard')+ })+ }+ }}+ >+ <Copy size={14} />+ <span className="text-xs">Copy event message</span>+ </ContextMenuItem_Shadcn_>+ </ContextMenuContent>+ </ContextMenu_Shadcn_><DataGridrole="table"style={{ flex: '1 1 0%', minHeight: 0 }}@@ -523,9 +532,6 @@ export const LogTable = ({})}rowHeight={40}headerRowHeight={queryType ? 0 : 28}- onSelectedCellChange={(row) => {- setCellPosition(row)- }}columns={columns}rowClass={(row: LogData) => {const key = getRowKey(row)@@ -557,16 +563,6 @@ export const LogTable = ({}}/></div>- {typeof window !== 'undefined' &&- createPortal(- <Menu id={LOGS_EXPLORER_CONTEXT_MENU_ID} animation={false}>- <Item onClick={onCopyCell}>- <Copy size={14} />- <span className="ml-2 text-xs">Copy event message</span>- </Item>- </Menu>,- document.body- )}</ResizablePanel>{selectionOpen && (diff --git a/apps/studio/components/interfaces/Storage/Storage.constants.ts b/apps/studio/components/interfaces/Storage/Storage.constants.tsindex 96499a4ff35..c6998dfbd1b 100644--- a/apps/studio/components/interfaces/Storage/Storage.constants.ts+++ b/apps/studio/components/interfaces/Storage/Storage.constants.ts@@ -54,12 +54,6 @@ export const STORAGE_CLIENT_LIBRARY_MAPPINGS = {getPublicUrl: [],}-export const CONTEXT_MENU_KEYS = {- STORAGE_COLUMN: 'STORAGE_COLUMN',- STORAGE_ITEM: 'STORAGE_ITEM',- STORAGE_FOLDER: 'STORAGE_FOLDER',-}-export const BUCKET_TYPES = {files: {displayName: 'Files',diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsxdeleted file mode 100644index 26fbafa5eef..00000000000--- a/apps/studio/components/interfaces/Storage/StorageExplorer/ColumnContextMenu.tsx+++ /dev/null@@ -1,150 +0,0 @@-import { compact, uniqBy } from 'lodash'-import { Item, Menu, Separator, Submenu } from 'react-contexify'--import 'react-contexify/dist/ReactContexify.css'--import { PermissionAction } from '@supabase/shared-types/out/constants'-import { ChevronRight, ChevronsDown, ChevronsUp, Copy, Eye, FolderPlus } from 'lucide-react'--import {- STORAGE_ROW_TYPES,- STORAGE_SORT_BY,- STORAGE_SORT_BY_ORDER,- STORAGE_VIEWS,-} from '../Storage.constants'-import { useStoragePreference } from './useStoragePreference'-import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'-import { useStorageExplorerStateSnapshot } from '@/state/storage-explorer'--interface ColumnContextMenuProps {- id: string-}--export const ColumnContextMenu = ({ id = '' }: ColumnContextMenuProps) => {- const {- projectRef,- columns,- selectedItems,- setSelectedItems,- setSelectedFilePreview,- refetchAllOpenedFolders,- addNewFolderPlaceholder,- } = useStorageExplorerStateSnapshot()- const {- setView,- setSortBy: setPreferenceSortBy,- setSortByOrder: setPreferenceSortByOrder,- } = useStoragePreference(projectRef)-- const setSortBy = async (value: STORAGE_SORT_BY) => {- setPreferenceSortBy(value)- setSelectedFilePreview(undefined)- await refetchAllOpenedFolders()- }-- const setSortByOrder = async (value: STORAGE_SORT_BY_ORDER) => {- setPreferenceSortByOrder(value)- setSelectedFilePreview(undefined)- await refetchAllOpenedFolders()- }-- const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')-- const onSelectCreateFolder = (columnIndex = -1) => {- addNewFolderPlaceholder(columnIndex)- }-- const onSelectAllItemsInColumn = (columnIndex: number) => {- const columnFiles = columns[columnIndex].items- .filter((item) => item.type === STORAGE_ROW_TYPES.FILE)- .map((item) => {- return { ...item, columnIndex }- })- const columnFilesId = compact(columnFiles.map((item) => item.id))- const selectedItemsFromColumn = selectedItems.filter(- (item) => item.id && columnFilesId.includes(item.id)- )-- if (selectedItemsFromColumn.length === columnFiles.length) {- // Deselect all items from column- const updatedSelectedItems = selectedItems.filter(- (item) => item.id && !columnFilesId.includes(item.id)- )- setSelectedItems(updatedSelectedItems)- } else {- // Select all items from column- const updatedSelectedItems = uniqBy(selectedItems.concat(columnFiles), 'id')- setSelectedItems(updatedSelectedItems)- }- }-- return (- <Menu id={id} animation="fade">- {canUpdateFiles && [- <Item key="create-folder" onClick={({ props }) => onSelectCreateFolder(props.index)}>- <FolderPlus size={14} />- <span className="ml-2 text-xs">New folder</span>- </Item>,- <Separator key="create-folder-separator" />,- ]}- <Item onClick={({ props }) => onSelectAllItemsInColumn(props.index)}>- <Copy size={14} />- <span className="ml-2 text-xs">Select all items</span>- </Item>- <Submenu- label={- <div className="flex items-center space-x-2">- <Eye size={14} />- <span className="text-xs">View</span>- </div>- }- arrow={<ChevronRight size={14} />}- >- <Item onClick={() => setView(STORAGE_VIEWS.COLUMNS)}>- <span className="ml-2 text-xs">As columns</span>- </Item>- <Item onClick={() => setView(STORAGE_VIEWS.LIST)}>- <span className="ml-2 text-xs">As list</span>- </Item>- </Submenu>- <Submenu- label={- <div className="flex items-center space-x-2">- <ChevronsDown size={14} />- <span className="ml-2 text-xs">Sort by</span>- </div>- }- arrow={<ChevronRight size={14} />}- >- <Item onClick={() => setSortBy(STORAGE_SORT_BY.NAME)}>- <span className="ml-2 text-xs">Name</span>- </Item>- <Item onClick={() => setSortBy(STORAGE_SORT_BY.CREATED_AT)}>- <span className="ml-2 text-xs">Last created</span>- </Item>- <Item onClick={() => setSortBy(STORAGE_SORT_BY.UPDATED_AT)}>- <span className="ml-2 text-xs">Last modified</span>- </Item>- <Item onClick={() => setSortBy(STORAGE_SORT_BY.LAST_ACCESSED_AT)}>- <span className="ml-2 text-xs">Last accessed</span>- </Item>- </Submenu>- <Submenu- label={- <div className="flex items-center space-x-2">- <ChevronsUp size={14} />- <span className="ml-2 text-xs">Sort by order</span>- </div>- }- arrow={<ChevronRight size={14} />}- >- <Item onClick={() => setSortByOrder(STORAGE_SORT_BY_ORDER.ASC)}>- <span className="ml-2 text-xs">Ascending</span>- </Item>- <Item onClick={() => setSortByOrder(STORAGE_SORT_BY_ORDER.DESC)}>- <span className="ml-2 text-xs">Descending</span>- </Item>- </Submenu>- </Menu>- )-}diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorer.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorer.tsxindex 96f8050989f..4ab8c0c9c2c 100644--- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorer.tsx+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorer.tsx@@ -2,12 +2,9 @@ import { noop } from 'lodash'import { useEffect, useRef } from 'react'import { cn } from 'ui'-import { CONTEXT_MENU_KEYS, STORAGE_ROW_STATUS, STORAGE_VIEWS } from '../Storage.constants'+import { STORAGE_ROW_STATUS, STORAGE_VIEWS } from '../Storage.constants'import type { StorageColumn, StorageItemWithColumn } from '../Storage.types'-import { ColumnContextMenu } from './ColumnContextMenu'import { FileExplorerColumn } from './FileExplorerColumn'-import { FolderContextMenu } from './FolderContextMenu'-import { ItemContextMenu } from './ItemContextMenu'import { useStoragePreference } from './useStoragePreference'import { useStorageExplorerStateSnapshot } from '@/state/storage-explorer'@@ -53,10 +50,6 @@ export const FileExplorer = ({view === STORAGE_VIEWS.LIST && 'flex-col')}>- <ColumnContextMenu id={CONTEXT_MENU_KEYS.STORAGE_COLUMN} />- <ItemContextMenu id={CONTEXT_MENU_KEYS.STORAGE_ITEM} />- <FolderContextMenu id={CONTEXT_MENU_KEYS.STORAGE_FOLDER} />-{isLoading ? (<FileExplorerColumncolumn={{ id: '', name: '', path: '', items: [], status: STORAGE_ROW_STATUS.LOADING }}diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsxindex 40b07c555b4..1036fd20043 100644--- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerColumn.tsx@@ -1,21 +1,33 @@import { Transition } from '@headlessui/react'import { PermissionAction } from '@supabase/shared-types/out/constants'-import { get, noop, sum } from 'lodash'-import { Upload } from 'lucide-react'+import { get, noop, sum, uniqBy } from 'lodash'+import { ChevronsDown, ChevronsUp, Copy, Eye, FolderPlus, Upload } from 'lucide-react'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'-import { useContextMenu } from 'react-contexify'import { toast } from 'sonner'-import { Checkbox, cn } from 'ui'+import {+ Checkbox,+ cn,+ ContextMenu_Shadcn_,+ ContextMenuContent_Shadcn_,+ ContextMenuItem_Shadcn_,+ ContextMenuSeparator_Shadcn_,+ ContextMenuSub_Shadcn_,+ ContextMenuSubContent_Shadcn_,+ ContextMenuSubTrigger_Shadcn_,+ ContextMenuTrigger_Shadcn_,+} from 'ui'import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'import {- CONTEXT_MENU_KEYS,STORAGE_ROW_STATUS,STORAGE_ROW_TYPES,+ STORAGE_SORT_BY,+ STORAGE_SORT_BY_ORDER,STORAGE_VIEWS,} from '../Storage.constants'import type { StorageColumn, StorageItemWithColumn } from '../Storage.types'import { FileExplorerRow } from './FileExplorerRow'+import { FileExplorerRowContextMenuProvider } from './FileExplorerRowContextMenu'import { useStoragePreference } from './useStoragePreference'import { InfiniteListDefault, LoaderForIconMenuItems } from '@/components/ui/InfiniteList'import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'@@ -84,7 +96,7 @@ export const FileExplorerColumn = ({const fileExplorerColumnRef = useRef<any>(null)const snap = useStorageExplorerStateSnapshot()- const { view } = useStoragePreference(snap.projectRef)+ const { view, setSortByOrder, setSortBy, setView } = useStoragePreference(snap.projectRef)const { can: canUpdateStorage } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')useEffect(() => {@@ -110,14 +122,6 @@ export const FileExplorerColumn = ({const isEmpty =column.items.filter((item) => item.status !== STORAGE_ROW_STATUS.LOADING).length === 0- const { show } = useContextMenu()- const displayMenu = (event: any) => {- show(event, {- id: CONTEXT_MENU_KEYS.STORAGE_COLUMN,- props: { index },- })- }-const onDragOver = (event: any) => {if (event) {event.stopPropagation()@@ -165,133 +169,221 @@ export const FileExplorerColumn = ({[view, index, selectedItems])+ const onSelectCreateFolder = () => {+ snap.addNewFolderPlaceholder(index)+ }++ const onSelectAllItems = () => {+ const colFiles = snap.columns[index].items+ .filter((item) => item.type === STORAGE_ROW_TYPES.FILE)+ .map((item) => ({ ...item, columnIndex: index }))+ const colFilesId = colFiles.map((item) => item.id).filter(Boolean)+ const selectedFromCol = selectedItems.filter((item) => item.id && colFilesId.includes(item.id))++ if (selectedFromCol.length === colFiles.length) {+ snap.setSelectedItems(+ selectedItems.filter((item) => item.id && !colFilesId.includes(item.id))+ )+ } else {+ snap.setSelectedItems(uniqBy(selectedItems.concat(colFiles), 'id'))+ }+ }+return (- <div- ref={fileExplorerColumnRef}- className={cn(- fullWidth ? 'w-full' : 'w-64 border-r border-overlay',- view === STORAGE_VIEWS.LIST && 'h-full',- 'hide-scrollbar relative flex flex-shrink-0 flex-col overflow-auto'- )}- onContextMenu={displayMenu}- onDragOver={onDragOver}- onDrop={onDrop}- onClick={(event) => {- const eventTarget = get(event.target, ['className'], '')- if (typeof eventTarget === 'string' && eventTarget.includes('react-contexify')) return- onSelectColumnEmptySpace(index)- }}- >- {/* Checkbox selection for select all */}- {view === STORAGE_VIEWS.COLUMNS && (+ <ContextMenu_Shadcn_ modal={false}>+ <ContextMenuTrigger_Shadcn_ asChild><div+ ref={fileExplorerColumnRef}className={cn(- 'sticky top-0 z-10 mb-0 flex items-center bg-table-header-light px-2.5 [[data-theme*=dark]_&]:bg-table-header-dark',- haveSelectedItems ? 'h-10 py-3 opacity-100' : 'h-0 py-0 opacity-0',- 'transition-all duration-200'+ fullWidth ? 'w-full' : 'w-64 border-r border-overlay',+ view === STORAGE_VIEWS.LIST && 'h-full',+ 'hide-scrollbar relative flex flex-shrink-0 flex-col overflow-auto')}- onClick={(event) => event.stopPropagation()}+ onDragOver={onDragOver}+ onDrop={onDrop}+ onClick={() => {+ onSelectColumnEmptySpace(index)+ }}>- {columnFiles.length > 0 ? (- <>- <SelectAllCheckbox />- <p className="text-sm text-foreground-light">Select all {columnFiles.length} files</p>- </>- ) : (- <p className="text-sm text-foreground-light">No files available for selection</p>+ {/* Checkbox selection for select all */}+ {view === STORAGE_VIEWS.COLUMNS && (+ <div+ className={cn(+ 'sticky top-0 z-10 mb-0 flex items-center bg-table-header-light px-2.5 [[data-theme*=dark]_&]:bg-table-header-dark',+ haveSelectedItems ? 'h-10 py-3 opacity-100' : 'h-0 py-0 opacity-0',+ 'transition-all duration-200'+ )}+ onClick={(event) => event.stopPropagation()}+ >+ {columnFiles.length > 0 ? (+ <>+ <SelectAllCheckbox />+ <p className="text-sm text-foreground-light">+ Select all {columnFiles.length} files+ </p>+ </>+ ) : (+ <p className="text-sm text-foreground-light">No files available for selection</p>+ )}+ </div>)}- </div>- )}- {/* List Interface Header */}- {view === STORAGE_VIEWS.LIST && (- <div className="sticky top-0 py-2 z-10 flex min-w-min items-center border-b border-overlay bg-surface-100 px-2.5">- <div className="flex w-[40%] min-w-[250px] items-center">- <SelectAllCheckbox />- <p className="text-sm">Name</p>- </div>- <p className="w-[11%] min-w-[100px] text-sm">Size</p>- <p className="w-[14%] min-w-[100px] text-sm">Type</p>- <p className="w-[15%] min-w-[160px] text-sm">Created at</p>- <p className="w-[15%] min-w-[160px] text-sm">Last modified at</p>- </div>- )}+ {/* List Interface Header */}+ {view === STORAGE_VIEWS.LIST && (+ <div className="sticky top-0 py-2 z-10 flex min-w-min items-center border-b border-overlay bg-surface-100 px-2.5">+ <div className="flex w-[40%] min-w-[250px] items-center">+ <SelectAllCheckbox />+ <p className="text-sm">Name</p>+ </div>+ <p className="w-[11%] min-w-[100px] text-sm">Size</p>+ <p className="w-[14%] min-w-[100px] text-sm">Type</p>+ <p className="w-[15%] min-w-[160px] text-sm">Created at</p>+ <p className="w-[15%] min-w-[160px] text-sm">Last modified at</p>+ </div>+ )}- {/* Shimmering loaders while fetching contents */}- {column.status === STORAGE_ROW_STATUS.LOADING && (- <div- className={`- ${fullWidth ? 'w-full' : 'w-64 border-r border-default'}- px-2 py-1 my-1 flex flex-shrink-0 flex-col space-y-2 overflow-auto- `}- >- <ShimmeringLoader />- <ShimmeringLoader />- <ShimmeringLoader />- </div>- )}+ {/* Shimmering loaders while fetching contents */}+ {column.status === STORAGE_ROW_STATUS.LOADING && (+ <div+ className={`+ ${fullWidth ? 'w-full' : 'w-64 border-r border-default'}+ px-2 py-1 my-1 flex flex-shrink-0 flex-col space-y-2 overflow-auto+ `}+ >+ <ShimmeringLoader />+ <ShimmeringLoader />+ <ShimmeringLoader />+ </div>+ )}- {/* Column Interface */}- {columnItems.length > 0 && (- <InfiniteListDefault- className="h-full"- items={columnItems}- itemProps={itemProps}- getItemKey={getItemKey}- getItemSize={(index) => (index !== 0 && index === columnItems.length ? 85 : 37)}- ItemComponent={FileExplorerRow}- LoaderComponent={LoaderForIconMenuItems}- hasNextPage={column.status !== STORAGE_ROW_STATUS.LOADING && column.hasMoreItems}- isLoadingNextPage={column.isLoadingMoreItems}- onLoadNextPage={() => onColumnLoadMore(index, column)}- />- )}+ {/* Column Interface */}+ {columnItems.length > 0 && (+ <FileExplorerRowContextMenuProvider>+ <InfiniteListDefault+ className="h-full"+ items={columnItems}+ itemProps={itemProps}+ getItemKey={getItemKey}+ getItemSize={(index) => (index !== 0 && index === columnItems.length ? 85 : 37)}+ ItemComponent={FileExplorerRow}+ LoaderComponent={LoaderForIconMenuItems}+ hasNextPage={column.status !== STORAGE_ROW_STATUS.LOADING && column.hasMoreItems}+ isLoadingNextPage={column.isLoadingMoreItems}+ onLoadNextPage={() => onColumnLoadMore(index, column)}+ />+ </FileExplorerRowContextMenuProvider>+ )}- {/* Drag drop upload CTA for when column is empty */}- {!(snap.isSearching && itemSearchString.length > 0) &&- column.items.length === 0 &&- column.status !== STORAGE_ROW_STATUS.LOADING && (- <div className="h-full w-full flex flex-col items-center justify-center">- <img- alt="storage-placeholder"- src={`${BASE_PATH}/img/storage-placeholder.svg`}- className="opacity-75 pointer-events-none"- />- <p className="text-sm my-3 opacity-75">Drop your files here</p>- <p className="w-40 text-center text-xs text-foreground-light">- Or upload them via the "Upload file" button above- </p>- </div>- )}+ {/* Drag drop upload CTA for when column is empty */}+ {!(snap.isSearching && itemSearchString.length > 0) &&+ column.items.length === 0 &&+ column.status !== STORAGE_ROW_STATUS.LOADING && (+ <div className="h-full w-full flex flex-col items-center justify-center">+ <img+ alt="storage-placeholder"+ src={`${BASE_PATH}/img/storage-placeholder.svg`}+ className="opacity-75 pointer-events-none"+ />+ <p className="text-sm my-3 opacity-75">Drop your files here</p>+ <p className="w-40 text-center text-xs text-foreground-light">+ Or upload them via the "Upload file" button above+ </p>+ </div>+ )}- {snap.isSearching &&- itemSearchString.length > 0 &&- isEmpty &&- column.status !== STORAGE_ROW_STATUS.LOADING && (- <div className="h-full w-full flex flex-col items-center justify-center">- <p className="text-sm my-3 text-foreground">No results found in this folder</p>- <p className="w-40 text-center text-sm text-foreground-light">- Your search for "{itemSearchString}" did not return any results- </p>- </div>- )}+ {snap.isSearching &&+ itemSearchString.length > 0 &&+ isEmpty &&+ column.status !== STORAGE_ROW_STATUS.LOADING && (+ <div className="h-full w-full flex flex-col items-center justify-center">+ <p className="text-sm my-3 text-foreground">No results found in this folder</p>+ <p className="w-40 text-center text-sm text-foreground-light">+ Your search for "{itemSearchString}" did not return any results+ </p>+ </div>+ )}- {/* Drag drop upload CTA for when column has files */}- <DragOverOverlay- isOpen={isDraggedOver}- folderIsEmpty={isEmpty}- onDragLeave={() => setIsDraggedOver(false)}- onDrop={() => setIsDraggedOver(false)}- />+ {/* Drag drop upload CTA for when column has files */}+ <DragOverOverlay+ isOpen={isDraggedOver}+ folderIsEmpty={isEmpty}+ onDragLeave={() => setIsDraggedOver(false)}+ onDrop={() => setIsDraggedOver(false)}+ />- {/* List interface footer */}- {view === STORAGE_VIEWS.LIST && (- <div className="shrink-0 rounded-b-md z-10 flex min-w-min items-center bg-panel-footer-light px-2.5 py-2 [[data-theme*=dark]_&]:bg-panel-footer-dark w-full">- <p className="text-sm">- {formatBytes(columnItemsSize)} for {columnItems.length} items- </p>+ {/* List interface footer */}+ {view === STORAGE_VIEWS.LIST && (+ <div className="shrink-0 rounded-b-md z-10 flex min-w-min items-center bg-panel-footer-light px-2.5 py-2 [[data-theme*=dark]_&]:bg-panel-footer-dark w-full">+ <p className="text-sm">+ {formatBytes(columnItemsSize)} for {columnItems.length} items+ </p>+ </div>+ )}</div>- )}- </div>+ </ContextMenuTrigger_Shadcn_>+ <ContextMenuContent_Shadcn_>+ {canUpdateStorage && (+ <>+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onSelectCreateFolder}>+ <FolderPlus size={14} />+ <span className="text-xs">New folder</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuSeparator_Shadcn_ />+ </>+ )}+ <ContextMenuItem_Shadcn_ className="gap-x-2" onSelect={onSelectAllItems}>+ <Copy size={14} />+ <span className="text-xs">Select all items</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuSub_Shadcn_>+ <ContextMenuSubTrigger_Shadcn_ className="gap-x-2">+ <Eye size={14} />+ <span className="text-xs">View</span>+ </ContextMenuSubTrigger_Shadcn_>+ <ContextMenuSubContent_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setView(STORAGE_VIEWS.COLUMNS)}>+ <span className="text-xs">As columns</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setView(STORAGE_VIEWS.LIST)}>+ <span className="text-xs">As list</span>+ </ContextMenuItem_Shadcn_>+ </ContextMenuSubContent_Shadcn_>+ </ContextMenuSub_Shadcn_>+ <ContextMenuSub_Shadcn_>+ <ContextMenuSubTrigger_Shadcn_ className="gap-x-2">+ <ChevronsDown size={14} />+ <span className="text-xs">Sort by</span>+ </ContextMenuSubTrigger_Shadcn_>+ <ContextMenuSubContent_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setSortBy(STORAGE_SORT_BY.NAME)}>+ <span className="text-xs">Name</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setSortBy(STORAGE_SORT_BY.CREATED_AT)}>+ <span className="text-xs">Last created</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setSortBy(STORAGE_SORT_BY.UPDATED_AT)}>+ <span className="text-xs">Last modified</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setSortBy(STORAGE_SORT_BY.LAST_ACCESSED_AT)}>+ <span className="text-xs">Last accessed</span>+ </ContextMenuItem_Shadcn_>+ </ContextMenuSubContent_Shadcn_>+ </ContextMenuSub_Shadcn_>+ <ContextMenuSub_Shadcn_>+ <ContextMenuSubTrigger_Shadcn_ className="gap-x-2">+ <ChevronsUp size={14} />+ <span className="text-xs">Sort by order</span>+ </ContextMenuSubTrigger_Shadcn_>+ <ContextMenuSubContent_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setSortByOrder(STORAGE_SORT_BY_ORDER.ASC)}>+ <span className="text-xs">Ascending</span>+ </ContextMenuItem_Shadcn_>+ <ContextMenuItem_Shadcn_ onSelect={() => setSortByOrder(STORAGE_SORT_BY_ORDER.DESC)}>+ <span className="text-xs">Descending</span>+ </ContextMenuItem_Shadcn_>+ </ContextMenuSubContent_Shadcn_>+ </ContextMenuSub_Shadcn_>+ </ContextMenuContent_Shadcn_>+ </ContextMenu_Shadcn_>)}diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsxindex 06d1da299ad..d206131f040 100644--- a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRow.tsx@@ -17,7 +17,6 @@ import {Trash2,} from 'lucide-react'import type { CSSProperties } from 'react'-import { useContextMenu } from 'react-contexify'import {Checkbox,cn,@@ -36,13 +35,13 @@ import {} from 'ui'import {- CONTEXT_MENU_KEYS,STORAGE_ROW_STATUS,STORAGE_ROW_TYPES,STORAGE_VIEWS,URL_EXPIRY_DURATION,} from '../Storage.constants'import { StorageItemWithColumn, type StorageItem } from '../Storage.types'+import { useFileExplorerContextMenu } from './FileExplorerRowContextMenu'import { FileExplorerRowEditing } from './FileExplorerRowEditing'import { copyPathToFolder } from './StorageExplorer.utils'import { useCopyUrl } from './useCopyUrl'@@ -127,8 +126,8 @@ export const FileExplorerRow = ({downloadFolder,selectRangeItems,} = useStorageExplorerStateSnapshot()- const { show } = useContextMenu()const { onCopyUrl } = useCopyUrl()+ const ctx = useFileExplorerContextMenu()const isPublic = selectedBucket.publicconst itemWithColumnIndex = { ...item, columnIndex }@@ -272,18 +271,6 @@ export const FileExplorerRow = ({const createdAt = item.created_at ? new Date(item.created_at).toLocaleString() : '-'const updatedAt = item.updated_at ? new Date(item.updated_at).toLocaleString() : '-'- const displayMenu = (event: any, rowType: STORAGE_ROW_TYPES) => {- show(event, {- id:- rowType === STORAGE_ROW_TYPES.FILE- ? CONTEXT_MENU_KEYS.STORAGE_ITEM- : CONTEXT_MENU_KEYS.STORAGE_FOLDER,- props: {- item: itemWithColumnIndex,- },- })- }-const nameWidth =view === STORAGE_VIEWS.LIST && item.isCorrupted? `calc(100% - 60px)`@@ -301,12 +288,7 @@ export const FileExplorerRow = ({<divstyle={style}className="h-full border-b border-default"- onContextMenu={(event) => {- event.stopPropagation()- item.type === STORAGE_ROW_TYPES.FILE- ? displayMenu(event, STORAGE_ROW_TYPES.FILE)- : displayMenu(event, STORAGE_ROW_TYPES.FOLDER)- }}+ onContextMenu={(e) => ctx?.onRowContextMenu(e, rowOptions)}><divclassName={cn(diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRowContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRowContextMenu.tsxnew file mode 100644index 00000000000..3884aca9b2a--- /dev/null+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/FileExplorerRowContextMenu.tsx@@ -0,0 +1,108 @@+import { createContext, useCallback, useContext, useRef, useState } from 'react'+import type { ReactNode } from 'react'+import { flushSync } from 'react-dom'+import {+ ContextMenu_Shadcn_,+ ContextMenuContent_Shadcn_,+ ContextMenuItem_Shadcn_,+ ContextMenuSeparator_Shadcn_,+ ContextMenuSub_Shadcn_,+ ContextMenuSubContent_Shadcn_,+ ContextMenuSubTrigger_Shadcn_,+ ContextMenuTrigger_Shadcn_,+} from 'ui'++export type RowOptionChild = { name: string; onClick: () => void }+export type RowOption = {+ name: string+ icon?: ReactNode+ onClick?: () => void+ children?: RowOptionChild[]+}++type FileExplorerContextMenuContextValue = {+ onRowContextMenu: (e: React.MouseEvent, options: RowOption[]) => void+}++const FileExplorerContextMenuContext = createContext<FileExplorerContextMenuContextValue | null>(+ null+)++export function useFileExplorerContextMenu() {+ return useContext(FileExplorerContextMenuContext)+}++/**+ * Context provider for the file explorer row context menu. This allows us to reuse a single context menu and event handlers.+ */+export function FileExplorerRowContextMenuProvider({ children }: { children: ReactNode }) {+ const triggerRef = useRef<HTMLDivElement>(null)+ const [contextMenuKey, setContextMenuKey] = useState(0)+ const [activeOptions, setActiveOptions] = useState<RowOption[]>([])++ const onRowContextMenu = useCallback((e: React.MouseEvent, options: RowOption[]) => {+ e.preventDefault()+ setActiveOptions(options)+ setContextMenuKey((prev) => prev + 1)+ const trigger = triggerRef.current+ if (!trigger) return+ trigger.style.left = `${e.clientX}px`+ trigger.style.top = `${e.clientY}px`+ trigger.dispatchEvent(+ new MouseEvent('contextmenu', {+ bubbles: true,+ clientX: e.clientX,+ clientY: e.clientY,+ })+ )+ }, [])++ return (+ <FileExplorerContextMenuContext.Provider value={{ onRowContextMenu }}>+ <ContextMenu_Shadcn_ modal={false}>+ <ContextMenuTrigger_Shadcn_ asChild>+ <div ref={triggerRef} className="fixed pointer-events-none w-0 h-0" />+ </ContextMenuTrigger_Shadcn_>+ <ContextMenuContent_Shadcn_+ key={contextMenuKey}+ onCloseAutoFocus={(e) => e.stopPropagation()}+ onClick={(e) => e.stopPropagation()}+ >+ {activeOptions.map((option) => {+ if ((option.children ?? []).length > 0) {+ return (+ <ContextMenuSub_Shadcn_ key={option.name}>+ <ContextMenuSubTrigger_Shadcn_ className="gap-x-2">+ {option.icon || <></>}+ <span className="text-xs">{option.name}</span>+ </ContextMenuSubTrigger_Shadcn_>+ <ContextMenuSubContent_Shadcn_>+ {(option.children ?? []).map((child) => (+ <ContextMenuItem_Shadcn_ key={child.name} onSelect={child.onClick}>+ <span className="text-xs">{child.name}</span>+ </ContextMenuItem_Shadcn_>+ ))}+ </ContextMenuSubContent_Shadcn_>+ </ContextMenuSub_Shadcn_>+ )+ } else if (option.name === 'Separator') {+ return <ContextMenuSeparator_Shadcn_ key={option.name} />+ } else {+ return (+ <ContextMenuItem_Shadcn_+ className="gap-x-2"+ key={option.name}+ onSelect={option.onClick}+ >+ {option.icon || <></>}+ <span className="text-xs">{option.name}</span>+ </ContextMenuItem_Shadcn_>+ )+ }+ })}+ </ContextMenuContent_Shadcn_>+ </ContextMenu_Shadcn_>+ {children}+ </FileExplorerContextMenuContext.Provider>+ )+}diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsxdeleted file mode 100644index 9c0050bf34c..00000000000--- a/apps/studio/components/interfaces/Storage/StorageExplorer/FolderContextMenu.tsx+++ /dev/null@@ -1,45 +0,0 @@-import { PermissionAction } from '@supabase/shared-types/out/constants'-import { Copy, Download, Edit, Trash2 } from 'lucide-react'-import { Item, Menu, Separator } from 'react-contexify'--import 'react-contexify/dist/ReactContexify.css'--import { copyPathToFolder } from './StorageExplorer.utils'-import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'-import { useStorageExplorerStateSnapshot } from '@/state/storage-explorer'--interface FolderContextMenuProps {- id: string-}--export const FolderContextMenu = ({ id = '' }: FolderContextMenuProps) => {- const { openedFolders, downloadFolder, setSelectedItemToRename, setSelectedItemsToDelete } =- useStorageExplorerStateSnapshot()- const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')-- return (- <Menu id={id} animation="fade">- {canUpdateFiles && (- <Item onClick={({ props }) => setSelectedItemToRename(props.item)}>- <Edit size={12} />- <span className="ml-2 text-xs">Rename</span>- </Item>- )}- <Item onClick={({ props }) => downloadFolder(props.item)}>- <Download size={12} />- <span className="ml-2 text-xs">Download</span>- </Item>- <Item onClick={({ props }) => copyPathToFolder(openedFolders, props.item)}>- <Copy size={12} />- <span className="ml-2 text-xs">Copy path to folder</span>- </Item>- {canUpdateFiles && [- <Separator key="separator" />,- <Item key="delete" onClick={({ props }) => setSelectedItemsToDelete([props.item])}>- <Trash2 size={12} />- <span className="ml-2 text-xs">Delete</span>- </Item>,- ]}- </Menu>- )-}diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsx b/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsxdeleted file mode 100644index 6b7ec64b323..00000000000--- a/apps/studio/components/interfaces/Storage/StorageExplorer/ItemContextMenu.tsx+++ /dev/null@@ -1,109 +0,0 @@-import { PermissionAction } from '@supabase/shared-types/out/constants'-import { ChevronRight, Copy, Download, Edit, Move, Trash2 } from 'lucide-react'-import { Item, Menu, Separator, Submenu } from 'react-contexify'--import 'react-contexify/dist/ReactContexify.css'--import { useParams } from 'common'--import { URL_EXPIRY_DURATION } from '../Storage.constants'-import { StorageItemWithColumn } from '../Storage.types'-import { useCopyUrl } from './useCopyUrl'-import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'-import { useStorageExplorerStateSnapshot } from '@/state/storage-explorer'--interface ItemContextMenuProps {- id: string-}--export const ItemContextMenu = ({ id = '' }: ItemContextMenuProps) => {- const snap = useStorageExplorerStateSnapshot()- const { setSelectedFileCustomExpiry } = snap-- const {- selectedBucket,- setSelectedItemsToDelete,- setSelectedItemToRename,- setSelectedItemsToMove,- downloadFile,- } = useStorageExplorerStateSnapshot()- const { onCopyUrl } = useCopyUrl()- const isPublic = selectedBucket.public- const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')-- const onHandleClick = async (event: any, item: StorageItemWithColumn, expiresIn?: number) => {- if (item.isCorrupted) return- switch (event) {- case 'copy':- if (expiresIn !== undefined && expiresIn < 0) return setSelectedFileCustomExpiry(item)- if (item.path) return onCopyUrl(item.path, expiresIn)- case 'rename':- return setSelectedItemToRename(item)- case 'move':- return setSelectedItemsToMove([item])- case 'download':- return await downloadFile(item)- default:- break- }- }-- return (- <Menu id={id} animation="fade">- {isPublic ? (- <Item onClick={({ props }) => onHandleClick('copy', props.item)}>- <Copy size={14} />- <span className="ml-2 text-xs">Get URL</span>- </Item>- ) : (- <Submenu- label={- <div className="flex items-center space-x-2">- <Copy size={14} />- <span className="text-xs">Get URL</span>- </div>- }- arrow={<ChevronRight size={14} />}- >- <Item- onClick={({ props }) => onHandleClick('copy', props.item, URL_EXPIRY_DURATION.WEEK)}- >- <span className="ml-2 text-xs">Expire in 1 week</span>- </Item>- <Item- onClick={({ props }) => onHandleClick('copy', props.item, URL_EXPIRY_DURATION.MONTH)}- >- <span className="ml-2 text-xs">Expire in 1 month</span>- </Item>- <Item- onClick={({ props }) => onHandleClick('copy', props.item, URL_EXPIRY_DURATION.YEAR)}- >- <span className="ml-2 text-xs">Expire in 1 year</span>- </Item>- <Item onClick={({ props }) => onHandleClick('copy', props.item, -1)}>- <span className="ml-2 text-xs">Custom expiry</span>- </Item>- </Submenu>- )}- <Item onClick={({ props }) => onHandleClick('download', props.item)}>- <Download size={14} strokeWidth={1} />- <span className="ml-2 text-xs">Download</span>- </Item>- {canUpdateFiles && [- <Item key="rename-file" onClick={({ props }) => onHandleClick('rename', props.item)}>- <Edit size={14} strokeWidth={1} />- <span className="ml-2 text-xs">Rename</span>- </Item>,- <Item key="move-file" onClick={({ props }) => onHandleClick('move', props.item)}>- <Move size={14} strokeWidth={1} />- <span className="ml-2 text-xs">Move</span>- </Item>,- <Separator key="file-separator" />,- <Item key="delete-file" onClick={({ props }) => setSelectedItemsToDelete([props.item])}>- <Trash2 size={14} strokeWidth={1} stroke="red" />- <span className="ml-2 text-xs">Delete</span>- </Item>,- ]}- </Menu>- )-}diff --git a/apps/studio/package.json b/apps/studio/package.jsonindex 59cf855f1fe..1b90622e2b6 100644--- a/apps/studio/package.json+++ b/apps/studio/package.json@@ -116,7 +116,6 @@"randombytes": "^2.1.0","react": "catalog:","react-beautiful-dnd": "^13.1.0",- "react-contexify": "^5.0.0","react-data-grid": "7.0.0-beta.47","react-day-picker": "^9.11.1","react-dnd": "^16.0.1",diff --git a/apps/studio/pages/_app.tsx b/apps/studio/pages/_app.tsxindex 27cb705ad4b..cda1453cadd 100644--- a/apps/studio/pages/_app.tsx+++ b/apps/studio/pages/_app.tsx@@ -1,6 +1,5 @@import 'react-data-grid/lib/styles.css'import 'styles/code.scss'-import 'styles/contextMenu.scss'import 'styles/editor.scss'import 'styles/focus.scss'import 'styles/graphiql-base.scss'diff --git a/apps/studio/styles/contextMenu.scss b/apps/studio/styles/contextMenu.scssdeleted file mode 100644index 1924b3acf44..00000000000--- a/apps/studio/styles/contextMenu.scss+++ /dev/null@@ -1,22 +0,0 @@-.react-contexify {- @apply border border-default;- background-color: hsl(var(--background-surface-100)) !important;-- .react-contexify__item {- .react-contexify__item__content {- @apply text-foreground-light text-sm;- }- .react-contexify__submenu {- @apply bg-surface-100 border;- }- }- .react-contexify__item:not(.react-contexify__item--disabled):hover- > .react-contexify__item__content,- .react-contexify__item:not(.react-contexify__item--disabled):focus- > .react-contexify__item__content {- @apply bg-overlay-hover text-foreground;- }- .react-contexify__separator {- @apply bg-surface-300;- }-}diff --git a/apps/studio/styles/grid.scss b/apps/studio/styles/grid.scssindex faed1baaf7c..ee0dfa861e4 100644--- a/apps/studio/styles/grid.scss+++ b/apps/studio/styles/grid.scss@@ -244,77 +244,6 @@background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='hsl(0, 0%, 0%)'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E") !important;}-/*- React Contexify-*/--.react-contexify {- position: fixed;- opacity: 0;- user-select: none;- background-color: #fff;- box-sizing: border-box;- box-shadow: 0px 10px 30px -5px rgba(0, 0, 0, 0.3);- border-radius: 6px;- padding: 6px 0;- min-width: 200px;- z-index: 100;-}-.react-contexify__submenu--is-open,-.react-contexify__submenu--is-open > .react-contexify__item__content {- color: white;- background-color: #4393e6;-}-.react-contexify__submenu--is-open > .react-contexify__submenu {- pointer-events: initial;- opacity: 1;-}-.react-contexify .react-contexify__submenu {- position: absolute;- /* negate padding */- top: -6px;- pointer-events: none;- transition: opacity 0.275s;-}-.react-contexify__submenu-arrow {- margin-left: auto;- font-size: 12px;-}-.react-contexify__will-leave--disabled {- pointer-events: none;-}-.react-contexify__item {- cursor: pointer;- position: relative;-}-.react-contexify__item:focus {- outline: 0;-}-.react-contexify__item:not(.react-contexify__item--disabled):hover- > .react-contexify__item__content,-.react-contexify__item:not(.react-contexify__item--disabled):focus- > .react-contexify__item__content {- color: white;- background-color: #4393e6;-}-.react-contexify__item:not(.react-contexify__item--disabled):hover > .react-contexify__submenu {- pointer-events: initial;- opacity: 1;-}-.react-contexify__item--disabled {- cursor: default;- opacity: 0.5;-}-.react-contexify__item__content {- font-size: 13px;- padding: 6px 12px;- display: flex;- align-items: center;- white-space: nowrap;- color: #333;- position: relative;-}-.rdg__segmented-control {@apply border-default relative mx-2 h-8 rounded-md border;}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d99d9da4030..c231893c857 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1096,9 +1096,6 @@ importers:react-beautiful-dnd:specifier: ^13.1.0- react-contexify:- specifier: ^5.0.0react-data-grid:specifier: 7.0.0-beta.47version: 7.0.0-beta.47(patch_hash=803f02d6cede565990ab9675326b93195b98bcc6477a4811715405892c257488)([email protected]([email protected]))([email protected])@@ -15993,13 +15990,6 @@ packages:peerDependencies:react: ^17.0.0 || ^18.0.0 || ^19.0.0 || ^0.0.0-experimental- resolution: {integrity: sha512-2FIp7lxJ6dtfGr8EZ4uVV5p5TQjd0n2h/JU7PrejNIMiCeZWvSVPFh4lj1ZvjXosglBvP7q5JQQ8yUCdSaMSaw==}- engines: {node: '>=10'}- peerDependencies:- react: '>=16'- react-dom: '>=16'-resolution: {integrity: sha512-k61RsNgAayIJNoy9yDsYzDe/yAZAzEbEgcz3DZMhF686LEyukcE1hzurxe85JandPUG+yTfGVFzuEw3xt8WP/A==}peerDependencies:@@ -34886,12 +34876,6 @@ snapshots:dependencies:react: 18.3.1- dependencies:- clsx: 1.2.1- react: 18.3.1- react-dom: 18.3.1([email protected])-dependencies:copy-to-clipboard: 3.3.3