mirror of
https://github.com/supabase/supabase.git
synced 2026-05-19 19:37:22 +08:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { useParams } from 'common'
|
|
import { useMemo } from 'react'
|
|
import {
|
|
FEATURE_GROUPS_NON_PLATFORM,
|
|
FEATURE_GROUPS_PLATFORM,
|
|
getMcpUrl,
|
|
} from 'ui-patterns/McpUrlBuilder'
|
|
|
|
import { StepContentProps } from './Connect.types'
|
|
import { IS_PLATFORM } from '@/lib/constants'
|
|
|
|
export function useMcpUrl(
|
|
state: StepContentProps['state'],
|
|
projectKeys: StepContentProps['projectKeys']
|
|
): string {
|
|
const { ref: projectRef } = useParams()
|
|
const readonly = Boolean(state.mcpReadonly)
|
|
|
|
return useMemo(() => {
|
|
const selectedFeatures = Array.isArray(state.mcpFeatures) ? state.mcpFeatures : []
|
|
const supportedFeatures = IS_PLATFORM ? FEATURE_GROUPS_PLATFORM : FEATURE_GROUPS_NON_PLATFORM
|
|
const validFeatures = selectedFeatures.filter((f) =>
|
|
supportedFeatures.some((group) => group.id === f)
|
|
)
|
|
|
|
return getMcpUrl({
|
|
projectRef,
|
|
isPlatform: IS_PLATFORM,
|
|
apiUrl: projectKeys.apiUrl ?? undefined,
|
|
readonly,
|
|
features: validFeatures,
|
|
}).mcpUrl
|
|
}, [projectKeys.apiUrl, projectRef, readonly, state.mcpFeatures])
|
|
}
|