The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Show custom header when viewing view definition
Joshen Lim027eeb00e67d
diff --git a/studio/components/grid/SupabaseGrid.tsx b/studio/components/grid/SupabaseGrid.tsxindex d24242229c9..42c63015358 100644--- a/studio/components/grid/SupabaseGrid.tsx+++ b/studio/components/grid/SupabaseGrid.tsx@@ -58,7 +58,15 @@ export const SupabaseGrid = forwardRef<SupabaseGridRef, SupabaseGridProps>((prop})const SupabaseGridLayout = forwardRef<SupabaseGridRef, SupabaseGridProps>((props, ref) => {- const { editable, storageRef, gridProps, headerActions, showCustomChildren, children } = props+ const {+ editable,+ storageRef,+ gridProps,+ headerActions,+ showCustomChildren,+ customHeader,+ children,+ } = propsconst dispatch = useDispatch()const state = useTrackedState()@@ -197,7 +205,7 @@ const SupabaseGridLayout = forwardRef<SupabaseGridRef, SupabaseGridProps>((propsonAddRow={editable ? props.onAddRow : undefined}onAddColumn={editable ? props.onAddColumn : undefined}headerActions={headerActions}- showCustomChildren={showCustomChildren}+ customHeader={customHeader}/>{showCustomChildren && children !== undefined ? (<>{children}</>diff --git a/studio/components/grid/components/header/Header.tsx b/studio/components/grid/components/header/Header.tsxindex 34c09278692..cd18a1ff7f0 100644--- a/studio/components/grid/components/header/Header.tsx+++ b/studio/components/grid/components/header/Header.tsx@@ -31,7 +31,7 @@ export type HeaderProps = {onAddColumn?: () => voidonAddRow?: () => voidheaderActions?: ReactNode- showCustomChildren?: boolean+ customHeader: ReactNode}const Header = ({@@ -41,7 +41,7 @@ const Header = ({onAddColumn,onAddRow,headerActions,- showCustomChildren,+ customHeader,}: HeaderProps) => {const state = useTrackedState()const { selectedRows } = state@@ -49,7 +49,9 @@ const Header = ({return (<div><div className="flex h-10 items-center justify-between bg-scale-100 px-5 py-1.5 dark:bg-scale-300">- {!showCustomChildren ? (+ {customHeader ? (+ <>{customHeader}</>+ ) : (<>{selectedRows.size > 0 ? (<RowHeader table={table} sorts={sorts} filters={filters} />@@ -57,8 +59,6 @@ const Header = ({<DefaultHeader table={table} onAddColumn={onAddColumn} onAddRow={onAddRow} />)}</>- ) : (- <div></div>)}<div className="sb-grid-header__inner">{headerActions}</div></div>diff --git a/studio/components/grid/types/grid.ts b/studio/components/grid/types/grid.tsindex 918229e565e..491285cb995 100644--- a/studio/components/grid/types/grid.ts+++ b/studio/components/grid/types/grid.ts@@ -87,6 +87,11 @@ export interface SupabaseGridProps {*/showCustomChildren?: boolean+ /**+ * Custom header left most actions component+ */+ customHeader?: ReactNode+/*** Custom component passed as children*/diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsxindex 2e4776cfb0f..8e7ae2a6a26 100644--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx@@ -318,6 +318,11 @@ const TableGridEditor = ({})}+ /** [Joshen] We're going to need to refactor SupabaseGrid eventually to make the code here more readable+ * For context we previously built the SupabaseGrid as a reusable npm component, but eventually decided+ * to just integrate it directly into the dashboard. The header, and body (+footer) should be decoupled.+ */+return (<><SupabaseGrid@@ -361,6 +366,16 @@ const TableGridEditor = ({onExpandJSONEditor={onExpandJSONEditor}onEditForeignKeyColumnValue={onEditForeignKeyColumnValue}showCustomChildren={isViewSelected && selectedView === 'definition'}+ customHeader={+ isViewSelected && selectedView === 'definition' ? (+ <div className="flex items-center space-x-2">+ <p>+ SQL Definition of <code className="text-sm">{selectedTable.name}</code>{' '}+ </p>+ <p className="text-scale-1000 text-sm">(Read only)</p>+ </div>+ ) : null+ }>{isViewSelected && <ViewDefinition name={selectedTable.name} />}</SupabaseGrid>