Skip to content

Commit 03bdaf9

Browse files
authored
Merge pull request #161 from supabase-community/feat/remove-legacy-domain
feat: remove references to legacy domain
2 parents 060c1e6 + 69b61e5 commit 03bdaf9

File tree

10 files changed

+37
-416
lines changed

10 files changed

+37
-416
lines changed

apps/web/.env.example

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ KV_REST_API_TOKEN="local_token"
1818
SUPABASE_OAUTH_SECRET="<supabase-oauth-secret>"
1919
SUPABASE_SERVICE_ROLE_KEY="<supabase-service-role-key>"
2020

21-
NEXT_PUBLIC_LEGACY_DOMAIN=https://postgres.new
22-
NEXT_PUBLIC_CURRENT_DOMAIN=https://database.build
23-
REDIRECT_LEGACY_DOMAIN=false
24-
2521
# Optional
2622
#LOGFLARE_SOURCE="<logflare-source>"
2723
#LOGFLARE_API_KEY="<logflare-api-key>"

apps/web/app/export/page.tsx

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,25 @@ import { chunk } from 'lodash'
55
import Link from 'next/link'
66
import { useState } from 'react'
77
import { useApp } from '~/components/app-provider'
8-
import {
9-
Accordion,
10-
AccordionContent,
11-
AccordionItem,
12-
AccordionTrigger,
13-
} from '~/components/ui/accordion'
148
import { Button } from '~/components/ui/button'
159
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '~/components/ui/dialog'
1610
import { Progress } from '~/components/ui/progress'
1711
import { DbManager } from '~/lib/db'
1812
import { countFiles, listFiles } from '~/lib/files'
13+
import { useOrigin } from '~/lib/hooks'
1914
import {
2015
fileFromStream,
2116
fileToTarStreamFile,
2217
mergeIterables,
2318
readableStreamFromIterable,
2419
transformStreamFromFn,
2520
} from '~/lib/streams'
26-
import {
27-
currentDomainHostname,
28-
currentDomainUrl,
29-
downloadFile,
30-
legacyDomainHostname,
31-
} from '~/lib/util'
21+
import { downloadFile } from '~/lib/util'
3222

3323
export default function Page() {
3424
const { dbManager } = useApp()
3525
const [progress, setProgress] = useState<number>()
26+
const origin = useOrigin()
3627

3728
return (
3829
<>
@@ -42,61 +33,15 @@ export default function Page() {
4233
<DialogTitle>Export your databases</DialogTitle>
4334
<div className="py-2 border-b" />
4435
</DialogHeader>
36+
<p>All databases live locally within your browser&apos;s local IndexedDB storage.</p>
4537
<p>
46-
{legacyDomainHostname} is renaming to {currentDomainHostname}, which means you need to
47-
transfer your databases if you wish to continue using them.
38+
You can backup and restore your databases in order to transfer them between browsers or
39+
devices.
4840
</p>
4941

50-
<Accordion type="single" collapsible>
51-
<AccordionItem value="item-1" className="border rounded-md">
52-
<AccordionTrigger className="p-0 gap-2 px-3 py-2">
53-
<div className="flex gap-2 items-center font-normal text-lighter text-sm">
54-
<span>
55-
Why is {legacyDomainHostname} renaming to {currentDomainHostname}?
56-
</span>
57-
</div>
58-
</AccordionTrigger>
59-
<AccordionContent className="p-3 prose prose-sm">
60-
This project is not an official Postgres project and we don&apos;t want to mislead
61-
anyone! We&apos;re renaming to{' '}
62-
<Link href={currentDomainUrl} className="underline">
63-
{currentDomainHostname}
64-
</Link>{' '}
65-
because, well, that&apos;s what this does. This will still be 100% Postgres-focused,
66-
just with a different URL.
67-
</AccordionContent>
68-
</AccordionItem>
69-
</Accordion>
70-
<Accordion type="single" collapsible>
71-
<AccordionItem value="item-1" className="border rounded-md">
72-
<AccordionTrigger className="p-0 gap-2 px-3 py-2">
73-
<div className="flex gap-2 items-center font-normal text-lighter text-sm">
74-
<span>Why do I need to export my databases?</span>
75-
</div>
76-
</AccordionTrigger>
77-
<AccordionContent className="p-3 prose prose-sm">
78-
<p>
79-
Since PGlite databases are stored in your browser&apos;s IndexedDB storage, other
80-
domains like{' '}
81-
<Link href={currentDomainUrl} className="underline">
82-
{currentDomainHostname}
83-
</Link>{' '}
84-
cannot access them directly (this is a security restriction built into every
85-
browser).
86-
</p>
87-
<p>
88-
If you&apos;d like to continue using your previous databases and conversations:
89-
<ol>
90-
<li>Export them from {legacyDomainHostname}</li>
91-
<li>Import them to {currentDomainHostname}</li>
92-
</ol>
93-
</p>
94-
</AccordionContent>
95-
</AccordionItem>
96-
</Accordion>
9742
<div className="my-2 border-b" />
9843
<div className="prose">
99-
<h4 className="mb-4">How to transfer your databases to {currentDomainHostname}</h4>
44+
<h4 className="mb-4">How to export and import your databases</h4>
10045
<ol>
10146
<li>
10247
Click <strong>Export</strong> to download all of your databases into a single
@@ -158,12 +103,11 @@ export default function Page() {
158103
)}
159104
<br />
160105
This tarball will contain every PGlite database&apos;s <code>pgdata</code> dump
161-
along with any files you imported or exported from {legacyDomainHostname}.
106+
along with any files that you imported or exported in your chats.
162107
</li>
163108
<li>
164-
Navigate to{' '}
165-
<Link href={`${currentDomainUrl}/import`}>{currentDomainHostname}/import</Link> and
166-
click <strong>Import</strong>.
109+
Navigate to <Link href="/import">{origin ?? ''}/import</Link> and click{' '}
110+
<strong>Import</strong>.
167111
</li>
168112
</ol>
169113
</div>

apps/web/app/import/page.tsx

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
import { UntarStream } from '@std/tar/untar-stream'
44
import { useState } from 'react'
55
import { useApp } from '~/components/app-provider'
6-
import {
7-
Accordion,
8-
AccordionContent,
9-
AccordionItem,
10-
AccordionTrigger,
11-
} from '~/components/ui/accordion'
126
import { Button } from '~/components/ui/button'
137
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '~/components/ui/dialog'
148
import { Progress } from '~/components/ui/progress'
@@ -20,21 +14,16 @@ import { useRouter } from 'next/navigation'
2014
import { getDatabasesQueryKey } from '~/data/databases/databases-query'
2115
import { DbManager } from '~/lib/db'
2216
import { hasFile, saveFile } from '~/lib/files'
17+
import { useOrigin } from '~/lib/hooks'
2318
import { tarStreamEntryToFile, waitForChunk } from '~/lib/streams'
24-
import {
25-
currentDomainHostname,
26-
currentDomainUrl,
27-
legacyDomainHostname,
28-
legacyDomainUrl,
29-
requestFileUpload,
30-
stripSuffix,
31-
} from '~/lib/util'
19+
import { requestFileUpload, stripSuffix } from '~/lib/util'
3220

3321
export default function Page() {
3422
const { dbManager } = useApp()
3523
const router = useRouter()
3624
const queryClient = useQueryClient()
3725
const [progress, setProgress] = useState<number>()
26+
const origin = useOrigin()
3827

3928
return (
4029
<>
@@ -47,66 +36,19 @@ export default function Page() {
4736
<DialogTitle>Import your databases</DialogTitle>
4837
<div className="py-2 border-b" />
4938
</DialogHeader>
39+
<p>All databases live locally within your browser&apos;s local IndexedDB storage.</p>
5040
<p>
51-
{legacyDomainHostname} is renaming to {currentDomainHostname}, which means you need to
52-
transfer your databases if you wish to continue using them.
41+
You can backup and restore your databases in order to transfer them between browsers or
42+
devices.
5343
</p>
5444

55-
<Accordion type="single" collapsible>
56-
<AccordionItem value="item-1" className="border rounded-md">
57-
<AccordionTrigger className="p-0 gap-2 px-3 py-2">
58-
<div className="flex gap-2 items-center font-normal text-lighter text-sm">
59-
<span>
60-
Why is {legacyDomainHostname} renaming to {currentDomainHostname}?
61-
</span>
62-
</div>
63-
</AccordionTrigger>
64-
<AccordionContent className="p-3 prose prose-sm">
65-
This project is not an official Postgres project and we don&apos;t want to mislead
66-
anyone! We&apos;re renaming to{' '}
67-
<Link href={currentDomainUrl} className="underline">
68-
{currentDomainHostname}
69-
</Link>{' '}
70-
because, well, that&apos;s what this does. This will still be 100% Postgres-focused,
71-
just with a different URL.
72-
</AccordionContent>
73-
</AccordionItem>
74-
</Accordion>
75-
<Accordion type="single" collapsible>
76-
<AccordionItem value="item-1" className="border rounded-md">
77-
<AccordionTrigger className="p-0 gap-2 px-3 py-2">
78-
<div className="flex gap-2 items-center font-normal text-lighter text-sm">
79-
<span>Why do I need to import my databases?</span>
80-
</div>
81-
</AccordionTrigger>
82-
<AccordionContent className="p-3 prose prose-sm">
83-
<p>
84-
Since PGlite databases are stored in your browser&apos;s IndexedDB storage,{' '}
85-
<Link href={currentDomainUrl} className="underline">
86-
{currentDomainHostname}
87-
</Link>{' '}
88-
cannot access them directly (this is a security restriction built into every
89-
browser).
90-
</p>
91-
<p>
92-
If you&apos;d like to continue using your previous databases and conversations:
93-
<ol>
94-
<li>Export them from {legacyDomainHostname}</li>
95-
<li>Import them to {currentDomainHostname}</li>
96-
</ol>
97-
</p>
98-
</AccordionContent>
99-
</AccordionItem>
100-
</Accordion>
10145
<div className="my-2 border-b" />
10246
<div className="prose">
103-
<h4 className="mb-4">How to transfer your databases to {currentDomainHostname}</h4>
47+
<h4 className="mb-4">How to export and import your databases</h4>
10448
<ol>
10549
<li>
106-
Navigate to{' '}
107-
<Link href={`${legacyDomainUrl}/export`}>{legacyDomainHostname}/export</Link> and
108-
click <strong>Export</strong> to download all of your databases into a single
109-
tarball.
50+
Navigate to <Link href="/export">{origin ?? ''}/export</Link> and click{' '}
51+
<strong>Export</strong> to download all of your databases into a single tarball.
11052
</li>
11153
<li>
11254
Click <strong>Import</strong> and select the previously exported tarball.

apps/web/components/app-provider.tsx

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
parseReadyForQuery,
3030
parseStartupMessage,
3131
} from '~/lib/pg-wire-util'
32-
import { legacyDomainHostname } from '~/lib/util'
3332
import { parse, serialize } from '~/lib/websocket-protocol'
3433
import { createClient } from '~/utils/supabase/client'
3534
import { useModelProvider } from './model-provider/use-model-provider'
@@ -43,7 +42,6 @@ export default function AppProvider({ children }: AppProps) {
4342
const [isLoadingUser, setIsLoadingUser] = useState(true)
4443
const [user, setUser] = useState<User>()
4544
const [isSignInDialogOpen, setIsSignInDialogOpen] = useState(false)
46-
const [isRenameDialogOpen, setIsRenameDialogOpen] = useState(false)
4745
const [isRateLimited, setIsRateLimited] = useState(false)
4846
const [showSidebar, setShowSidebar] = useState(false)
4947

@@ -259,23 +257,10 @@ export default function AppProvider({ children }: AppProps) {
259257
clientIp: connectedClientIp,
260258
isLiveSharing: Boolean(liveSharedDatabaseId),
261259
}
262-
const [isLegacyDomain, setIsLegacyDomain] = useState(false)
263-
const [isLegacyDomainRedirect, setIsLegacyDomainRedirect] = useState(false)
264260

265261
const [modelProviderError, setModelProviderError] = useState<string>()
266262
const [isModelProviderDialogOpen, setIsModelProviderDialogOpen] = useState(false)
267263

268-
useEffect(() => {
269-
const isLegacyDomain = window.location.hostname === legacyDomainHostname
270-
const urlParams = new URLSearchParams(window.location.search)
271-
const isLegacyDomainRedirect = urlParams.get('from') === legacyDomainHostname
272-
273-
// Set via useEffect() to prevent SSR hydration issues
274-
setIsLegacyDomain(isLegacyDomain)
275-
setIsLegacyDomainRedirect(isLegacyDomainRedirect)
276-
setIsRenameDialogOpen(isLegacyDomain || isLegacyDomainRedirect)
277-
}, [])
278-
279264
const modelProvider = useModelProvider()
280265

281266
return (
@@ -291,8 +276,6 @@ export default function AppProvider({ children }: AppProps) {
291276
signOut,
292277
isSignInDialogOpen,
293278
setIsSignInDialogOpen,
294-
isRenameDialogOpen,
295-
setIsRenameDialogOpen,
296279
isRateLimited,
297280
setIsRateLimited,
298281
isModelProviderDialogOpen,
@@ -301,8 +284,6 @@ export default function AppProvider({ children }: AppProps) {
301284
dbManager,
302285
pgliteVersion,
303286
pgVersion,
304-
isLegacyDomain,
305-
isLegacyDomainRedirect,
306287
showSidebar,
307288
setShowSidebar,
308289
}}
@@ -323,8 +304,6 @@ export type AppContextValues = {
323304
signOut: () => Promise<void>
324305
isSignInDialogOpen: boolean
325306
setIsSignInDialogOpen: (open: boolean) => void
326-
isRenameDialogOpen: boolean
327-
setIsRenameDialogOpen: (open: boolean) => void
328307
isRateLimited: boolean
329308
setIsRateLimited: (limited: boolean) => void
330309
isModelProviderDialogOpen: boolean
@@ -343,8 +322,6 @@ export type AppContextValues = {
343322
modelProvider: ReturnType<typeof useModelProvider>
344323
modelProviderError?: string
345324
setModelProviderError: (error: string | undefined) => void
346-
isLegacyDomain: boolean
347-
isLegacyDomainRedirect: boolean
348325
showSidebar: boolean
349326
setShowSidebar: (show: boolean) => void
350327
}

0 commit comments

Comments
 (0)