diff --git a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx index 2810405de6b..dff0cfdd0af 100644 --- a/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx +++ b/apps/studio/components/interfaces/Settings/API/ExposedSchemaSelector.tsx @@ -16,6 +16,7 @@ import { } from 'ui' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' +import { getExposedSchemaCounts } from './ExposedSchemaSelector.utils' import { useSchemasQuery } from '@/data/database/schemas-query' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' import { INTERNAL_SCHEMAS } from '@/hooks/useProtectedSchemas' @@ -30,13 +31,17 @@ export const internalSchemasCannotExpose = new Set( ) interface ExposedSchemaSelectorProps { - disabled?: boolean + /** + * When true the dropdown can still be opened to inspect which schemas are exposed (e.g. + * self-hosted, where schemas are managed via PGRST_DB_SCHEMAS), but schemas can't be toggled. + */ + readOnly?: boolean selectedSchemas: string[] onToggleSchema: (schema: string) => void } export const ExposedSchemaSelector = ({ - disabled = false, + readOnly = false, selectedSchemas, onToggleSchema, }: ExposedSchemaSelectorProps) => { @@ -68,14 +73,17 @@ export const ExposedSchemaSelector = ({ ) const selectedSet = useMemo(() => new Set(selectedSchemas), [selectedSchemas]) - const selectedCount = schemas.filter((s) => selectedSet.has(s.name)).length + const { selectedCount, totalCount } = getExposedSchemaCounts({ + visibleSchemas: schemas.map((s) => s.name), + selectedSchemas, + protectedSchemas: internalSchemasCannotExpose, + }) return (