Files
supabase/apps/studio/components/interfaces/Database/Schemas/ColumnEditionContext.tsx
Gildas Garcia f66eb3f7bd feat: Allow to edit a column from the schema visualiser (#43592)
## Problem

Editing a column from the schema visualiser requires many clicks

## Solution

When hovering over a column in the schema visualiser, an edit button
should appear on the right side. Clicking this button should open the
column edit pane on the right side of the screen. This would reduce the
number of clicks required and allow users to make edits directly from
the visualiser instead of using it only as a visual aid.
2026-03-10 19:28:38 +01:00

23 lines
718 B
TypeScript

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