Files
Danny White 9be9e570c3 feat(studio): adopt shared inline code defaults (#51981)
## Problem

Studio relies on repeated classes to style inline code. Bare `<code>`
elements can miss those styles.

## Solution

Import the shared styles from #51980 and remove the repeated classes.
Keep Markdown renderer behaviour and existing size overrides. Use
`data-code-style="plain"` for webhook headers, CLI and upgrade commands,
configuration comparisons and connected-resource labels that have their
own layout.

## Review instructions

Dashboard review: this PR changes Studio only.

1. Open [Database >
Extensions](https://studio-staging-git-dnywh-depr-707-code-studio-supabase.vercel.app/dashboard/project/_/database/extensions).
Search for `pg_trgm` or another disabled extension and turn on its
toggle to open the Enable dialog. Check the Extension and Schema values
and the help text under “Install in a different schema”. The SQL block
should keep its highlighting and copy control. Close without installing.
2. Open [Edge Functions >
Secrets](https://studio-staging-git-dnywh-depr-707-code-studio-supabase.vercel.app/dashboard/project/_/functions/secrets).
Scroll to “Default secrets” and check `SUPABASE_URL` and
`SUPABASE_DB_URL`: both should use the bordered inline-code style. Hover
a name to see “Click to copy”, then click it and confirm the name is
copied. No custom secret or deployed function is needed.
3. Compare light and dark themes at narrow and desktop widths.

| Before | After |
| --- | --- |
| <img width="812" height="1066" alt="CleanShot 2026-10-19 at 15 35
10@2x"
src="https://github.com/user-attachments/assets/e4a21310-1fac-4143-9ee6-d2452ab4f314"
/> | <img width="812" height="1068" alt="CleanShot 2026-10-20 at 15 39
20@2x"
src="https://github.com/user-attachments/assets/d2c91ef6-7836-4c71-8f15-d0c0df8e969d"
/> |
2026-10-22 00:48:56 +00:00

176 lines
7.0 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 className="px-0">
<Accordion type="single" collapsible>
<AccordionItem value="advanced-settings" className="border-none">
<AccordionTrigger className="font-normal gap-2 px-5 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 [&>div]:px-5">
<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>{ext.schema}</code> schema
</>
) : defaultSchema ? (
<>
Must be installed in the <code>{defaultSchema}</code> schema
</>
) : recommendedSchema ? (
<>
Use the <code>{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>
)
}