mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 12:55:06 +03:00
## What kind of change does this PR introduce? Chore ## What is the current behavior? - We use the MCP client connect dialog in two places: Studio and Docs - We duplicate image assets for each client in each of those two places ## What is the new behavior? - Centralised assets - Consolidation and simplification as a result of it all being a single source-of-truth now ## To test - [ ] Everything works as it did before across both Studio and [Docs](https://supabase.com/docs/guides/getting-started/mcp) - [ ] All MCP client images load as expected
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { IS_PLATFORM, useParams } from 'common'
|
|
import Panel from 'components/ui/Panel'
|
|
import { useTrack } from 'lib/telemetry/track'
|
|
import { useTheme } from 'next-themes'
|
|
import { useMemo, useState } from 'react'
|
|
import { createMcpCopyHandler, McpConfigPanel, type McpClient } from 'ui-patterns/McpUrlBuilder'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
import type { projectKeys } from './Connect.types'
|
|
|
|
export const McpTabContent = ({ projectKeys }: { projectKeys: projectKeys }) => {
|
|
const { ref: projectRef } = useParams()
|
|
|
|
return (
|
|
<Panel className="bg-inherit border-none shadow-none">
|
|
{projectRef ? (
|
|
<McpTabContentInnerLoaded projectRef={projectRef} projectKeys={projectKeys} />
|
|
) : (
|
|
<McpTabContentInnerLoading />
|
|
)}
|
|
</Panel>
|
|
)
|
|
}
|
|
|
|
const McpTabContentInnerLoading = () => {
|
|
return (
|
|
<div className="flex flex-col gap-2">
|
|
<ShimmeringLoader className="w-3/4" />
|
|
<ShimmeringLoader className="w-1/2" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const McpTabContentInnerLoaded = ({
|
|
projectRef,
|
|
projectKeys,
|
|
}: {
|
|
projectRef: string
|
|
projectKeys: projectKeys
|
|
}) => {
|
|
const { resolvedTheme } = useTheme()
|
|
const track = useTrack()
|
|
const [selectedClient, setSelectedClient] = useState<McpClient | null>(null)
|
|
|
|
const handleCopy = useMemo(
|
|
() =>
|
|
createMcpCopyHandler({
|
|
selectedClient,
|
|
source: 'studio',
|
|
onTrack: (event) => track(event.action, event.properties, event.groups),
|
|
projectRef,
|
|
}),
|
|
[selectedClient, track, projectRef]
|
|
)
|
|
|
|
const handleInstall = () => {
|
|
if (selectedClient?.label) {
|
|
track('mcp_install_button_clicked', {
|
|
client: selectedClient.label,
|
|
source: 'studio',
|
|
})
|
|
}
|
|
}
|
|
|
|
return (
|
|
<McpConfigPanel
|
|
projectRef={projectRef}
|
|
theme={resolvedTheme as 'light' | 'dark'}
|
|
isPlatform={IS_PLATFORM}
|
|
apiUrl={projectKeys.apiUrl ?? undefined}
|
|
onCopyCallback={handleCopy}
|
|
onInstallCallback={handleInstall}
|
|
onClientSelect={setSelectedClient}
|
|
/>
|
|
)
|
|
}
|