settings.tsx87 lines · main
| 1 | import { PageContainer } from 'ui-patterns/PageContainer' |
| 2 | import { |
| 3 | PageHeader, |
| 4 | PageHeaderDescription, |
| 5 | PageHeaderMeta, |
| 6 | PageHeaderSummary, |
| 7 | PageHeaderTitle, |
| 8 | } from 'ui-patterns/PageHeader' |
| 9 | import { PageSection, PageSectionContent } from 'ui-patterns/PageSection' |
| 10 | |
| 11 | import { useIsJitDbAccessEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext' |
| 12 | import { DiskManagementPanelForm } from '@/components/interfaces/DiskManagement/DiskManagementPanelForm' |
| 13 | import { BannedIPs } from '@/components/interfaces/Settings/Database/BannedIPs' |
| 14 | import { ConnectionPooling } from '@/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling' |
| 15 | import { DatabaseReadOnlyAlert } from '@/components/interfaces/Settings/Database/DatabaseReadOnlyAlert' |
| 16 | import ResetDbPassword from '@/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword' |
| 17 | import { DiskSizeConfiguration } from '@/components/interfaces/Settings/Database/DiskSizeConfiguration' |
| 18 | import { JitDbAccessConfiguration } from '@/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccessConfiguration' |
| 19 | import { NetworkRestrictions } from '@/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions' |
| 20 | import { PoolingModesModal } from '@/components/interfaces/Settings/Database/PoolingModesModal' |
| 21 | import { SettingsDatabaseEmptyStateLocal } from '@/components/interfaces/Settings/Database/SettingsDatabaseEmptyStateLocal' |
| 22 | import { SSLConfiguration } from '@/components/interfaces/Settings/Database/SSLConfiguration' |
| 23 | import DatabaseLayout from '@/components/layouts/DatabaseLayout/DatabaseLayout' |
| 24 | import DefaultLayout from '@/components/layouts/DefaultLayout' |
| 25 | import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' |
| 26 | import { useIsAwsCloudProvider, useIsAwsK8sCloudProvider } from '@/hooks/misc/useSelectedProject' |
| 27 | import { IS_PLATFORM } from '@/lib/constants' |
| 28 | import type { NextPageWithLayout } from '@/types' |
| 29 | |
| 30 | const DatabaseSettings: NextPageWithLayout = () => { |
| 31 | const isAws = useIsAwsCloudProvider() |
| 32 | const isAwsK8s = useIsAwsK8sCloudProvider() |
| 33 | const jitDbAccessEnabled = useIsJitDbAccessEnabled() |
| 34 | const showNewDiskManagementUI = isAws || isAwsK8s |
| 35 | const { databaseNetworkRestrictions } = useIsFeatureEnabled(['database:network_restrictions']) |
| 36 | |
| 37 | return ( |
| 38 | <> |
| 39 | <PageHeader size="small"> |
| 40 | <PageHeaderMeta> |
| 41 | <PageHeaderSummary> |
| 42 | <PageHeaderTitle>Database Settings</PageHeaderTitle> |
| 43 | <PageHeaderDescription> |
| 44 | Connections, security, and network configuration |
| 45 | </PageHeaderDescription> |
| 46 | </PageHeaderSummary> |
| 47 | </PageHeaderMeta> |
| 48 | </PageHeader> |
| 49 | {IS_PLATFORM ? ( |
| 50 | <> |
| 51 | <PageContainer size="small" className="flex flex-col gap-8 pb-12"> |
| 52 | <DatabaseReadOnlyAlert /> |
| 53 | <ResetDbPassword /> |
| 54 | {jitDbAccessEnabled && <JitDbAccessConfiguration />} |
| 55 | <ConnectionPooling /> |
| 56 | <SSLConfiguration /> |
| 57 | {showNewDiskManagementUI ? ( |
| 58 | // This form is hidden if Disk and Compute form is enabled, new form is on ./settings/compute-and-disk |
| 59 | <DiskManagementPanelForm /> |
| 60 | ) : ( |
| 61 | <DiskSizeConfiguration /> |
| 62 | )} |
| 63 | {databaseNetworkRestrictions && <NetworkRestrictions />} |
| 64 | <BannedIPs /> |
| 65 | </PageContainer> |
| 66 | <PoolingModesModal /> |
| 67 | </> |
| 68 | ) : ( |
| 69 | <PageContainer size="small" className="pb-12"> |
| 70 | <PageSection> |
| 71 | <PageSectionContent className="space-y-4 md:space-y-8"> |
| 72 | <SettingsDatabaseEmptyStateLocal /> |
| 73 | </PageSectionContent> |
| 74 | </PageSection> |
| 75 | </PageContainer> |
| 76 | )} |
| 77 | </> |
| 78 | ) |
| 79 | } |
| 80 | |
| 81 | DatabaseSettings.getLayout = (page) => ( |
| 82 | <DefaultLayout> |
| 83 | <DatabaseLayout title="Settings">{page}</DatabaseLayout> |
| 84 | </DefaultLayout> |
| 85 | ) |
| 86 | |
| 87 | export default DatabaseSettings |