useAvailableConnectModes.ts26 lines · main
| 1 | import { useMemo } from 'react' |
| 2 | |
| 3 | import type { ConnectMode } from './Connect.types' |
| 4 | import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' |
| 5 | |
| 6 | export function useAvailableConnectModes(): ConnectMode[] { |
| 7 | const { |
| 8 | projectConnectionShowAppFrameworks: showAppFrameworks, |
| 9 | projectConnectionShowMobileFrameworks: showMobileFrameworks, |
| 10 | projectConnectionShowOrms: showOrms, |
| 11 | } = useIsFeatureEnabled([ |
| 12 | 'project_connection:show_app_frameworks', |
| 13 | 'project_connection:show_mobile_frameworks', |
| 14 | 'project_connection:show_orms', |
| 15 | ]) |
| 16 | |
| 17 | return useMemo(() => { |
| 18 | const allModes: { id: ConnectMode; enabled: boolean }[] = [ |
| 19 | { id: 'framework', enabled: showAppFrameworks || showMobileFrameworks }, |
| 20 | { id: 'direct', enabled: true }, |
| 21 | { id: 'orm', enabled: showOrms }, |
| 22 | { id: 'mcp', enabled: true }, |
| 23 | ] |
| 24 | return allModes.filter((m) => m.enabled).map((m) => m.id) |
| 25 | }, [showAppFrameworks, showMobileFrameworks, showOrms]) |
| 26 | } |