mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 04:45:08 +03:00
This PR fixes some prettier issues: - Bump and unify all prettier versions to 3.7.3 across teh whole repo - Bump the SQL prettier plugin - When running `test:prettier`, check `mdx` files also - Run the new prettier format on all files --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { IS_PLATFORM } from 'lib/constants'
|
|
import { useMemo } from 'react'
|
|
import { FEATURE_GROUPS_NON_PLATFORM, FEATURE_GROUPS_PLATFORM } from 'ui-patterns/McpUrlBuilder'
|
|
|
|
import { StepContentProps } from './Connect.types'
|
|
|
|
export function useMcpUrl(
|
|
state: StepContentProps['state'],
|
|
projectKeys: StepContentProps['projectKeys']
|
|
): string {
|
|
const readonly = Boolean(state.mcpReadonly)
|
|
const baseUrl = IS_PLATFORM ? 'https://mcp.supabase.com' : (projectKeys.apiUrl ?? '')
|
|
|
|
return useMemo(() => {
|
|
const params = new URLSearchParams()
|
|
if (readonly) params.set('readonly', 'true')
|
|
|
|
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)
|
|
)
|
|
if (validFeatures.length > 0) {
|
|
params.set('features', validFeatures.join(','))
|
|
}
|
|
|
|
const queryString = params.toString()
|
|
return queryString ? `${baseUrl}?${queryString}` : baseUrl
|
|
}, [baseUrl, readonly, state.mcpFeatures])
|
|
}
|