Skip to content

Commit 7f80d2d

Browse files
authored
Merge pull request #1898 from appwrite/fix-regions
Re-add: available regions filtering on project creations
2 parents 70608a0 + c4fc0ea commit 7f80d2d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/lib/layout/createProject.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
label: region.name,
2929
value: region.$id,
3030
leadingHtml: `<img src='${getFlagUrl(region.flag)}' alt='Region flag'/>`,
31-
disabled: region.disabled
31+
disabled: region.disabled || !region.available
3232
};
3333
});
3434
}
@@ -39,6 +39,7 @@
3939
<link rel="preload" as="image" href={getFlagUrl(region.flag)} />
4040
{/each}
4141
</svelte:head>
42+
4243
<form on:submit|preventDefault>
4344
<Layout.Stack direction="column" gap="xxl">
4445
{#if showTitle}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import { base } from '$app/paths';
1111
import { addNotification } from '$lib/stores/notifications';
1212
import CreateProject from '$lib/layout/createProject.svelte';
13+
import { loadAvailableRegions } from '$routes/(console)/regions';
14+
import { regions as regionsStore } from '$lib/stores/organization';
1315
1416
let isLoading = false;
1517
let id: string;
@@ -49,6 +51,9 @@
4951
});
5052
}
5153
}
54+
55+
// safe side!
56+
loadAvailableRegions(data.organization.$id);
5257
</script>
5358

5459
<svelte:head>
@@ -74,7 +79,7 @@
7479
alt="Appwrite Logo" />
7580
<Card.Base variant="primary" padding="l">
7681
<CreateProject
77-
regions={isCloud ? data.regions.regions : []}
82+
regions={$regionsStore.regions}
7883
bind:projectName
7984
bind:id
8085
bind:region

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import { BillingPlan } from '$lib/constants';
88
import { redirect } from '@sveltejs/kit';
99
import { base } from '$app/paths';
1010

11+
// TODO: this needs to be cleaned up!
1112
export const load: PageLoad = async ({ parent }) => {
1213
const { organizations } = await parent();
14+
1315
try {
1416
if (!organizations?.total) {
1517
try {
@@ -29,8 +31,7 @@ export const load: PageLoad = async ({ parent }) => {
2931

3032
if (isOrganization(org)) {
3133
return {
32-
organization: org,
33-
regions: await sdk.forConsole.billing.listRegions(org.$id)
34+
organization: org
3435
};
3536
} else {
3637
const e = new Error(org.message, {
@@ -43,8 +44,7 @@ export const load: PageLoad = async ({ parent }) => {
4344
organization: await sdk.forConsole.teams.create(
4445
ID.unique(),
4546
'Personal projects'
46-
),
47-
regions: null
47+
)
4848
};
4949
}
5050
} catch (e) {
@@ -57,10 +57,8 @@ export const load: PageLoad = async ({ parent }) => {
5757
Query.limit(1)
5858
]);
5959
if (!projects.total) {
60-
const regions = isCloud ? await sdk.forConsole.billing.listRegions(org.$id) : null;
6160
return {
62-
organization: org,
63-
regions
61+
organization: org
6462
};
6563
} else {
6664
redirect(303, `${base}/console/organization-${org.$id}`);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@
120120
});
121121
122122
function findRegion(project: Models.Project) {
123-
return $regionsStore?.regions?.find(
124-
(region) => region.$id === (project as Models.Project & { region: string }).region
125-
);
123+
return $regionsStore?.regions?.find((region) => region.$id === project.region);
126124
}
127125
</script>
128126

0 commit comments

Comments
 (0)