Skip to content

Commit fcfe5c8

Browse files
authored
Merge branch 'main' into dat-567
2 parents 66a09c1 + f08bad0 commit fcfe5c8

File tree

12 files changed

+58
-31
lines changed

12 files changed

+58
-31
lines changed

e2e/journeys/upgrade-free-tier.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ test('upgrade - free tier', async ({ page }) => {
1111
await page.waitForURL(/\/organization-[^/]+\/change-plan/);
1212
await page.locator('input[value="tier-1"]').click();
1313
await page.getByRole('button', { name: 'add' }).first().click();
14+
1415
await enterCreditCard(page);
16+
17+
// wait for a second after adding a card to update the UI.
18+
await page.waitForSelector('button#method[role="combobox"]');
19+
1520
// skip members
1621
await page.getByRole('button', { name: 'change plan' }).click();
1722
await page.waitForURL(/\/console\/project-(?:[a-z0-9]+-)?([^/]+)\/get-started/);

src/lib/components/billing/paymentModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
try {
2222
const card = await submitStripeCard(name, page?.params?.organization ?? null);
2323
modal.closeModal();
24-
invalidate(Dependencies.PAYMENT_METHODS);
24+
await invalidate(Dependencies.PAYMENT_METHODS);
2525
dispatch('submit', card);
2626
addNotification({
2727
type: 'success',

src/lib/components/billing/selectPaymentMethod.svelte

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@
2020
2121
async function cardSaved(event: CustomEvent<PaymentMethodData>) {
2222
value = event.detail.$id;
23-
invalidate(Dependencies.UPGRADE_PLAN);
24-
invalidate(Dependencies.CREATE_ORGANIZATION);
23+
24+
if (value) {
25+
methods = {
26+
...methods,
27+
total: methods.total + 1,
28+
paymentMethods: [...methods.paymentMethods, event.detail]
29+
};
30+
}
31+
32+
await Promise.all([
33+
invalidate(Dependencies.UPGRADE_PLAN),
34+
invalidate(Dependencies.ORGANIZATION)
35+
]);
2536
}
2637
2738
onMount(() => {

src/lib/components/breadcrumbs.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
102102
async function createProjectsBottomSheet(organization: Organization): Promise<SheetMenu> {
103103
isLoadingProjects = true;
104-
loadedProjects = await projects;
104+
// null on non-org/project path like `onboarding`.
105+
loadedProjects = (await projects) ?? loadedProjects;
105106
isLoadingProjects = false;
106107
107108
const createProjectItem = {

src/lib/layout/wizard.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@
5050
if (confirmExit) {
5151
showExitModal = true;
5252
} else {
53-
goto(href);
53+
goBack();
5454
trackEvent('wizard_exit', {
5555
from: 'escape'
5656
});
5757
}
5858
}
5959
}
6060
61+
const goBack = () => goto(href);
62+
6163
onMount(() => ($isNewWizardStatusOpen = true));
6264
6365
onDestroy(() => ($isNewWizardStatusOpen = false));
@@ -77,7 +79,7 @@
7779
if (confirmExit) {
7880
showExitModal = true;
7981
} else {
80-
goto(href);
82+
goBack();
8183
trackEvent('wizard_exit', {
8284
from: 'button'
8385
});

src/routes/(console)/+layout.svelte

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,19 @@
316316
317317
$: checkForUsageLimits($organization);
318318
319-
$: projects = sdk.forConsole.projects.list([
320-
Query.equal(
321-
'teamId',
322-
// id from page params ?? id from store ?? id from preferences
323-
page.params.organization ?? currentOrganizationId ?? data.currentOrgId
324-
),
325-
Query.limit(5),
326-
Query.orderDesc('$updatedAt')
327-
]);
319+
$: isOnOnboarding = page.route?.id?.includes('/(console)/onboarding');
320+
321+
$: projects = isOnOnboarding
322+
? null
323+
: sdk.forConsole.projects.list([
324+
Query.equal(
325+
'teamId',
326+
// id from page params ?? id from store ?? id from preferences
327+
page.params.organization ?? currentOrganizationId ?? data.currentOrgId
328+
),
329+
Query.limit(5),
330+
Query.orderDesc('$updatedAt')
331+
]);
328332
329333
$: if ($requestedMigration) {
330334
openMigrationWizard();

src/routes/(console)/create-organization/+page.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import type { Coupon } from '$lib/sdk/billing';
55
import type { Organization } from '$lib/stores/organization';
66

77
export const load: PageLoad = async ({ url, parent, depends }) => {
8-
depends(Dependencies.CREATE_ORGANIZATION);
98
const { organizations } = await parent();
9+
depends(Dependencies.CREATE_ORGANIZATION);
10+
1011
const [coupon, paymentMethods] = await Promise.all([
1112
getCoupon(url),
1213
sdk.forConsole.billing.listPaymentMethods()

src/routes/(console)/onboarding/create-organization/+page.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import { isCloud } from '$lib/system';
33
import { sdk } from '$lib/stores/sdk';
44
import { ID } from '@appwrite.io/console';
5-
import { BillingPlan } from '$lib/constants';
5+
import { BillingPlan, Dependencies } from '$lib/constants';
66
import { tierToPlan } from '$lib/stores/billing';
77
import { addNotification } from '$lib/stores/notifications';
88
import { loadAvailableRegions } from '$routes/(console)/regions';
99
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
1010
import { Button, Card, Layout, Input, Typography, Spinner } from '@appwrite.io/pink-svelte';
1111
import { Form } from '$lib/elements/forms/index.js';
12-
import { goto } from '$app/navigation';
12+
import { goto, invalidate } from '$app/navigation';
1313
import { base } from '$app/paths';
1414
1515
let isLoading = false;
@@ -47,6 +47,10 @@
4747
if (organization) {
4848
loadAvailableRegions(organization?.$id).then();
4949
await goto(`${base}/organization-${organization.$id}`);
50+
51+
// fixes an edge case where
52+
// the org is not available for some reason!
53+
await invalidate(Dependencies.CREATE_ORGANIZATION);
5054
}
5155
isLoading = false;
5256
}

src/routes/(console)/organization-[organization]/change-plan/+page.svelte

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,7 @@
271271
<title>Change plan - Appwrite</title>
272272
</svelte:head>
273273

274-
<Wizard
275-
title="Change plan"
276-
href={`${base}/organization-${page.params.organization}`}
277-
bind:showExitModal
278-
confirmExit>
274+
<Wizard title="Change plan" href={previousPage} bind:showExitModal confirmExit>
279275
<Form bind:this={formComponent} onSubmit={handleSubmit} bind:isSubmitting>
280276
<Layout.Stack gap="xxl">
281277
<Fieldset legend="Select plan">
@@ -338,12 +334,12 @@
338334
</Layout.Stack>
339335
</Layout.Stack>
340336
</Fieldset>
341-
{:then paymentMethods}
337+
{:then}
342338
<Fieldset legend="Payment">
343339
<SelectPaymentMethod
344-
methods={paymentMethods}
340+
bind:taxId
345341
bind:value={paymentMethodId}
346-
bind:taxId>
342+
bind:methods={paymentMethods}>
347343
<svelte:fragment slot="actions">
348344
{#if !selectedCoupon?.code}
349345
{#if paymentMethodId}

src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</Button>
5353
</Layout.Stack>
5454
</div>
55-
<Paginator items={members.memberships} hideFooter={members?.total <= 5}>
55+
<Paginator items={members?.memberships} hideFooter={members?.total <= 5}>
5656
{#snippet children(paginatedItems: typeof members.memberships)}
5757
<Table.Root columns={2} let:root>
5858
<svelte:fragment slot="header" let:root>

0 commit comments

Comments
 (0)