Skip to content

Commit c09e82d

Browse files
authored
Merge pull request #2650 from appwrite/fix-filtering
2 parents 7a00fac + 71cad9b commit c09e82d

File tree

10 files changed

+37
-31
lines changed

10 files changed

+37
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@ai-sdk/svelte": "^1.1.24",
25-
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@acef319",
25+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@406d8be",
2626
"@appwrite.io/pink-icons": "0.25.0",
2727
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@6916470",
2828
"@appwrite.io/pink-legacy": "^1.0.3",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/stores/billing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type {
2424
} from '$lib/sdk/billing';
2525
import { isCloud } from '$lib/system';
2626
import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store';
27-
import { AppwriteException, Query } from '@appwrite.io/console';
27+
import { AppwriteException, Query, Platform } from '@appwrite.io/console';
2828
import { derived, get, writable } from 'svelte/store';
2929
import { headerAlert } from './headerAlert';
3030
import { addNotification, notifications } from './notifications';
@@ -558,7 +558,7 @@ export async function checkForMissingPaymentMethod() {
558558
Query.notEqual('billingPlan', BillingPlan.FREE),
559559
Query.isNull('paymentMethodId'),
560560
Query.isNull('backupPaymentMethodId'),
561-
Query.equal('platform', 'appwrite')
561+
Query.equal('platform', Platform.Appwrite)
562562
]);
563563
if (orgs?.total) {
564564
orgMissingPaymentMethod.set(orgs.teams[0]);

src/routes/(console)/account/organizations/+page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Query } from '@appwrite.io/console';
1+
import { Query, Platform } from '@appwrite.io/console';
22
import { sdk } from '$lib/stores/sdk';
33
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
44
import { CARD_LIMIT } from '$lib/constants';
@@ -14,7 +14,7 @@ export const load: PageLoad = async ({ url, route }) => {
1414
Query.offset(offset),
1515
Query.limit(limit),
1616
Query.orderDesc(''),
17-
Query.equal('platform', 'appwrite')
17+
Query.equal('platform', Platform.Appwrite)
1818
];
1919

2020
const organizations = !isCloud

src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/+page.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Dependencies } from '$lib/constants';
22
import { sdk } from '$lib/stores/sdk';
33
import { isCloud } from '$lib/system';
4-
import { Query } from '@appwrite.io/console';
4+
import { Query, Platform } from '@appwrite.io/console';
55

66
export const load = async ({ parent, depends }) => {
77
depends(Dependencies.DOMAINS);
88

99
const organizations = !isCloud
1010
? await sdk.forConsole.teams.list()
11-
: await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')]);
11+
: await sdk.forConsole.billing.listOrganization([
12+
Query.equal('platform', Platform.Appwrite)
13+
]);
1214

1315
const { domain } = await parent();
1416
return {

src/routes/(console)/project-[region]-[project]/+layout.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,29 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
2323
(org) => org.$id === project.teamId
2424
);
2525

26-
const includedInBasePlans = plansInfo.has(organization.billingPlan);
26+
// organization can be null if not in the filtered list!
27+
const includedInBasePlans = plansInfo.has(organization?.billingPlan);
2728

28-
const [org, regionalConsoleVariables, rolesResult, organizationPlan] = await Promise.all([
29+
const [org, regionalConsoleVariables, rolesResult] = await Promise.all([
2930
!organization
3031
? (sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise<Organization>)
3132
: organization,
3233
sdk.forConsoleIn(project.region).console.variables(),
3334
isCloud ? sdk.forConsole.billing.getRoles(project.teamId) : null,
3435

35-
// fetch if not available in `plansInfo`
36-
includedInBasePlans
37-
? plansInfo.get(organization.billingPlan)
38-
: isCloud
39-
? sdk.forConsole.billing.getOrganizationPlan(organization.$id)
40-
: null,
41-
4236
loadAvailableRegions(project.teamId)
4337
]);
4438

4539
if (!organization) organization = org;
4640

41+
// fetch if not available in `plansInfo`.
42+
// out of promise.all because we filter orgs based on platform now!
43+
const organizationPlan = includedInBasePlans
44+
? plansInfo.get(organization?.billingPlan)
45+
: isCloud
46+
? await sdk.forConsole.billing.getOrganizationPlan(organization?.$id)
47+
: null;
48+
4749
const roles = rolesResult?.roles ?? defaultRoles;
4850
const scopes = rolesResult?.scopes ?? defaultScopes;
4951

src/routes/(public)/functions/deploy/+page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { redirect } from '@sveltejs/kit';
33
import { base } from '$app/paths';
44
import { isCloud } from '$lib/system';
55
import { BillingPlan } from '$lib/constants';
6-
import { ID, type Models, Query } from '@appwrite.io/console';
6+
import { ID, type Models, Query, Platform } from '@appwrite.io/console';
77
import type { OrganizationList } from '$lib/stores/organization';
88
import { redirectTo } from '$routes/store';
99
import type { PageLoad } from './$types';
@@ -67,7 +67,7 @@ export const load: PageLoad = async ({ parent, url }) => {
6767
let organizations: Models.TeamList<Record<string, unknown>> | OrganizationList | undefined;
6868
if (isCloud) {
6969
organizations = await sdk.forConsole.billing.listOrganization([
70-
Query.equal('platform', 'appwrite')
70+
Query.equal('platform', Platform.Appwrite)
7171
]);
7272
} else {
7373
organizations = await sdk.forConsole.teams.list();
@@ -91,7 +91,7 @@ export const load: PageLoad = async ({ parent, url }) => {
9191

9292
if (isCloud) {
9393
organizations = await sdk.forConsole.billing.listOrganization([
94-
Query.equal('platform', 'appwrite')
94+
Query.equal('platform', Platform.Appwrite)
9595
]);
9696
} else {
9797
organizations = await sdk.forConsole.teams.list();

src/routes/(public)/sites/deploy/+page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { redirect, error } from '@sveltejs/kit';
33
import { base } from '$app/paths';
44
import { isCloud } from '$lib/system';
55
import { BillingPlan } from '$lib/constants';
6-
import { ID, type Models, Query } from '@appwrite.io/console';
6+
import { ID, type Models, Query, Platform } from '@appwrite.io/console';
77
import type { OrganizationList } from '$lib/stores/organization';
88
import { redirectTo } from '$routes/store';
99
import type { PageLoad } from './$types';
@@ -84,7 +84,7 @@ export const load: PageLoad = async ({ parent, url }) => {
8484

8585
if (isCloud) {
8686
organizations = await sdk.forConsole.billing.listOrganization([
87-
Query.equal('platform', 'appwrite')
87+
Query.equal('platform', Platform.Appwrite)
8888
]);
8989
} else {
9090
organizations = await sdk.forConsole.teams.list();
@@ -109,7 +109,7 @@ export const load: PageLoad = async ({ parent, url }) => {
109109
// Refetch organizations after creation
110110
if (isCloud) {
111111
organizations = await sdk.forConsole.billing.listOrganization([
112-
Query.equal('platform', 'appwrite')
112+
Query.equal('platform', Platform.Appwrite)
113113
]);
114114
} else {
115115
organizations = await sdk.forConsole.teams.list();

src/routes/(public)/template-[template]/+page.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BillingPlan } from '$lib/constants.js';
22
import { sdk } from '$lib/stores/sdk.js';
3-
import { ID, type Models, Query } from '@appwrite.io/console';
3+
import { ID, type Models, Query, Platform } from '@appwrite.io/console';
44
import { isCloud } from '$lib/system.js';
55
import { error, redirect } from '@sveltejs/kit';
66
import type { OrganizationList } from '$lib/stores/organization.js';
@@ -40,7 +40,9 @@ export const load = async ({ parent, url, params }) => {
4040
let organizations: Models.TeamList<Record<string, unknown>> | OrganizationList | undefined;
4141
if (isCloud) {
4242
organizations = account?.$id
43-
? await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')])
43+
? await sdk.forConsole.billing.listOrganization([
44+
Query.equal('platform', Platform.Appwrite)
45+
])
4446
: undefined;
4547
} else {
4648
organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined;

src/routes/+layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { LayoutLoad } from './$types';
88
import { redirectTo } from './store';
99
import { base, resolve } from '$app/paths';
1010
import type { Account } from '$lib/stores/user';
11-
import { type AppwriteException, Query } from '@appwrite.io/console';
11+
import { type AppwriteException, Query, Platform } from '@appwrite.io/console';
1212
import { isCloud, VARS } from '$lib/system';
1313
import { checkPricingRefAndRedirect } from '$lib/helpers/pricingRedirect';
1414

@@ -43,7 +43,7 @@ export const load: LayoutLoad = async ({ depends, url, route }) => {
4343
organizations: !isCloud
4444
? await sdk.forConsole.teams.list()
4545
: await sdk.forConsole.billing.listOrganization([
46-
Query.equal('platform', 'appwrite')
46+
Query.equal('platform', Platform.Appwrite)
4747
])
4848
};
4949
}

0 commit comments

Comments
 (0)