|
18 | 18 | import Info from '@lucide/svelte/icons/info'; |
19 | 19 | import * as Alert from '$lib/components/ui/alert/index.js'; |
20 | 20 | import posthog from 'posthog-js'; |
| 21 | + import { preferencesStore } from '$lib/stores.js'; |
21 | 22 |
|
22 | 23 | // let query = $state(useQuery(api.backups.get, { jwt: '' })); |
23 | 24 | // const client = useConvexClient(); |
|
40 | 41 | } |
41 | 42 | </script> |
42 | 43 |
|
43 | | -<div class="mx-auto flex w-full max-w-3xl flex-col gap-3 p-3"> |
44 | | - <h1 class="text-3xl">Backups</h1> |
45 | | - <AlertDialog.Root open={loading} |
46 | | - ><AlertDialog.Content class="flex flex-row gap-3"> |
47 | | - <LoaderCircle class="animate-spin" /> |
48 | | - Loading |
49 | | - </AlertDialog.Content> |
50 | | - </AlertDialog.Root> |
| 44 | +{#if $preferencesStore.experimentalFeatures} |
| 45 | + <div class="mx-auto flex w-full max-w-3xl flex-col gap-3 p-3"> |
| 46 | + <h1 class="text-3xl">Backups</h1> |
| 47 | + <AlertDialog.Root open={loading} |
| 48 | + ><AlertDialog.Content class="flex flex-row gap-3"> |
| 49 | + <LoaderCircle class="animate-spin" /> |
| 50 | + Loading |
| 51 | + </AlertDialog.Content> |
| 52 | + </AlertDialog.Root> |
51 | 53 |
|
52 | | - <Card.Root> |
53 | | - <Card.Header><Card.Title>Local Backup</Card.Title></Card.Header> |
54 | | - <Card.Content class="flex flex-col gap-3"> |
55 | | - Export |
56 | | - <div class="flex flex-row gap-3"> |
57 | | - <Input disabled={true} value={backupData} /> |
58 | | - <Button |
59 | | - size="icon" |
60 | | - onclick={() => { |
61 | | - posthog.capture('backup', { type: 'copy', location: 'local' }); |
62 | | - navigator.clipboard |
63 | | - .writeText(backupData) |
64 | | - .then(() => { |
65 | | - toast.success('Backup copied to clipboard'); |
66 | | - }) |
67 | | - .catch((error) => { |
68 | | - toast.error('Failed to copy backup to clipboard'); |
69 | | - }); |
70 | | - }}><Clipboard /></Button |
71 | | - > |
72 | | - </div> |
73 | | - Import |
74 | | - <div class="flex flex-row gap-3"> |
75 | | - <Input bind:value={inputtedBackupData} /> |
76 | | - <Button |
77 | | - disabled={inputtedBackupData.length === 0} |
78 | | - onclick={() => { |
79 | | - posthog.capture('backup', { type: 'import', location: 'local' }); |
80 | | - loading = true; |
81 | | - restoreBackup(inputtedBackupData); |
82 | | - }}>Import</Button |
83 | | - > |
84 | | - </div> |
85 | | - </Card.Content> |
86 | | - </Card.Root> |
| 54 | + <Card.Root> |
| 55 | + <Card.Header><Card.Title>Local Backup</Card.Title></Card.Header> |
| 56 | + <Card.Content class="flex flex-col gap-3"> |
| 57 | + Export |
| 58 | + <div class="flex flex-row gap-3"> |
| 59 | + <Input disabled={true} value={backupData} /> |
| 60 | + <Button |
| 61 | + size="icon" |
| 62 | + onclick={() => { |
| 63 | + posthog.capture('backup', { type: 'copy', location: 'local' }); |
| 64 | + navigator.clipboard |
| 65 | + .writeText(backupData) |
| 66 | + .then(() => { |
| 67 | + toast.success('Backup copied to clipboard'); |
| 68 | + }) |
| 69 | + .catch((error) => { |
| 70 | + toast.error('Failed to copy backup to clipboard'); |
| 71 | + }); |
| 72 | + }}><Clipboard /></Button |
| 73 | + > |
| 74 | + </div> |
| 75 | + Import |
| 76 | + <div class="flex flex-row gap-3"> |
| 77 | + <Input bind:value={inputtedBackupData} /> |
| 78 | + <Button |
| 79 | + disabled={inputtedBackupData.length === 0} |
| 80 | + onclick={() => { |
| 81 | + posthog.capture('backup', { type: 'import', location: 'local' }); |
| 82 | + loading = true; |
| 83 | + restoreBackup(inputtedBackupData); |
| 84 | + }}>Import</Button |
| 85 | + > |
| 86 | + </div> |
| 87 | + </Card.Content> |
| 88 | + </Card.Root> |
87 | 89 |
|
88 | | - <!-- <SignedIn> |
| 90 | + <!-- <SignedIn> |
89 | 91 | <div class="grid w-full grid-cols-1 gap-3 md:grid-cols-2"> |
90 | 92 | <Card.Root> |
91 | 93 | <Card.Header><Card.Title>Create a Backup</Card.Title></Card.Header> |
|
137 | 139 | ></Alert.Root |
138 | 140 | > |
139 | 141 | </SignedOut> --> |
140 | | -</div> |
| 142 | + </div> |
| 143 | +{:else} |
| 144 | + <div class="flex h-full flex-col items-center justify-center gap-3"> |
| 145 | + <span class="text-6xl">404</span> |
| 146 | + <span class="text-3xl">Not Found</span> |
| 147 | + <Button variant="outline" href="/">Go home</Button> |
| 148 | + </div> |
| 149 | +{/if} |
0 commit comments