From 7616e5a43b67e82f3c8618b513185a53aaac38a7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 12 Jan 2026 20:05:51 +0400 Subject: [PATCH] Migrate from isCloud gating to billing checks --- src/lib/components/backupRestoreBox.svelte | 5 ++-- src/lib/components/cardContainer.svelte | 4 +-- src/lib/components/navbar.svelte | 7 +++-- src/lib/elements/table/body.svelte | 4 +-- src/lib/layout/containerHeader.svelte | 9 ++++--- src/lib/layout/shell.svelte | 15 ++++++----- src/lib/profiles/index.svelte.ts | 5 ++++ src/lib/stores/billing.ts | 8 +++--- src/routes/(console)/+layout.ts | 5 ++-- .../account/organizations/+page.svelte | 3 ++- .../(console)/account/organizations/+page.ts | 7 +++-- .../organization-[organization]/+layout.ts | 8 +++--- .../billing/+page.ts | 4 +-- .../organization-[organization]/header.svelte | 12 ++++----- .../members/+page.svelte | 6 ++--- .../settings/+page.ts | 4 +-- .../organization-[organization]/view.svelte | 13 ++++++---- .../project-[region]-[project]/+layout.ts | 8 +++--- .../auth/security/updateMockNumbers.svelte | 8 +++--- .../auth/templates/+page.svelte | 4 +-- .../database-[database]/+layout.svelte | 6 ++--- .../database-[database]/backups/+page.svelte | 5 ++-- .../backups/upgradeCard.svelte | 26 +++++++++---------- .../table-[table]/columns/string.svelte | 4 +-- .../create-function/manual/+page.svelte | 5 ++-- .../(modals)/createManual.svelte | 4 +-- .../settings/updateResourceLimits.svelte | 4 +-- .../template-[template]/+page.svelte | 6 ++--- .../sites/create-site/manual/+page.svelte | 5 ++-- .../createManualDeploymentModal.svelte | 4 +-- .../settings/updateResourceLimits.svelte | 4 +-- .../bucket-[bucket]/create/+page.svelte | 4 +-- 32 files changed, 113 insertions(+), 103 deletions(-) diff --git a/src/lib/components/backupRestoreBox.svelte b/src/lib/components/backupRestoreBox.svelte index 85d8cf6c00..42f51ee87b 100644 --- a/src/lib/components/backupRestoreBox.svelte +++ b/src/lib/components/backupRestoreBox.svelte @@ -2,8 +2,9 @@ import { realtime } from '$lib/stores/sdk'; import { type Payload } from '@appwrite.io/console'; import { onMount } from 'svelte'; - import { isCloud, isSelfHosted } from '$lib/system'; + import { isSelfHosted } from '$lib/system'; import { organization } from '$lib/stores/organization'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { Dependencies } from '$lib/constants'; import type { BackupArchive, BackupRestoration } from '$lib/sdk/backups'; import { goto, invalidate } from '$app/navigation'; @@ -126,7 +127,7 @@ onMount(() => { // fast path: don't subscribe if org is on a free plan or is self-hosted. - if (isSelfHosted || (isCloud && isFreePlan($organization?.billingPlan))) return; + if (isSelfHosted || (isBillingEnabled && isFreePlan($organization?.billingPlan))) return; return realtime.forProject(page.params.region, 'console', (response) => { if (!response.channels.includes(`projects.${getProjectId()}`)) return; diff --git a/src/lib/components/cardContainer.svelte b/src/lib/components/cardContainer.svelte index a34931d4f1..7586f3f964 100644 --- a/src/lib/components/cardContainer.svelte +++ b/src/lib/components/cardContainer.svelte @@ -2,11 +2,11 @@ import { page } from '$app/state'; import { Empty } from '$lib/components'; import { CARD_LIMIT } from '$lib/constants'; - import { isCloud } from '$lib/system'; import CardPlanLimit from './cardPlanLimit.svelte'; import { preferences } from '$lib/stores/preferences'; import { isSmallViewport } from '$lib/stores/viewport'; import { getServiceLimit, type PlanServices } from '$lib/stores/billing'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; export let disableEmpty = true; export let offset = 0; @@ -28,7 +28,7 @@ {#if total > 3 ? total < limit + offset : total % 2 !== 0} - {#if isCloud && serviceId && total >= planLimit} + {#if isBillingEnabled && serviceId && total >= planLimit} {:else} diff --git a/src/lib/components/navbar.svelte b/src/lib/components/navbar.svelte index e6b1955c18..02c45eebc1 100644 --- a/src/lib/components/navbar.svelte +++ b/src/lib/components/navbar.svelte @@ -50,14 +50,13 @@ import { logout } from '$lib/helpers/logout'; import { app } from '$lib/stores/app'; import { isTabletViewport, isSmallViewport } from '$lib/stores/viewport'; - import { isCloud } from '$lib/system.js'; import { user } from '$lib/stores/user'; import { Click, trackEvent } from '$lib/actions/analytics'; import { beforeNavigate } from '$app/navigation'; import { page } from '$app/state'; import type { Models } from '@appwrite.io/console'; import { organization } from '$lib/stores/organization'; - import { resolvedProfile } from '$lib/profiles/index.svelte'; + import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; import { headerAlert } from '$lib/stores/headerAlert'; import ProgressBar from './progressbar/ProgressBar.svelte'; import { resolve } from '$app/paths'; @@ -196,7 +195,7 @@
- {#if isCloud && currentOrg?.showUpgrade} + {#if isBillingEnabled && currentOrg?.showUpgrade} {#if dailyCredits !== null} - + {dailyCredits} daily and {monthlyCredits} monthly credits diff --git a/src/lib/elements/table/body.svelte b/src/lib/elements/table/body.svelte index a3ac5fe785..8e45d27ff5 100644 --- a/src/lib/elements/table/body.svelte +++ b/src/lib/elements/table/body.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { Click, trackEvent } from '$lib/actions/analytics'; import { getServiceLimit, upgradeURL, type PlanServices } from '$lib/stores/billing'; - import { isCloud } from '$lib/system'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { Button } from '../forms'; let tableBody: HTMLDivElement; @@ -31,7 +31,7 @@
-{#if isCloud && limitReached && service} +{#if isBillingEnabled && limitReached && service} diff --git a/src/lib/layout/containerHeader.svelte b/src/lib/layout/containerHeader.svelte index 538a4137aa..5ee4cb20b3 100644 --- a/src/lib/layout/containerHeader.svelte +++ b/src/lib/layout/containerHeader.svelte @@ -16,8 +16,9 @@ type PlanServices } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; - import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system'; + import { GRACE_PERIOD_OVERRIDE } from '$lib/system'; import { createEventDispatcher, onMount } from 'svelte'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { ContainerButton } from '.'; import { goto } from '$app/navigation'; import { Layout, Typography } from '@appwrite.io/pink-svelte'; @@ -89,8 +90,8 @@ $: if (isLimited) dispatch('data', { isButtonDisabled, limit, tier }); - -{#if isCloud && showAlert} + +{#if isBillingEnabled && showAlert} {@const services = overflowingServices .map((s) => { @@ -127,7 +128,7 @@ {title} - {#if isCloud && isLimited} + {#if isBillingEnabled && isLimited} {#if hasProjectLimitation} ('failedInvoice', function ({ set }) { return { load: async (orgId) => { - if (!isCloud) set(null); + if (!isBillingEnabled) set(null); if (!get(canSeeBilling)) set(null); const failedInvoices = await sdk.forConsole.billing.listInvoices(orgId, [ Query.equal('status', 'failed') @@ -314,7 +314,7 @@ export function calculateTrialDay(org: Organization) { } export async function checkForProjectsLimit(org: Organization, orgProjectCount?: number) { - if (!isCloud) return; + if (!isBillingEnabled) return; if (!org) return; const plan = await sdk.forConsole.billing.getOrganizationPlan(org.$id); diff --git a/src/routes/(console)/+layout.ts b/src/routes/(console)/+layout.ts index 4c5a6dd438..3ec48a81d7 100644 --- a/src/routes/(console)/+layout.ts +++ b/src/routes/(console)/+layout.ts @@ -1,11 +1,10 @@ import { sdk } from '$lib/stores/sdk'; -import { isCloud } from '$lib/system'; import type { LayoutLoad } from './$types'; import { Query } from '@appwrite.io/console'; import type { Tier } from '$lib/stores/billing'; import type { Plan, PlanList } from '$lib/sdk/billing'; import { Dependencies } from '$lib/constants'; -import { resolvedProfile } from '$lib/profiles/index.svelte'; +import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; export const load: LayoutLoad = async ({ depends, parent }) => { const { organizations } = await parent(); @@ -17,7 +16,7 @@ export const load: LayoutLoad = async ({ depends, parent }) => { const { endpoint, project } = sdk.forConsole.client.config; const [preferences, plansArray, versionData, consoleVariables] = await Promise.all([ sdk.forConsole.account.getPrefs(), - isCloud ? sdk.forConsole.billing.listPlans() : null, + isBillingEnabled ? sdk.forConsole.billing.listPlans() : null, fetch(`${endpoint}/health/version`, { headers: { 'X-Appwrite-Project': project } }).then((response) => response.json() as { version?: string }), diff --git a/src/routes/(console)/account/organizations/+page.svelte b/src/routes/(console)/account/organizations/+page.svelte index 5475fa7d56..c581b83aba 100644 --- a/src/routes/(console)/account/organizations/+page.svelte +++ b/src/routes/(console)/account/organizations/+page.svelte @@ -13,6 +13,7 @@ import { sdk } from '$lib/stores/sdk'; import type { PageData } from './$types'; import { isCloud } from '$lib/system'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { Badge, Skeleton } from '@appwrite.io/pink-svelte'; import type { Models } from '@appwrite.io/console'; import type { Organization } from '$lib/stores/organization'; @@ -85,7 +86,7 @@ function isCloudOrg( data: Partial> | Organization ): data is Organization { - return isCloud && 'billingPlan' in data; + return isBillingEnabled && 'billingPlan' in data; } function createOrg() { diff --git a/src/routes/(console)/account/organizations/+page.ts b/src/routes/(console)/account/organizations/+page.ts index 536082e210..31ce6a2f7b 100644 --- a/src/routes/(console)/account/organizations/+page.ts +++ b/src/routes/(console)/account/organizations/+page.ts @@ -3,8 +3,7 @@ import { sdk } from '$lib/stores/sdk'; import { getLimit, getPage, pageToOffset } from '$lib/helpers/load'; import { CARD_LIMIT } from '$lib/constants'; import type { PageLoad } from './$types'; -import { isCloud } from '$lib/system'; -import { resolvedProfile } from '$lib/profiles/index.svelte'; +import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; export const load: PageLoad = async ({ url, route }) => { const page = getPage(url); @@ -15,10 +14,10 @@ export const load: PageLoad = async ({ url, route }) => { Query.offset(offset), Query.limit(limit), Query.orderDesc(''), - ...(isCloud ? [Query.equal('platform', resolvedProfile.organizationPlatform)] : []) + ...(isBillingEnabled ? [Query.equal('platform', resolvedProfile.organizationPlatform)] : []) ]; - const organizations = !isCloud + const organizations = !isBillingEnabled ? await sdk.forConsole.teams.list({ queries }) : await sdk.forConsole.billing.listOrganization(queries); diff --git a/src/routes/(console)/organization-[organization]/+layout.ts b/src/routes/(console)/organization-[organization]/+layout.ts index 22d86d0752..e3380d4ad5 100644 --- a/src/routes/(console)/organization-[organization]/+layout.ts +++ b/src/routes/(console)/organization-[organization]/+layout.ts @@ -14,7 +14,7 @@ import { defaultRoles, defaultScopes } from '$lib/constants'; import type { Plan } from '$lib/sdk/billing'; import { loadAvailableRegions } from '$routes/(console)/regions'; import type { Organization } from '$lib/stores/organization'; -import { resolvedProfile } from '$lib/profiles/index.svelte'; +import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; import { resolve } from '$app/paths'; export const load: LayoutLoad = async ({ params, depends, parent }) => { @@ -26,12 +26,12 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => { const requestedOrg = await checkPlatformAndRedirect(params, organizations, prefs); - let roles = isCloud ? [] : defaultRoles; - let scopes = isCloud ? [] : defaultScopes; + let roles = isBillingEnabled ? [] : defaultRoles; + let scopes = isBillingEnabled ? [] : defaultScopes; let currentPlan: Plan = null; try { - if (isCloud) { + if (isBillingEnabled) { [{ roles, scopes }, currentPlan] = await Promise.all([ sdk.forConsole.billing.getRoles(params.organization), sdk.forConsole.billing.getOrganizationPlan(params.organization) diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts index 535c319542..8bbba5c16f 100644 --- a/src/routes/(console)/organization-[organization]/billing/+page.ts +++ b/src/routes/(console)/organization-[organization]/billing/+page.ts @@ -4,7 +4,7 @@ import { type Organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; import { redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; -import { isCloud } from '$lib/system'; +import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { base } from '$app/paths'; import { isFreePlan } from '$lib/helpers/billing'; @@ -62,7 +62,7 @@ export const load: PageLoad = async ({ parent, depends, url, route }) => { // ignore error } - const areCreditsSupported = isCloud + const areCreditsSupported = isBillingEnabled ? (currentPlan?.supportsCredits ?? (!isFreePlan(organization.billingPlan) && organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION)) diff --git a/src/routes/(console)/organization-[organization]/header.svelte b/src/routes/(console)/organization-[organization]/header.svelte index 140d43d2bf..1f40c0939a 100644 --- a/src/routes/(console)/organization-[organization]/header.svelte +++ b/src/routes/(console)/organization-[organization]/header.svelte @@ -31,7 +31,7 @@ import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system'; import { IconGithub, IconPlus, IconPlusSm } from '@appwrite.io/pink-icons-svelte'; import { Badge, Icon, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte'; - import { resolvedProfile } from '$lib/profiles/index.svelte'; + import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; import { isFreePlan } from '$lib/helpers/billing'; let areMembersLimited: boolean = $state(false); @@ -75,7 +75,7 @@ title: 'Usage', hasChildren: true, disabled: !( - isCloud && + isBillingEnabled && ($isOwner || $isBilling) && !page.data.currentPlan?.usagePerProject ) @@ -84,7 +84,7 @@ href: `${path}/billing`, event: 'billing', title: 'Billing', - disabled: !(isCloud && $canSeeBilling) + disabled: !(isBillingEnabled && $canSeeBilling) }, { href: `${path}/settings`, @@ -119,15 +119,15 @@ {#if !resolvedProfile.minimalOrgHeader} - {#if isCloud && organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} + {#if isBillingEnabled && organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} - {:else if isCloud && isFreePlan(organization?.billingPlan)} + {:else if isBillingEnabled && isFreePlan(organization?.billingPlan)} {/if} - {#if isCloud && organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays} + {#if isBillingEnabled && organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays} diff --git a/src/routes/(console)/organization-[organization]/members/+page.svelte b/src/routes/(console)/organization-[organization]/members/+page.svelte index 4ac568c6f6..e770d09e3d 100644 --- a/src/routes/(console)/organization-[organization]/members/+page.svelte +++ b/src/routes/(console)/organization-[organization]/members/+page.svelte @@ -14,7 +14,7 @@ import type { Models } from '@appwrite.io/console'; import Delete from '../deleteMember.svelte'; import Edit from './edit.svelte'; - import { isCloud } from '$lib/system'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { IconDotsHorizontal, IconInfo, @@ -47,7 +47,7 @@ // Calculate if button should be disabled and tooltip should show $: memberCount = data.organizationMembers?.total ?? 0; $: isFreeWithMembers = isFreePlan($organization?.billingPlan) && memberCount >= 1; - $: isButtonDisabled = isCloud ? isFreeWithMembers : false; + $: isButtonDisabled = isBillingEnabled ? isFreeWithMembers : false; const resend = async (member: Models.Membership) => { try { @@ -159,7 +159,7 @@
- {#if isCloud && $currentPlan?.supportsOrganizationRoles} + {#if isBillingEnabled && $currentPlan?.supportsOrganizationRoles} { diff --git a/src/routes/(console)/organization-[organization]/settings/+page.ts b/src/routes/(console)/organization-[organization]/settings/+page.ts index ffecda25ac..260af1ecfe 100644 --- a/src/routes/(console)/organization-[organization]/settings/+page.ts +++ b/src/routes/(console)/organization-[organization]/settings/+page.ts @@ -2,7 +2,7 @@ import type { PageLoad } from './$types'; import { Dependencies } from '$lib/constants'; import { sdk } from '$lib/stores/sdk'; import { Query } from '@appwrite.io/console'; -import { isCloud } from '$lib/system'; +import { isBillingEnabled } from '$lib/profiles/index.svelte'; export const load: PageLoad = async ({ depends, params, parent }) => { const { countryList, locale } = await parent(); @@ -10,7 +10,7 @@ export const load: PageLoad = async ({ depends, params, parent }) => { const [projects, invoices] = await Promise.all([ sdk.forConsole.projects.list({ queries: [Query.equal('teamId', params.organization)] }), - isCloud ? sdk.forConsole.billing.listInvoices(params.organization) : undefined + isBillingEnabled ? sdk.forConsole.billing.listInvoices(params.organization) : undefined ]); return { diff --git a/src/routes/(console)/organization-[organization]/view.svelte b/src/routes/(console)/organization-[organization]/view.svelte index 9efb60af75..49474b2484 100644 --- a/src/routes/(console)/organization-[organization]/view.svelte +++ b/src/routes/(console)/organization-[organization]/view.svelte @@ -4,6 +4,7 @@ import CreateProject from './createProject.svelte'; import CreateOrganization from '../createOrganization.svelte'; import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { page } from '$app/state'; import { registerCommands } from '$lib/commandCenter'; import { formatName as formatNameHelper } from '$lib/helpers/string'; @@ -84,12 +85,14 @@ } $: projectCreationDisabled = - (isCloud && getServiceLimit('projects', null, data.currentPlan) <= data.projects.total) || - (isCloud && $readOnly && !GRACE_PERIOD_OVERRIDE) || + (isBillingEnabled && + getServiceLimit('projects', null, data.currentPlan) <= data.projects.total) || + (isBillingEnabled && $readOnly && !GRACE_PERIOD_OVERRIDE) || !$canWriteProjects; $: reachedProjectLimit = - isCloud && getServiceLimit('projects', null, data.currentPlan) <= data.projects.total; + isBillingEnabled && + getServiceLimit('projects', null, data.currentPlan) <= data.projects.total; $: projectsLimit = getServiceLimit('projects', null, data.currentPlan); @@ -178,7 +181,7 @@ {/if} - {#if isCloud && $currentPlan?.projects && $currentPlan?.projects > 0 && data.organization.projects.length > 0 && $canWriteProjects && (projectsToArchive.length > 0 || data.projects.total > $currentPlan.projects)} + {#if isBillingEnabled && $currentPlan?.projects && $currentPlan?.projects > 0 && data.organization.projects.length > 0 && $canWriteProjects && (projectsToArchive.length > 0 || data.projects.total > $currentPlan.projects)} {@const difference = projectsToArchive.length} {@const messagePrefix = difference !== 1 ? `${difference} projects are` : `${difference} project is`} @@ -201,7 +204,7 @@ {/if} - {#if isCloud && isFreePlan(data.organization.billingPlan) && projectsToArchive.length === 0 && !freePlanAlertDismissed} + {#if isBillingEnabled && isFreePlan(data.organization.billingPlan) && projectsToArchive.length === 0 && !freePlanAlertDismissed} Your Free plan includes up to 2 projects and limited resources. Upgrade to unlock diff --git a/src/routes/(console)/project-[region]-[project]/+layout.ts b/src/routes/(console)/project-[region]-[project]/+layout.ts index 019b442f7f..0180df3c9d 100644 --- a/src/routes/(console)/project-[region]-[project]/+layout.ts +++ b/src/routes/(console)/project-[region]-[project]/+layout.ts @@ -10,7 +10,7 @@ import PaymentFailed from '$lib/components/billing/alerts/paymentFailed.svelte'; import { loadAvailableRegions } from '$routes/(console)/regions'; import type { Organization } from '$lib/stores/organization'; import { redirect } from '@sveltejs/kit'; -import { resolvedProfile } from '$lib/profiles/index.svelte'; +import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; import { resolve } from '$app/paths'; function checkServiceAccess(routeId: string | null, params: { region: string; project: string }) { @@ -55,7 +55,7 @@ export const load: LayoutLoad = async ({ params, route, depends, parent }) => { ? (sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise) : organization, sdk.forConsoleIn(project.region).console.variables(), - isCloud ? sdk.forConsole.billing.getRoles(project.teamId) : null, + isBillingEnabled ? sdk.forConsole.billing.getRoles(project.teamId) : null, loadAvailableRegions(project.teamId) ]); @@ -77,7 +77,7 @@ export const load: LayoutLoad = async ({ params, route, depends, parent }) => { // out of promise.all because we filter orgs based on platform now! const organizationPlan = includedInBasePlans ? plansInfo.get(organization?.billingPlan) - : isCloud + : isBillingEnabled ? await sdk.forConsole.billing.getOrganizationPlan(organization?.$id) : null; @@ -96,7 +96,7 @@ export const load: LayoutLoad = async ({ params, route, depends, parent }) => { // should be awaited for `displayNames`! await preferences.loadTeamPrefs(project.teamId); - if (isCloud && scopes.includes('billing.read')) { + if (isBillingEnabled && scopes.includes('billing.read')) { loadFailedInvoices(project.teamId); } diff --git a/src/routes/(console)/project-[region]-[project]/auth/security/updateMockNumbers.svelte b/src/routes/(console)/project-[region]-[project]/auth/security/updateMockNumbers.svelte index be735a7085..1d93cf9621 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/security/updateMockNumbers.svelte @@ -10,7 +10,7 @@ import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; import { currentPlan } from '$lib/stores/organization'; - import { isCloud, isSelfHosted } from '$lib/system'; + import { isSelfHosted } from '$lib/system'; import MockNumbersLight from './mock-numbers-light.png'; import MockNumbersDark from './mock-numbers-dark.png'; import EmptyCardImageCloud from '$lib/components/emptyCardImageCloud.svelte'; @@ -19,7 +19,7 @@ import type { Models } from '@appwrite.io/console'; import { Icon, Input, Layout, Link, Tooltip } from '@appwrite.io/pink-svelte'; import { IconPlus, IconRefresh } from '@appwrite.io/pink-icons-svelte'; - import { resolvedProfile } from '$lib/profiles/index.svelte'; + import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; let numbers: Models.MockNumber[] = $project?.authMockNumbers ?? []; let initialNumbers = []; @@ -28,7 +28,7 @@ $: isSubmitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers); let isComponentDisabled: boolean = - isSelfHosted || (isCloud && !$currentPlan.supportsMockNumbers); + isSelfHosted || (isBillingEnabled && !$currentPlan.supportsMockNumbers); let emptyStateTitle: string = isSelfHosted ? `Available on ${resolvedProfile.platform} Cloud` @@ -141,7 +141,7 @@ secondary fullWidth external={isSelfHosted} - href={isCloud ? $upgradeURL : 'https://cloud.appwrite.io/register'} + href={isSelfHosted ? 'https://cloud.appwrite.io/register' : $upgradeURL} on:click={() => { trackEvent(Click.CloudSignupClick, { from: 'button', diff --git a/src/routes/(console)/project-[region]-[project]/auth/templates/+page.svelte b/src/routes/(console)/project-[region]-[project]/auth/templates/+page.svelte index da7178906c..cbaf29eaec 100644 --- a/src/routes/(console)/project-[region]-[project]/auth/templates/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/auth/templates/+page.svelte @@ -55,7 +55,7 @@ import { Button } from '$lib/elements/forms'; import { currentPlan } from '$lib/stores/organization'; import EmailSignature from './emailSignature.svelte'; - import { isCloud } from '$lib/system'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { Accordion, Alert, Badge, Layout, Link, Typography } from '@appwrite.io/pink-svelte'; import { page } from '$app/state'; @@ -144,7 +144,7 @@ - {#if isCloud && $currentPlan.emailBranding} + {#if isBillingEnabled && $currentPlan.emailBranding} {/if} diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte index 188eb41a65..d28d4f0bde 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte @@ -17,7 +17,7 @@ import { showCreateBackup, showCreatePolicy } from './backups/store'; import { IconPlus } from '@appwrite.io/pink-icons-svelte'; import { currentPlan } from '$lib/stores/organization'; - import { isCloud } from '$lib/system'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { noWidthTransition } from '$lib/stores/sidebar'; import { resolvedProfile } from '$lib/profiles/index.svelte'; import { getPageTitle } from '../../store'; @@ -55,7 +55,7 @@ group: 'databases', icon: IconPlus, rank: page.url.pathname.endsWith('backups') ? 10 : 0, - disabled: !isCloud || !$currentPlan?.backupsEnabled + disabled: !isBillingEnabled || !$currentPlan?.backupsEnabled }, { label: 'Create manual backup', @@ -71,7 +71,7 @@ group: 'databases', icon: IconPlus, rank: page.url.pathname.endsWith('backups') ? 10 : 0, - disabled: !isCloud || !$currentPlan?.backupsEnabled + disabled: !isBillingEnabled || !$currentPlan?.backupsEnabled }, { label: 'Go to tables', diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/+page.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/+page.svelte index 99521078d7..74cad5496b 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/+page.svelte @@ -12,8 +12,9 @@ import { realtime, sdk } from '$lib/stores/sdk'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; - import { isCloud, isSelfHosted } from '$lib/system'; + import { isSelfHosted } from '$lib/system'; import { currentPlan } from '$lib/stores/organization'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { onMount } from 'svelte'; import { feedback } from '$lib/stores/feedback'; import { cronExpression, type UserBackupPolicy } from '$lib/helpers/backups'; @@ -27,7 +28,7 @@ let policyCreateError: string; let totalPolicies: UserBackupPolicy[] = []; - let isDisabled = isSelfHosted || (isCloud && !$currentPlan.backupsEnabled); + let isDisabled = isSelfHosted || (isBillingEnabled && !$currentPlan.backupsEnabled); export let data: PageData; diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/upgradeCard.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/upgradeCard.svelte index 46e7107005..490fdc5583 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/upgradeCard.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/upgradeCard.svelte @@ -12,17 +12,17 @@ import EmptyLightTablet from '$lib/images/backups/upgrade/backups-tablet-light.png'; import { upgradeURL } from '$lib/stores/billing'; - import { isCloud } from '$lib/system'; + import { isSelfHosted } from '$lib/system'; import { Card, Layout, Typography } from '@appwrite.io/pink-svelte'; import { resolvedProfile } from '$lib/profiles/index.svelte'; - const title = isCloud - ? 'Backups are available on paid plans' - : `Database Backups are available on ${resolvedProfile.platform} Cloud`; + const title = isSelfHosted + ? `Database Backups are available on ${resolvedProfile.platform} Cloud` + : 'Backups are available on paid plans'; - const message = isCloud - ? `Upgrade now to unlock ${resolvedProfile.platform}'s backups.` - : `Sign up now to access ${resolvedProfile.platform}'s backups.`; + const message = isSelfHosted + ? `Sign up now to access ${resolvedProfile.platform}'s backups.` + : `Upgrade now to unlock ${resolvedProfile.platform}'s backups.`; const isDark = $app.themeInUse === 'dark'; @@ -77,17 +77,17 @@
diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/string.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/string.svelte index 84ef6f7060..06eba1e166 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/string.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/columns/string.svelte @@ -39,9 +39,9 @@ diff --git a/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte b/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte index 8714fd8e61..7fceb96efb 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/create-site/manual/+page.svelte @@ -18,10 +18,9 @@ import { IconInfo } from '@appwrite.io/pink-icons-svelte'; import { InvalidFileType, removeFile } from '$lib/helpers/files'; import { humanFileSize } from '$lib/helpers/sizeConvertion'; - import { isCloud } from '$lib/system'; import { currentPlan } from '$lib/stores/organization'; import Domain from '../domain.svelte'; - import { resolvedProfile } from '$lib/profiles/index.svelte'; + import { isBillingEnabled, resolvedProfile } from '$lib/profiles/index.svelte'; export let data; let showExitModal = false; @@ -44,7 +43,7 @@ let files: FileList; $: maxSize = - isCloud && $currentPlan + isBillingEnabled && $currentPlan ? $currentPlan.deploymentSize * 1000000 : $regionalConsoleVariables._APP_COMPUTE_SIZE_LIMIT; // already in MB diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/createManualDeploymentModal.svelte b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/createManualDeploymentModal.svelte index a8843f2fac..6e2ce85f2b 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/createManualDeploymentModal.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/createManualDeploymentModal.svelte @@ -9,10 +9,10 @@ import type { Models } from '@appwrite.io/console'; import { IconInfo } from '@appwrite.io/pink-icons-svelte'; import { Icon, Layout, Tooltip, Typography, Upload } from '@appwrite.io/pink-svelte'; - import { isCloud } from '$lib/system'; import { currentPlan } from '$lib/stores/organization'; import { consoleVariables } from '$routes/(console)/store'; import { humanFileSize } from '$lib/helpers/sizeConvertion'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; export let show = false; export let site: Models.Site; @@ -21,7 +21,7 @@ let error: string = ''; $: maxSize = - isCloud && $currentPlan + isBillingEnabled && $currentPlan ? $currentPlan.deploymentSize * 1000000 : $consoleVariables._APP_COMPUTE_SIZE_LIMIT; // already in MB diff --git a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateResourceLimits.svelte b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateResourceLimits.svelte index cfd1df2894..0f52cf6d9c 100644 --- a/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateResourceLimits.svelte +++ b/src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateResourceLimits.svelte @@ -10,10 +10,10 @@ import Link from '$lib/elements/link.svelte'; import { Alert } from '@appwrite.io/pink-svelte'; import { upgradeURL } from '$lib/stores/billing'; - import { isCloud } from '$lib/system'; import { organization } from '$lib/stores/organization'; import { page } from '$app/state'; import { isFreePlan } from '$lib/helpers/billing'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; export let site: Models.Site; export let specs: Models.SpecificationList; @@ -83,7 +83,7 @@ disabled={options.length < 1} bind:value={specification} {options} /> - {#if isCloud && isFreePlan($organization?.billingPlan)} + {#if isBillingEnabled && isFreePlan($organization?.billingPlan)} Upgrade to Pro or Scale to adjust your CPU and RAM beyond the default. diff --git a/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/create/+page.svelte b/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/create/+page.svelte index 8242811059..f96ec43c5f 100644 --- a/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/create/+page.svelte +++ b/src/routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/create/+page.svelte @@ -16,8 +16,8 @@ import { writable } from 'svelte/store'; import { Permissions } from '$lib/components/permissions'; import type { PageData } from './$types'; - import { isCloud } from '$lib/system'; import { currentPlan } from '$lib/stores/organization'; + import { isBillingEnabled } from '$lib/profiles/index.svelte'; import { humanFileSize, sizeToBytes } from '$lib/helpers/sizeConvertion'; import CustomId from '$lib/components/customId.svelte'; import { IconPencil } from '@appwrite.io/pink-icons-svelte'; @@ -101,7 +101,7 @@
- {#if isCloud && fileError === 'File size exceeds the limit'} + {#if isBillingEnabled && fileError === 'File size exceeds the limit'} {@const size = humanFileSize( data.bucket.maximumFileSize ?? sizeToBytes(service, 'MB', 1000) )}