Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/commandCenter/searchers/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { base } from '$app/paths';
import { sdk } from '$lib/stores/sdk';
import type { Searcher } from '../commands';
import { isCloud } from '$lib/system';
import { Query } from '@appwrite.io/console';

export const orgSearcher = (async (query: string) => {
const { teams } = !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization();
: await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')]);

return teams
.filter((organization) => organization.name.toLowerCase().includes(query.toLowerCase()))
Expand Down
3 changes: 2 additions & 1 deletion src/lib/stores/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ export async function checkForMissingPaymentMethod() {
const orgs = await sdk.forConsole.billing.listOrganization([
Query.notEqual('billingPlan', BillingPlan.FREE),
Query.isNull('paymentMethodId'),
Query.isNull('backupPaymentMethodId')
Query.isNull('backupPaymentMethodId'),
Query.equal('platform', 'appwrite')
]);
if (orgs?.total) {
orgMissingPaymentMethod.set(orgs.teams[0]);
Expand Down
7 changes: 6 additions & 1 deletion src/routes/(console)/account/organizations/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export const load: PageLoad = async ({ url, route }) => {
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);

const queries = [Query.offset(offset), Query.limit(limit), Query.orderDesc('')];
const queries = [
Query.offset(offset),
Query.limit(limit),
Query.orderDesc(''),
Query.equal('platform', 'appwrite')
];

const organizations = !isCloud
? await sdk.forConsole.teams.list({ queries })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
import { isCloud } from '$lib/system';
import { Query } from '@appwrite.io/console';

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

const organizations = !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization();
: await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')]);

const { domain } = await parent();
return {
Expand Down
10 changes: 7 additions & 3 deletions src/routes/(public)/functions/deploy/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { redirect } from '@sveltejs/kit';
import { base } from '$app/paths';
import { isCloud } from '$lib/system';
import { BillingPlan } from '$lib/constants';
import { ID, type Models } from '@appwrite.io/console';
import { ID, type Models, Query } from '@appwrite.io/console';
import type { OrganizationList } from '$lib/stores/organization';
import { redirectTo } from '$routes/store';
import type { PageLoad } from './$types';
Expand Down Expand Up @@ -66,7 +66,9 @@ export const load: PageLoad = async ({ parent, url }) => {
// Get organizations
let organizations: Models.TeamList<Record<string, unknown>> | OrganizationList | undefined;
if (isCloud) {
organizations = await sdk.forConsole.billing.listOrganization();
organizations = await sdk.forConsole.billing.listOrganization([
Query.equal('platform', 'appwrite')
]);
} else {
organizations = await sdk.forConsole.teams.list();
}
Expand All @@ -88,7 +90,9 @@ export const load: PageLoad = async ({ parent, url }) => {
}

if (isCloud) {
organizations = await sdk.forConsole.billing.listOrganization();
organizations = await sdk.forConsole.billing.listOrganization([
Query.equal('platform', 'appwrite')
]);
} else {
organizations = await sdk.forConsole.teams.list();
}
Expand Down
10 changes: 7 additions & 3 deletions src/routes/(public)/sites/deploy/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { redirect, error } from '@sveltejs/kit';
import { base } from '$app/paths';
import { isCloud } from '$lib/system';
import { BillingPlan } from '$lib/constants';
import { ID, type Models } from '@appwrite.io/console';
import { ID, type Models, Query } from '@appwrite.io/console';
import type { OrganizationList } from '$lib/stores/organization';
import { redirectTo } from '$routes/store';
import type { PageLoad } from './$types';
Expand Down Expand Up @@ -83,7 +83,9 @@ export const load: PageLoad = async ({ parent, url }) => {
let organizations: Models.TeamList<Record<string, unknown>> | OrganizationList | undefined;

if (isCloud) {
organizations = await sdk.forConsole.billing.listOrganization();
organizations = await sdk.forConsole.billing.listOrganization([
Query.equal('platform', 'appwrite')
]);
} else {
organizations = await sdk.forConsole.teams.list();
}
Expand All @@ -106,7 +108,9 @@ export const load: PageLoad = async ({ parent, url }) => {

// Refetch organizations after creation
if (isCloud) {
organizations = await sdk.forConsole.billing.listOrganization();
organizations = await sdk.forConsole.billing.listOrganization([
Query.equal('platform', 'appwrite')
]);
} else {
organizations = await sdk.forConsole.teams.list();
}
Expand Down
6 changes: 4 additions & 2 deletions src/routes/(public)/template-[template]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BillingPlan } from '$lib/constants.js';
import { sdk } from '$lib/stores/sdk.js';
import { ID, type Models } from '@appwrite.io/console';
import { ID, type Models, Query } from '@appwrite.io/console';
import { isCloud } from '$lib/system.js';
import { error, redirect } from '@sveltejs/kit';
import type { OrganizationList } from '$lib/stores/organization.js';
Expand Down Expand Up @@ -39,7 +39,9 @@ export const load = async ({ parent, url, params }) => {

let organizations: Models.TeamList<Record<string, unknown>> | OrganizationList | undefined;
if (isCloud) {
organizations = account?.$id ? await sdk.forConsole.billing.listOrganization() : undefined;
organizations = account?.$id
? await sdk.forConsole.billing.listOrganization([Query.equal('platform', 'appwrite')])
: undefined;
} else {
organizations = account?.$id ? await sdk.forConsole.teams.list() : undefined;
}
Expand Down
6 changes: 4 additions & 2 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { LayoutLoad } from './$types';
import { redirectTo } from './store';
import { base, resolve } from '$app/paths';
import type { Account } from '$lib/stores/user';
import type { AppwriteException } from '@appwrite.io/console';
import { type AppwriteException, Query } from '@appwrite.io/console';
import { isCloud, VARS } from '$lib/system';
import { checkPricingRefAndRedirect } from '$lib/helpers/pricingRedirect';

Expand Down Expand Up @@ -42,7 +42,9 @@ export const load: LayoutLoad = async ({ depends, url, route }) => {
account: account,
organizations: !isCloud
? await sdk.forConsole.teams.list()
: await sdk.forConsole.billing.listOrganization()
: await sdk.forConsole.billing.listOrganization([
Query.equal('platform', 'appwrite')
])
};
}

Expand Down