mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 23:29:08 +03:00
* add new page * moar * moar * added icons * improve icons * moved connect dialog to main header * update text * smaller screen support * moar * add python and sqlalchemyString * moar * add IPv4 warning * moar * Delete pooler-icons-v2.tsx * tidy * Delete DatabaseSettings.tsx * tidy * tidy * moar. Session pooler is de-prioritized * Update DatabaseConnectionString.tsx * type issue * moar * Update DatabaseConnectionString.tsx * Spelling * Clean up LayoutHeader * Clean up ConnectionPanel * Clean up ConnectionParameters * Last batch of clean up * Fix loading state padding * Shift old Connect files to new Connect folder outside of Home * Final clean up * Smol fix * FIX * Fix button link * Fixes * Lint --------- Co-authored-by: Terry Sutton <saltcod@gmail.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
81 lines
2.9 KiB
TypeScript
81 lines
2.9 KiB
TypeScript
import dynamic from 'next/dynamic'
|
|
import { forwardRef, HTMLAttributes, useMemo } from 'react'
|
|
|
|
import { useParams } from 'common'
|
|
import { getConnectionStrings } from 'components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.utils'
|
|
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
|
|
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
|
|
import { usePoolingConfigurationQuery } from 'data/database/pooling-configuration-query'
|
|
import { pluckObjectFields } from 'lib/helpers'
|
|
import { cn } from 'ui'
|
|
import type { projectKeys } from './Connect.types'
|
|
|
|
interface ConnectContentTabProps extends HTMLAttributes<HTMLDivElement> {
|
|
projectKeys: projectKeys
|
|
filePath: string
|
|
connectionStringPooler?: {
|
|
transaction: string
|
|
session: string
|
|
}
|
|
connectionStringDirect?: string
|
|
}
|
|
|
|
const ConnectTabContentNew = forwardRef<HTMLDivElement, ConnectContentTabProps>(
|
|
({ projectKeys, filePath, ...props }, ref) => {
|
|
const { ref: projectRef } = useParams()
|
|
|
|
const { data: settings } = useProjectSettingsV2Query({ projectRef })
|
|
const { data: poolingInfo } = usePoolingConfigurationQuery({ projectRef })
|
|
|
|
const DB_FIELDS = ['db_host', 'db_name', 'db_port', 'db_user', 'inserted_at']
|
|
const emptyState = { db_user: '', db_host: '', db_port: '', db_name: '' }
|
|
const connectionInfo = pluckObjectFields(settings || emptyState, DB_FIELDS)
|
|
const poolingConfiguration = poolingInfo?.find((x) => x.database_type === 'PRIMARY')
|
|
|
|
const connectionStringsPooler =
|
|
poolingConfiguration !== undefined
|
|
? getConnectionStrings(connectionInfo, poolingConfiguration, {
|
|
projectRef,
|
|
usePoolerConnection: true,
|
|
})
|
|
: { uri: '' }
|
|
const connectionStringsDirect =
|
|
poolingConfiguration !== undefined
|
|
? getConnectionStrings(connectionInfo, poolingConfiguration, {
|
|
projectRef,
|
|
usePoolerConnection: false,
|
|
})
|
|
: { uri: '' }
|
|
const connectionStringPoolerTransaction = connectionStringsPooler.uri
|
|
const connectionStringPoolerSession = connectionStringsPooler.uri.replace('6543', '5432')
|
|
|
|
const ContentFile = useMemo(() => {
|
|
return dynamic<ConnectContentTabProps>(() => import(`./content/${filePath}/content`), {
|
|
loading: () => (
|
|
<div className="p-4 min-h-[331px]">
|
|
<GenericSkeletonLoader />
|
|
</div>
|
|
),
|
|
})
|
|
}, [filePath])
|
|
|
|
return (
|
|
<div ref={ref} {...props} className={cn('border rounded-lg', props.className)}>
|
|
<ContentFile
|
|
projectKeys={projectKeys}
|
|
filePath={filePath}
|
|
connectionStringPooler={{
|
|
transaction: connectionStringPoolerTransaction,
|
|
session: connectionStringPoolerSession,
|
|
}}
|
|
connectionStringDirect={connectionStringsDirect.uri}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
)
|
|
|
|
ConnectTabContentNew.displayName = 'ConnectTabContentNew'
|
|
|
|
export default ConnectTabContentNew
|