The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): show read replicas moved notice on Replication (#49355)
Danny White417b0fe13eb0
diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsxindex d053473a728..8b7d4dcb9d7 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.test.tsx@@ -60,6 +60,7 @@ const addBackgroundMocks = () => {describe('DestinationTypeSelection', () => {beforeEach(() => {mockInfrastructureReadReplicas.mockReturnValue(true)+ window.localStorage.clear()})test('shows placeholder when no type is selected', async () => {@@ -171,9 +172,9 @@ describe('DestinationTypeSelection', () => {customRender(<DestinationTypeSelection />)expect(await screen.findByText('Read replicas have moved')).toBeInTheDocument()- expect(screen.getByRole('link', { name: 'Add read replica' })).toHaveAttribute(+ expect(screen.getByRole('link', { name: 'Go to Infrastructure' })).toHaveAttribute('href',- expect.stringContaining('/settings/infrastructure?addReplica=true')+ expect.stringContaining('/settings/infrastructure'))})diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsxindex f3e23de6e61..fc042ed1de2 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationTypeSelection.tsx@@ -22,7 +22,6 @@ import {import { DestinationType } from './DestinationPanel.types'import { ReadReplicasMovedCallout } from './ReadReplicasMovedCallout'import { InlineLink } from '@/components/ui/InlineLink'-import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'interface DestinationTypeOption {value: DestinationType@@ -47,7 +46,6 @@ export const DestinationTypeSelection = () => {const etlEnableDucklake = useIsETLDucklakePrivateAlpha()const etlEnableSnowflake = useIsETLSnowflakePrivateAlpha()const etlEnableClickHouse = useIsETLClickHousePrivateAlpha()- const { infrastructureReadReplicas } = useIsFeatureEnabled(['infrastructure:read_replicas'])const [urlDestinationType, setDestinationType] = useQueryState('destinationType',@@ -214,11 +212,7 @@ export const DestinationTypeSelection = () => {</SelectContent></Select></FormItemLayout>- {!editMode && infrastructureReadReplicas && (- <div className="px-5 pb-5">- <ReadReplicasMovedCallout />- </div>- )}+ {!editMode && <ReadReplicasMovedCallout className="px-5 pb-5" />}</>)}diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.test.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.test.tsxnew file mode 100644index 00000000000..9a32598a717--- /dev/null+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.test.tsx@@ -0,0 +1,66 @@+import { screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { LOCAL_STORAGE_KEYS } from 'common'+import { beforeEach, describe, expect, test, vi } from 'vitest'++import { ReadReplicasMovedCallout } from './ReadReplicasMovedCallout'+import { customRender } from '@/tests/lib/custom-render'++const mockInfrastructureReadReplicas = vi.fn(() => true)++vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({+ useIsFeatureEnabled: () => ({+ infrastructureReadReplicas: mockInfrastructureReadReplicas(),+ }),+}))++describe('ReadReplicasMovedCallout', () => {+ beforeEach(() => {+ mockInfrastructureReadReplicas.mockReturnValue(true)+ window.localStorage.clear()+ })++ test('renders the notice with a link to Infrastructure', async () => {+ customRender(<ReadReplicasMovedCallout />)++ expect(await screen.findByText('Read replicas have moved')).toBeInTheDocument()+ expect(screen.getByRole('link', { name: 'Go to Infrastructure' })).toHaveAttribute(+ 'href',+ expect.stringContaining('/settings/infrastructure')+ )+ })++ test('hides after dismiss and persists via localStorage', async () => {+ const user = userEvent.setup()+ customRender(<ReadReplicasMovedCallout />)++ expect(await screen.findByText('Read replicas have moved')).toBeInTheDocument()+ await user.click(screen.getByRole('button', { name: 'Dismiss read replicas moved notice' }))++ expect(screen.queryByText('Read replicas have moved')).not.toBeInTheDocument()+ expect(+ window.localStorage.getItem(+ LOCAL_STORAGE_KEYS.READ_REPLICAS_MOVED_CALLOUT_DISMISSED('default')+ )+ ).toBe('true')+ })++ test('stays hidden when previously dismissed', async () => {+ window.localStorage.setItem(+ LOCAL_STORAGE_KEYS.READ_REPLICAS_MOVED_CALLOUT_DISMISSED('default'),+ 'true'+ )++ customRender(<ReadReplicasMovedCallout />)++ await expect(screen.findByText('Read replicas have moved')).rejects.toThrow()+ })++ test('hides when Infrastructure read replicas are disabled', () => {+ mockInfrastructureReadReplicas.mockReturnValue(false)++ customRender(<ReadReplicasMovedCallout />)++ expect(screen.queryByText('Read replicas have moved')).not.toBeInTheDocument()+ })+})diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.tsxindex 1f61ffdcda7..ff8a6ea561f 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.tsx@@ -1,24 +1,50 @@-import { useParams } from 'common'+import { LOCAL_STORAGE_KEYS, useParams } from 'common'+import { X } from 'lucide-react'import Link from 'next/link'import { Button } from 'ui'import { Admonition } from 'ui-patterns/Admonition'-import { getAddReadReplicaPath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'+import { getInfrastructurePath } from '@/components/interfaces/Settings/Infrastructure/Infrastructure.utils'+import { ButtonTooltip } from '@/components/ui/ButtonTooltip'+import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'+import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'-export const ReadReplicasMovedCallout = () => {+/** Shown while muscle-memory still opens Database → Replication for replicas. */+export const ReadReplicasMovedCallout = ({ className }: { className?: string }) => {const { ref: projectRef } = useParams()+ const { infrastructureReadReplicas } = useIsFeatureEnabled(['infrastructure:read_replicas'])+ const [isDismissed, setIsDismissed, { isSuccess: isDismissalLoaded }] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.READ_REPLICAS_MOVED_CALLOUT_DISMISSED(projectRef ?? 'unknown'),+ false+ )++ if (!projectRef || !infrastructureReadReplicas || !isDismissalLoaded || isDismissed) {+ return null+ }return (- <Admonition- type="note"- layout="responsive"- title="Read replicas have moved"- description="Read replicas are now managed on the Infrastructure page, alongside compute and disk."- actions={- <Button asChild variant="default" size="tiny">- <Link href={getAddReadReplicaPath(projectRef)}>Add read replica</Link>- </Button>- }- />+ <div className={className}>+ <Admonition+ type="note"+ layout="responsive"+ title="Read replicas have moved"+ description="Manage read replicas on the Infrastructure page, alongside compute and disk."+ actions={+ <>+ <Button asChild variant="default" size="tiny">+ <Link href={getInfrastructurePath(projectRef)}>Go to Infrastructure</Link>+ </Button>+ <ButtonTooltip+ icon={<X />}+ variant="text"+ className="w-6"+ tooltip={{ content: { side: 'bottom', text: 'Dismiss' } }}+ aria-label="Dismiss read replicas moved notice"+ onClick={() => setIsDismissed(true)}+ />+ </>+ }+ />+ </div>)}diff --git a/apps/studio/pages/project/[ref]/database/replication/index.tsx b/apps/studio/pages/project/[ref]/database/replication/index.tsxindex 462c3c49ae5..296fcd4f3e2 100644--- a/apps/studio/pages/project/[ref]/database/replication/index.tsx+++ b/apps/studio/pages/project/[ref]/database/replication/index.tsx@@ -9,6 +9,7 @@ import {import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'+import { ReadReplicasMovedCallout } from '@/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout'import { Destinations } from '@/components/interfaces/Database/Replication/Destinations'import { ReplicationDiagram } from '@/components/interfaces/Database/Replication/ReplicationDiagram'import DatabaseLayout from '@/components/layouts/DatabaseLayout/DatabaseLayout'@@ -58,6 +59,7 @@ const DatabaseReplicationPage: NextPageWithLayout = () => {) : (<PageSection><PageSectionContent className="flex flex-col gap-12">+ <ReadReplicasMovedCallout /><ReplicationDiagram /><Destinations /></PageSectionContent>diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.tsindex 70bffe0cdf5..8a8ce0312eb 100644--- a/packages/common/constants/local-storage.ts+++ b/packages/common/constants/local-storage.ts@@ -104,6 +104,10 @@ export const LOCAL_STORAGE_KEYS = {// RLS event trigger banner dismissedRLS_EVENT_TRIGGER_BANNER_DISMISSED: (ref: string) => `rls-event-trigger-banner-dismissed-${ref}`,+ // Read replicas moved from Replication → Infrastructure+ READ_REPLICAS_MOVED_CALLOUT_DISMISSED: (ref: string) =>+ `read-replicas-moved-callout-dismissed-${ref}`,+PROJECT_SECURITY_DISMISSED_AT: (ref: string) => `project-security-dismissed-at-${ref}`,DATABASE_CONNECTIONS_BANNER_DISMISSED: (ref: string) =>