mirror of
https://github.com/supabase/supabase.git
synced 2026-09-29 22:42:58 +08:00
## What kind of change does this PR introduce? Feature. Resolves DEPR-599. ## What is the current behavior? When the Data API is disabled (PostgREST has no exposed schemas), the Connect sheet still shows client-library setup steps for Framework and MCP modes without indicating that database queries will fail. ## What is the new behavior? When database access via the Connect instructions requires PostgREST, an inline warning appears above the steps (setup instructions remain visible): - **Framework**: warns when Data API is off; install, env vars, and auth/SSR setup still work - **MCP**: warns only when Database tools apply (selected explicitly, or by default when no feature filter is set) The warning fails open if PostgREST config cannot be loaded, and links to Data API settings via an "Enable Data API" CTA. | After | | --- | | <img width="1664" height="718" alt="CleanShot 2026-07-02 at 21 29 16@2x" src="https://github.com/user-attachments/assets/80d21927-c4dd-4158-8946-bf648b95e451" />| ## Additional context - Gating logic lives in `ConnectStepsSection.utils.ts` with unit tests - Out of scope: warning when Data API is on but zero tables/schemas are exposed - Coexists with the upcoming warehouse branch's catalog warning — that lives in a separate `WarehouseCatalogPanel` for `catalog` mode only <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Connection setup now checks Data API enablement and conditionally shows a “Data API disabled” warning, including an action to open Data API settings. * **Bug Fixes** * Warning logic now more accurately reflects the selected connection mode and chosen feature/tool selections. * **Tests** * Added a focused test suite covering the Data API configuration decision rules and when the warning should appear. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
22 lines
618 B
TypeScript
22 lines
618 B
TypeScript
import { useProjectPostgrestConfigQuery } from '@/data/config/project-postgrest-config-query'
|
|
|
|
/**
|
|
* Returns whether the Data API is enabled for the given project.
|
|
*
|
|
* The Data API is considered enabled when the PostgREST `db_schema` config
|
|
* contains at least one non-empty schema name.
|
|
*/
|
|
export const useIsDataApiEnabled = ({
|
|
projectRef,
|
|
enabled = true,
|
|
}: {
|
|
projectRef?: string
|
|
enabled?: boolean
|
|
}) => {
|
|
const { data: config, ...rest } = useProjectPostgrestConfigQuery({ projectRef }, { enabled })
|
|
|
|
const isEnabled = !!config?.db_schema?.trim()
|
|
|
|
return { ...rest, data: isEnabled, isEnabled }
|
|
}
|