Files
supabase/apps/studio/components/interfaces/Database/Schemas/SchemaGraphContext.tsx
T
Gildas Garcia db14762aa6 feat: Add table and column menus in schema visualiser (#43693)
## Problem

- The schema visualiser lacks editing capabilities which leads to a lot
of navigation (ediing tables, columns)
- ReactFlow prevents users from selecting table and column names (to
copy them). Diasbling drag and pan on those texts would make moving
items cumbersome
- Long table and column names are hidden and even hide other elements

## Solution

- Add menus for both tables and columns
- Truncate long names with ellipsis and add a tooltip
- Hide menus when exporting to png/svg

[Screen Recording 2026-03-12 at
10.10.08.webm](https://github.com/user-attachments/assets/b2780266-e874-41d1-ac82-7c2c4ba5abf2)
2026-03-16 22:14:44 +01:00

25 lines
762 B
TypeScript

import { createContext, useContext, type ReactNode } from 'react'
export type SchemaGraphContextType = {
isDownloading: boolean
onEditColumn: (tableId: number, columnId: string) => void
onEditTable: (tableId: number) => void
}
export const SchemaGraphContext = createContext<SchemaGraphContextType | null>(null)
export const SchemaGraphContextProvider = ({
children,
value,
}: {
children: ReactNode
value: SchemaGraphContextType
}) => <SchemaGraphContext.Provider value={value}>{children}</SchemaGraphContext.Provider>
export const useSchemaGraphContext = () => {
const context = useContext(SchemaGraphContext)
if (!context)
throw new Error('useSchemaGraphContext must be used inside a <SchemaGraphContextProvider>')
return context
}