Skip to content

Commit 2a76074

Browse files
Merge pull request #1771 from appwrite/svelte5-migration
Refactor: `$page` usage to `page`
2 parents 3dd67d6 + f21a62d commit 2a76074

File tree

312 files changed

+998
-1008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+998
-1008
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "node build.js",
1010
"preview": "vite preview",
1111
"prepare": "svelte-kit sync || echo ''",
12+
"clean": "rm -rf node_modules && rm -rf .svelte_kit && pnpm i --force",
1213
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1314
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
1415
"format": "prettier --write .",

src/lib/actions/analytics.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Analytics, { type AnalyticsPlugin } from 'analytics';
22
import Plausible from 'plausible-tracker';
33
import { get } from 'svelte/store';
4-
import { page } from '$app/stores';
4+
import { page } from '$app/state';
55
import { user } from '$lib/stores/user';
66
import { ENV, MODE, VARS, isCloud } from '$lib/system';
77
import { AppwriteException } from '@appwrite.io/console';
@@ -55,13 +55,12 @@ export function trackEvent(name: string, data: object = null): void {
5555
return;
5656
}
5757

58-
const currentPage = get(page);
59-
const path = currentPage.route.id;
58+
const path = page.route.id;
6059

61-
if (currentPage.params?.project) {
60+
if (page.params?.project) {
6261
data = {
6362
...data,
64-
project: currentPage.params.project
63+
project: page.params.project
6564
};
6665
}
6766

src/lib/commandCenter/panels/ai.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,15 @@
164164

165165
{#if !$preferences.hideAiDisclaimer}
166166
<div style="padding: 1rem; padding-block-end: 0;">
167-
<Alert
168-
type="default"
167+
<Alert.Inline
169168
dismissible
170169
on:dismiss={() => {
171170
$preferences.hideAiDisclaimer = true;
172171
}}>
173172
<span slot="title">
174173
We collect user responses to refine our experimental AI feature.
175174
</span>
176-
</Alert>
175+
</Alert.Inline>
177176
</div>
178177
{/if}
179178

src/lib/components/backupDatabaseAlert.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { page } from '$app/stores';
2+
import { page } from '$app/state';
33
import { BillingPlan } from '$lib/constants';
44
import { Button } from '$lib/elements/forms';
55
import { organization } from '$lib/stores/organization';
@@ -17,15 +17,15 @@
1717
}
1818
</script>
1919

20-
{#if $showPolicyAlert && isCloud && $organization?.$id && $page.url.pathname.match(/\/databases\/database-[^/]+$/)}
20+
{#if $showPolicyAlert && isCloud && $organization?.$id && page.url.pathname.match(/\/databases\/database-[^/]+$/)}
2121
{@const isFreePlan = $organization?.billingPlan === BillingPlan.FREE}
2222

2323
{@const subtitle = isFreePlan
2424
? 'Upgrade your plan to ensure your data stays safe and backed up'
2525
: 'Protect your data by quickly adding a backup policy'}
2626

2727
{@const ctaText = isFreePlan ? 'Upgrade plan' : 'Create policy'}
28-
{@const ctaURL = isFreePlan ? $upgradeURL : `${$page.url.pathname}/backups`}
28+
{@const ctaURL = isFreePlan ? $upgradeURL : `${page.url.pathname}/backups`}
2929

3030
<HeaderAlert type="warning" title="Your database has no backup policy">
3131
<svelte:fragment>{subtitle}</svelte:fragment>

src/lib/components/backupRestoreBox.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { BillingPlan, Dependencies } from '$lib/constants';
88
import type { BackupArchive, BackupRestoration } from '$lib/sdk/backups';
99
import { goto, invalidate } from '$app/navigation';
10-
import { page } from '$app/stores';
10+
import { page } from '$app/state';
1111
import { addNotification } from '$lib/stores/notifications';
1212
import { base } from '$app/paths';
1313
import { getProjectId } from '$lib/helpers/project';
@@ -34,7 +34,7 @@
3434
3535
function showRestoreNotification(newDatabaseId: string, newDatabaseName: string) {
3636
if (newDatabaseId && newDatabaseName && lastDatabaseRestorationId !== newDatabaseId) {
37-
const project = $page.params.project;
37+
const project = page.params.project;
3838
lastDatabaseRestorationId = newDatabaseId;
3939
4040
addNotification({

src/lib/components/billing/alerts/limitReached.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { base } from '$app/paths';
3-
import { page } from '$app/stores';
3+
import { page } from '$app/state';
44
import { Click, trackEvent } from '$lib/actions/analytics';
55
import { BillingPlan } from '$lib/constants';
66
import { Button } from '$lib/elements/forms';
@@ -9,7 +9,7 @@
99
import { organization } from '$lib/stores/organization';
1010
</script>
1111

12-
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
12+
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes(page.url.pathname)}
1313
<HeaderAlert
1414
type="error"
1515
title={`${$organization.name} usage has reached the ${tierToPlan($organization.billingPlan).name} plan limit`}>

src/lib/components/billing/alerts/markedForDeletion.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts">
2-
import { page } from '$app/stores';
2+
import { page } from '$app/state';
33
import { HeaderAlert } from '$lib/layout';
44
import { hideBillingHeaderRoutes } from '$lib/stores/billing';
55
import { organization } from '$lib/stores/organization';
66
</script>
77

8-
{#if $organization?.markedForDeletion && !hideBillingHeaderRoutes.includes($page.url.pathname)}
8+
{#if $organization?.markedForDeletion && !hideBillingHeaderRoutes.includes(page.url.pathname)}
99
<HeaderAlert title="Organization flagged for deletion">
1010
<svelte:fragment>
1111
All existing projects in the {$organization.name} organization have been paused. This organization

src/lib/components/billing/alerts/missingPaymentMethod.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<script lang="ts">
22
import { base } from '$app/paths';
3-
import { page } from '$app/stores';
3+
import { page } from '$app/state';
44
import { BillingPlan } from '$lib/constants';
55
import { Button } from '$lib/elements/forms';
66
import { HeaderAlert } from '$lib/layout';
77
import { hideBillingHeaderRoutes } from '$lib/stores/billing';
88
import { orgMissingPaymentMethod } from '$routes/(console)/store';
99
</script>
1010

11-
{#if ($orgMissingPaymentMethod.billingPlan === BillingPlan.PRO || $orgMissingPaymentMethod.billingPlan === BillingPlan.SCALE) && !$orgMissingPaymentMethod.paymentMethodId && !$orgMissingPaymentMethod.backupPaymentMethodId && !hideBillingHeaderRoutes.includes($page.url.pathname)}
11+
{#if ($orgMissingPaymentMethod.billingPlan === BillingPlan.PRO || $orgMissingPaymentMethod.billingPlan === BillingPlan.SCALE) && !$orgMissingPaymentMethod.paymentMethodId && !$orgMissingPaymentMethod.backupPaymentMethodId && !hideBillingHeaderRoutes.includes(page.url.pathname)}
1212
<HeaderAlert
1313
type="error"
1414
title={`Payment method required for ${$orgMissingPaymentMethod.name}`}>

src/lib/components/billing/alerts/newDevUpgradePro.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { base } from '$app/paths';
3-
import { page } from '$app/stores';
3+
import { page } from '$app/state';
44
import { Click, trackEvent } from '$lib/actions/analytics';
55
import { BillingPlan } from '$lib/constants';
66
import { Button } from '$lib/elements/forms';
@@ -21,7 +21,7 @@
2121
}
2222
</script>
2323

24-
{#if show && $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && !$page.url.pathname.includes('/console/account')}
24+
{#if show && $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && !page.url.pathname.includes('/console/account')}
2525
<GradientBanner on:close={handleClose}>
2626
<div class="u-flex u-gap-24 u-main-center u-cross-center u-flex-vertical-mobile">
2727
<span class="body-text-1">Get $50 Cloud credits for Appwrite Pro.</span>

src/lib/components/billing/alerts/paymentAuthRequired.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { base } from '$app/paths';
3-
import { page } from '$app/stores';
3+
import { page } from '$app/state';
44
import { Button } from '$lib/elements/forms';
55
import { HeaderAlert } from '$lib/layout';
66
import { actionRequiredInvoices, hideBillingHeaderRoutes } from '$lib/stores/billing';
@@ -9,7 +9,7 @@
99
const endpoint = getApiEndpoint();
1010
</script>
1111

12-
{#if $actionRequiredInvoices && $actionRequiredInvoices?.invoices?.length && !hideBillingHeaderRoutes.includes($page.url.pathname)}
12+
{#if $actionRequiredInvoices && $actionRequiredInvoices?.invoices?.length && !hideBillingHeaderRoutes.includes(page.url.pathname)}
1313
<HeaderAlert title="Authorization required" type="error">
1414
Please authorize your upcoming payment for {$organization.name}. Your bank requires this
1515
security measure to proceed with payment.

0 commit comments

Comments
 (0)