mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 22:18:00 +08:00
## 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.
23 lines
718 B
TypeScript
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
|
|
}
|