Files
Alaister YoungandAlaister Young 0fe2366659 [FE-3790] fix(studio): hide Multigres from user-facing surfaces (#48191)
Hides the "Multigres" term from user-facing surfaces — it's the tech
powering High Availability projects, but "High Availability" is the only
term users should see for now (per Slack discussion with Saxon/Ivan).

**Changed:**
- High Availability badge hover card (project overview) no longer says
"Driven by Multigres"
- Project creation HA toggle description drops the Multigres name +
multigres.com link, keeps the informational copy
- All schema dropdowns now hide the `multigres` schema on HA projects,
by wiring in the previously-unused `filterSchemasForHighAvailability`
helper:
- `SchemaSelector` (shared — Table Editor, Functions, Indexes, Triggers,
Schema Visualizer, etc.)
  - `ExposedSchemaSelector` (API settings → exposed schemas)
- `EnableExtensionModal`, `CreateIndexSidePanel`, `ForeignKeySelector`,
`WrapperTableEditor`, Integrations install sheet `AdvancedSettings`
  - SQL editor schema autocomplete (`useAddDefinitions`)
- Schema list computations in the touched components are now memoized
(incl. stabilizing `SchemaSelector`'s `excludedSchemas` default so the
memo actually holds)

**Added:**
- Unit tests for `filterSchemasForHighAvailability` /
`resolveHighAvailability`
- MSW component test for `SchemaSelector` asserting `multigres` is
hidden on HA projects and still shown on non-HA projects

The filter is HA-gated on purpose: a self-hosted/non-HA user with their
own schema named `multigres` still sees it. The flag-gated Multigres
option in Logs is intentionally untouched — that exposure is kept for
the Multigres team's debugging (separate track).

## To test

- On an HA project (`high_availability: true`): hover the High
Availability badge on project overview — no "Multigres" mention; open
schema dropdowns in Table Editor / Database pages / SQL editor
autocomplete — no `multigres` schema
- Project creation with HA entitlement: toggle description has no
Multigres wording/link
- On a non-HA project: schema dropdowns behave as before

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Improvements**
* Made schema dropdowns and related selectors high-availability aware
across extensions, indexes, integrations, SQL editing, API exposed
schemas, and relationship editors.
* Updated project high-availability UI text and badge hover description
to remove outdated branding and clarify horizontally scalable Postgres
architecture.
* **Tests**
* Added coverage to ensure the schema “multigres” option is hidden/shown
correctly based on high availability, and validated high-availability
value handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-07-23 00:08:11 +08:00

177 lines
7.1 KiB
TypeScript

import { useMemo, type Dispatch, type SetStateAction } from 'react'
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
Badge,
Select,
SelectContent,
SelectItem,
SelectSeparator,
SelectTrigger,
SelectValue,
SheetSection,
} from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { getExtensionDefaultSchema } from '../IntegrationOverviewTabV2.utils'
import { type ExtensionsSchema, type InstallIntegrationSheetProps } from './InstallIntegrationSheet'
import { extensionsWithRecommendedSchemas } from '@/components/interfaces/Database/Extensions/Extensions.constants'
import { useDatabaseExtensionsQuery } from '@/data/database-extensions/database-extensions-query'
import { useSchemasQuery } from '@/data/database/schemas-query'
import { useSchemasFilteredForHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useProtectedSchemas } from '@/hooks/useProtectedSchemas'
type AdvancedSettingsProps = InstallIntegrationSheetProps & {
extensionsSchema: ExtensionsSchema
setExtensionsSchema: Dispatch<SetStateAction<ExtensionsSchema>>
}
export const AdvancedSettings = ({
integration,
extensionsSchema,
setExtensionsSchema,
}: AdvancedSettingsProps) => {
const { data: project } = useSelectedProjectQuery()
const { data: protectedSchemas } = useProtectedSchemas({ excludeSchemas: ['extensions'] })
const { requiredExtensions: requiredExtensionNames } = integration
const involvesExtensions = requiredExtensionNames.length > 0
const { data: extensions = [] } = useDatabaseExtensionsQuery(
{ projectRef: project?.ref, connectionString: project?.connectionString },
{ enabled: involvesExtensions }
)
const { data: schemas = [] } = useSchemasQuery(
{ projectRef: project?.ref, connectionString: project?.connectionString },
{ enabled: involvesExtensions }
)
const visibleSchemas = useSchemasFilteredForHighAvailability(schemas)
const availableSchemas = useMemo(
() =>
visibleSchemas.filter(
(schema) =>
!protectedSchemas.some((protectedSchema) => protectedSchema.name === schema.name)
),
[visibleSchemas, protectedSchemas]
)
return (
<SheetSection>
<Accordion type="single" collapsible>
<AccordionItem value="advanced-settings" className="border-none">
<AccordionTrigger className="font-normal gap-2 py-0 justify-between text-sm hover:no-underline">
Advanced settings
</AccordionTrigger>
<AccordionContent className="pb-0! pt-3 [&>div]:flex [&>div]:flex-col [&>div]:gap-y-4">
<p className="text-foreground-light">
Select which schemas to install the database extensions under
</p>
{requiredExtensionNames.map((extName) => {
const ext = extensions.find((x) => x.name === extName)
const extMeta = extensionsSchema[extName]
const { schema, value } = extMeta
const recommendedSchema = extensionsWithRecommendedSchemas[extName]
const defaultSchema = getExtensionDefaultSchema(ext)
return (
<FormItemLayout
key={extName}
isReactForm={false}
layout="horizontal"
label={extName}
description={
ext?.installed_version ? (
<>
Installed in <code className="text-code-inline">{ext.schema}</code> schema
</>
) : defaultSchema ? (
<>
Must be installed in the{' '}
<code className="text-code-inline">{defaultSchema}</code> schema
</>
) : recommendedSchema ? (
<>
Use the <code className="text-code-inline">{recommendedSchema}</code> schema
for full compatibility with related features
</>
) : undefined
}
>
<Select
disabled={!!defaultSchema || !!ext?.installed_version}
value={schema}
onValueChange={(schema) =>
setExtensionsSchema((prev) => ({
...prev,
[extName]: {
schema,
value: schema === 'custom' ? extName : undefined,
},
}))
}
>
<SelectTrigger>
<SelectValue placeholder="Select a schema" />
</SelectTrigger>
<SelectContent>
<SelectItem value="custom">Create a new schema</SelectItem>
<SelectSeparator />
{availableSchemas.map((schema) => {
return (
<SelectItem key={schema.id} value={schema.name}>
{schema.name}
{schema.name === recommendedSchema ? (
<Badge className="ml-2" variant="success">
Recommended
</Badge>
) : schema.name === 'extensions' ? (
<Badge className="ml-2">Default</Badge>
) : null}
</SelectItem>
)
})}
{defaultSchema &&
!availableSchemas.some((schema) => schema.name === defaultSchema) ? (
<SelectItem key={defaultSchema} value={defaultSchema}>
{defaultSchema}
<Badge className="ml-2">Default</Badge>
</SelectItem>
) : null}
</SelectContent>
</Select>
{schema === 'custom' && (
<FormItemLayout
isReactForm={false}
className="mt-2"
label="Provide a name for your new schema"
>
<Input
value={value}
onChange={(e) =>
setExtensionsSchema((prev) => ({
...prev,
[extName]: {
schema: prev[extName].schema,
value: e.target.value,
},
}))
}
placeholder="Provide a name for your schema"
/>
</FormItemLayout>
)}
</FormItemLayout>
)
})}
</AccordionContent>
</AccordionItem>
</Accordion>
</SheetSection>
)
}