Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Chore/read replica fixes 290524 (#26852)

Joshen Lim578a0291f323
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
index 2a74810645e..7b7618332b3 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
@@ -1,9 +1,10 @@
-import { useParams } from 'common'
import dayjs from 'dayjs'
+import { capitalize } from 'lodash'
+import { BarChart2, ExternalLink } from 'lucide-react'
import Link from 'next/link'
import { Fragment, useMemo, useState } from 'react'
-import { IconBarChart2, IconExternalLink } from 'ui'
+import { useParams } from 'common'
import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'
import {
CPUWarnings,
@@ -19,6 +20,7 @@ import {
ScaffoldSectionDetail,
} from 'components/layouts/Scaffold'
import DateRangePicker from 'components/to-be-cleaned/DateRangePicker'
+import DatabaseSelector from 'components/ui/DatabaseSelector'
import Panel from 'components/ui/Panel'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { DataPoint } from 'data/analytics/constants'
@@ -27,16 +29,17 @@ import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-que
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'
import { useSelectedOrganization, useSelectedProject } from 'hooks'
+import { INSTANCE_MICRO_SPECS, INSTANCE_NANO_SPECS } from 'lib/constants'
import { TIME_PERIODS_BILLING, TIME_PERIODS_REPORTS } from 'lib/constants/metrics'
+import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import { INFRA_ACTIVITY_METRICS } from './Infrastructure.constants'
-import { capitalize } from 'lodash'
-import { INSTANCE_MICRO_SPECS, INSTANCE_NANO_SPECS } from 'lib/constants'
const InfrastructureActivity = () => {
const { ref: projectRef } = useParams()
+ const project = useSelectedProject()
const organization = useSelectedOrganization()
+ const state = useDatabaseSelectorStateSnapshot()
const [dateRange, setDateRange] = useState<any>()
- const project = useSelectedProject()
const { data: subscription, isLoading: isLoadingSubscription } = useOrgSubscriptionQuery({
orgSlug: organization?.slug,
@@ -130,6 +133,7 @@ const InfrastructureActivity = () => {
startDate,
endDate,
dateFormat,
+ databaseIdentifier: state.selectedDatabaseId,
})
const { data: memoryUsageData, isLoading: isLoadingMemoryUsageData } = useInfraMonitoringQuery({
@@ -139,6 +143,7 @@ const InfrastructureActivity = () => {
startDate,
endDate,
dateFormat,
+ databaseIdentifier: state.selectedDatabaseId,
})
const { data: ioBudgetData, isLoading: isLoadingIoBudgetData } = useInfraMonitoringQuery({
@@ -148,6 +153,7 @@ const InfrastructureActivity = () => {
startDate,
endDate,
dateFormat,
+ databaseIdentifier: state.selectedDatabaseId,
})
const hasLatest = dayjs(endDate!).isAfter(dayjs().startOf('day'))
@@ -190,8 +196,7 @@ const InfrastructureActivity = () => {
</ScaffoldContainer>
<ScaffoldContainer className="sticky top-0 py-6 border-b bg-studio z-10">
<div className="flex items-center gap-x-4">
- {/* [Joshen] Metrics for replicas not available yet */}
- {/* {readReplicasEnabled && <DatabaseSelector />} */}
+ <DatabaseSelector />
{!isLoadingSubscription && (
<>
<DateRangePicker
@@ -238,7 +243,7 @@ const InfrastructureActivity = () => {
<Link href={link.url} target="_blank" rel="noreferrer">
<div className="flex items-center space-x-2 opacity-50 hover:opacity-100 transition">
<p className="text-sm m-0">{link.name}</p>
- <IconExternalLink size={16} strokeWidth={1.5} />
+ <ExternalLink size={16} strokeWidth={1.5} />
</div>
</Link>
</div>
@@ -388,7 +393,7 @@ const InfrastructureActivity = () => {
<Panel>
<Panel.Content>
<div className="flex flex-col items-center justify-center space-y-2">
- <IconBarChart2 className="text-foreground-light mb-2" />
+ <BarChart2 size={18} className="text-foreground-light mb-2" />
<p className="text-sm">No data in period</p>
<p className="text-sm text-foreground-light">
May take a few minutes to show
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
index 382901b251f..303078683f1 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx
@@ -176,6 +176,27 @@ const DeployNewReplicaPanel = ({
</div>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
+ ) : currentPgVersion < 15 ? (
+ <Alert_Shadcn_>
+ <WarningIcon />
+ <AlertTitle_Shadcn_>
+ Read replicas can only be deployed with projects on Postgres version 15 and above
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ If you'd like to use read replicas, please contact us via support
+ </AlertDescription_Shadcn_>
+ <AlertDescription_Shadcn_ className="mt-2">
+ <Button type="default">
+ <Link
+ href={`/support/new?category=Sales&ref=${projectRef}&subject=Enquiry%20on%20read%20replicas&message=Project%20DB%20version:%20${project?.dbVersion}`}
+ target="_blank"
+ rel="noreferrer"
+ >
+ Contact support
+ </Link>
+ </Button>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
) : (
<>
{!isWalgEnabled && (
@@ -270,29 +291,6 @@ const DeployNewReplicaPanel = ({
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)}
-
- {currentPgVersion < 15 && (
- <Alert_Shadcn_>
- <WarningIcon />
- <AlertTitle_Shadcn_>
- Read replicas can only be deployed with projects on Postgres version 15 and above
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- If you'd like to use read replicas, please contact us via support
- </AlertDescription_Shadcn_>
- <AlertDescription_Shadcn_ className="mt-2">
- <Button type="default">
- <Link
- href={`/support/new?category=Sales&ref=${projectRef}&subject=Enquiry%20on%20read%20replicas&message=Project%20DB%20version:%20${project?.dbVersion}`}
- target="_blank"
- rel="noreferrer"
- >
- Contact support
- </Link>
- </Button>
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
</>
)}