Skip to content

Commit

Permalink
Merge branch 'appwrite:main' into fix-977-email-failed-modal-message-…
Browse files Browse the repository at this point in the history
…improve
  • Loading branch information
naman1608 authored Jun 8, 2024
2 parents f15afcc + e1169fa commit d2011db
Show file tree
Hide file tree
Showing 32 changed files with 110 additions and 96 deletions.
6 changes: 4 additions & 2 deletions src/lib/components/billing/alerts/limitReached.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import { organization } from '$lib/stores/organization';
</script>

{#if $organization?.$id && $organization?.billingPlan === BillingPlan.STARTER && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes($page.url.pathname)}
<HeaderAlert
type="error"
title={`${$organization.name} usage has reached the ${tierToPlan($organization.billingPlan).name} plan limit`}>
<svelte:fragment>
Usage for the <b>{$organization.name}</b> organization has reached the limits of the Starter
Usage for the <b>{$organization.name}</b> organization has reached the limits of the {tierToPlan(
$organization.billingPlan
).name}
plan. Consider upgrading to increase your resource usage.
</svelte:fragment>
<svelte:fragment slot="buttons">
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/billing/planComparisonBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<SecondaryTabsItem
disabled={selectedTab === 'tier-0'}
on:click={() => (selectedTab = 'tier-0')}>
Starter
Free
</SecondaryTabsItem>
<SecondaryTabsItem
disabled={selectedTab === 'tier-1'}
Expand All @@ -38,7 +38,7 @@
{:else if selectedTab === 'tier-1'}
<h3 class="u-bold body-text-1">{plan.name} plan</h3>
<ul class="un-order-list u-margin-block-start-8">
<li>Everything in the Starter plan, plus:</li>
<li>Everything in the Free plan, plus:</li>
<li>Unlimited databases, buckets, functions</li>
<li>{plan.bandwidth}GB bandwidth</li>
<li>{plan.storage}GB storage</li>
Expand Down
10 changes: 6 additions & 4 deletions src/lib/components/billing/planExcess.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { onMount } from 'svelte';
import type { OrganizationUsage } from '$lib/sdk/billing';
import { sdk } from '$lib/stores/sdk';
import { BillingPlan } from '$lib/constants';
export let tier: Tier;
Expand Down Expand Up @@ -51,15 +52,16 @@
$organization.billingNextInvoiceDate
)}
</svelte:fragment>
Following payment of your final invoice, your organization will switch to the Starter plan. {#if excess?.members > 0}All
team members except the owner will be removed on that date.{/if} Service disruptions may
occur unless resource usage is reduced.
Following payment of your final invoice, your organization will switch to the {tierToPlan(
BillingPlan.FREE
).name} plan. {#if excess?.members > 0}All team members except the owner will be removed on
that date.{/if} Service disruptions may occur unless resource usage is reduced.
<!-- Any executions, bandwidth, or messaging usage will be reset at that time. -->
<svelte:fragment slot="buttons">
<Button
text
external
href="https://appwrite.io/docs/advanced/platform/starter#reaching-resource-limits">
href="https://appwrite.io/docs/advanced/platform/free#reaching-resource-limits">
Learn more
</Button>
</svelte:fragment>
Expand Down
7 changes: 3 additions & 4 deletions src/lib/components/billing/usageRates.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@
}
];
$: isFree = org.billingPlan === BillingPlan.STARTER;
$: isFree = org.billingPlan === BillingPlan.FREE;
</script>

<Modal bind:show size="big" headerDivider={false} title="Usage rates">
{#if isFree}
Usage on the Starter plan is limited for the following resources. Next billing period: {toLocaleDate(
nextDate
)}.
Usage on the {$plansInfo?.get(BillingPlan.FREE).name} plan is limited for the following resources.
Next billing period: {toLocaleDate(nextDate)}.
{:else if org.billingPlan === BillingPlan.PRO}
<p>
Usage on the Pro plan will be charged at the end of each billing period at the following
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/support.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</p>
{/if}
</div>
{#if $organization?.billingPlan === BillingPlan.STARTER}
{#if $organization?.billingPlan === BillingPlan.FREE}
<Button
fullWidth
href={$upgradeURL}
Expand Down Expand Up @@ -63,6 +63,7 @@
<div class="u-margin-block-start-8 u-width-full-line">
{#key $app.themeInUse}
<iframe
style="color-scheme: none"
title="Appwrite Status"
src={`https://status.appwrite.online/badge?theme=${
$app.themeInUse === 'dark' ? 'dark' : 'light'
Expand Down
4 changes: 2 additions & 2 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export const eventServices: Array<EventService> = [
];

export enum BillingPlan {
STARTER = 'tier-0',
FREE = 'tier-0',
PRO = 'tier-1',
SCALE = 'tier-2'
}
Expand All @@ -387,7 +387,7 @@ export const feedbackDowngradeOptions = [
},
{
value: 'starter',
label: 'The Starter plan is enough for my projects'
label: 'The Free plan is enough for my projects'
},
{
value: 'budget',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/layout/activity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
Logs are retained in rolling {hoursToDays(limit)} intervals with the
{tierToPlan($organization.billingPlan).name}
plan.
{#if $organization?.billingPlan === BillingPlan.STARTER}
{#if $organization?.billingPlan === BillingPlan.FREE}
<Button link on:click={upgradeMethod}>Upgrade</Button> to increase your log
retention for a longer period.
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/layout/containerButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export let title: string;
export let tooltipContent =
$organization.billingPlan === BillingPlan.STARTER
$organization.billingPlan === BillingPlan.FREE
? `Upgrade to add more ${title.toLocaleLowerCase()}`
: `You've reached the ${title.toLocaleLowerCase()} limit for the ${
tierToPlan($organization.billingPlan).name
Expand Down
8 changes: 4 additions & 4 deletions src/lib/layout/containerHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
$: tier = tierToPlan($organization?.billingPlan)?.name;
$: hasProjectLimitation =
checkForProjectLimitation(serviceId) && $organization?.billingPlan === BillingPlan.STARTER;
checkForProjectLimitation(serviceId) && $organization?.billingPlan === BillingPlan.FREE;
$: hasUsageFees = hasProjectLimitation
? checkForUsageFees($organization?.billingPlan, serviceId)
: false;
Expand All @@ -88,7 +88,7 @@
})
.join(', ')}
<slot name="alert" {limit} {tier} {title} {upgradeMethod} {hasUsageFees} {services}>
{#if $organization?.billingPlan !== BillingPlan.STARTER && hasUsageFees}
{#if $organization?.billingPlan !== BillingPlan.FREE && hasUsageFees}
<Alert type="info" isStandalone>
<span class="text">
You've reached the {services} limit for the {tier} plan.
Expand Down Expand Up @@ -135,7 +135,7 @@
<p class="text">
You are limited to {limit}
{title.toLocaleLowerCase()} per project on the {tier} plan.
{#if $organization?.billingPlan === BillingPlan.STARTER}<Button
{#if $organization?.billingPlan === BillingPlan.FREE}<Button
link
href={$upgradeURL}
on:click={() =>
Expand All @@ -158,7 +158,7 @@
<p class="text">
You are limited to {limit}
{title.toLocaleLowerCase()} per organization on the {tier} plan.
{#if $organization?.billingPlan === BillingPlan.STARTER}
{#if $organization?.billingPlan === BillingPlan.FREE}
<Button link href={$upgradeURL}>Upgrade</Button>
for additional {title.toLocaleLowerCase()}.
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/layout/header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

<div class="main-header-end">
<nav class="u-flex is-only-desktop u-cross-center">
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER && !$page.url.pathname.startsWith('/console/account')}
{#if isCloud && $organization?.billingPlan === BillingPlan.FREE && !$page.url.pathname.startsWith('/console/account')}
<Button
disabled={$organization?.markedForDeletion}
href={$upgradeURL}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/layout/logs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
<Alert>
Logs are retained in rolling {hoursToDays(limit)} intervals
with the {tier} plan.
{#if $organization.billingPlan === BillingPlan.STARTER}
{#if $organization.billingPlan === BillingPlan.FREE}
<Button link href={$upgradeURL}>Upgrade</Button> to increase
your log retention for a longer period.
{/if}
Expand Down
16 changes: 8 additions & 8 deletions src/lib/stores/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const readOnly = writable<boolean>(false);

export function tierToPlan(tier: Tier) {
switch (tier) {
case BillingPlan.STARTER:
case BillingPlan.FREE:
return tierFree;
case BillingPlan.PRO:
return tierPro;
Expand Down Expand Up @@ -115,7 +115,7 @@ export type TierData = {
};

export const tierFree: TierData = {
name: 'Starter',
name: 'Free',
description: 'For personal hobby projects of small scale and students.'
};

Expand Down Expand Up @@ -171,7 +171,7 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num
}

export function calculateTrialDay(org: Organization) {
if (org?.billingPlan === BillingPlan.STARTER) return false;
if (org?.billingPlan === BillingPlan.FREE) return false;
const endDate = new Date(org?.billingStartDate);
const today = new Date();

Expand All @@ -185,7 +185,7 @@ export function calculateTrialDay(org: Organization) {
}

export async function checkForUsageLimit(org: Organization) {
if (org?.billingPlan !== BillingPlan.STARTER) {
if (org?.billingPlan !== BillingPlan.FREE) {
readOnly.set(false);
return;
}
Expand Down Expand Up @@ -221,9 +221,9 @@ export async function checkForUsageLimit(org: Organization) {
if (now - lastNotification < 1000 * 60 * 60 * 24) return;

localStorage.setItem('limitReachedNotification', now.toString());
let message = `<b>${org.name}</b> has reached <b>75%</b> of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`;
let message = `<b>${org.name}</b> has reached <b>75%</b> of the ${tierToPlan(BillingPlan.FREE).name} plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`;
if (resources.filter((r) => r.value >= 75)?.length > 1) {
message = `Usage for <b>${org.name}</b> has reached 75% of the Starter plan limit. Upgrade to ensure there are no service disruptions.`;
message = `Usage for <b>${org.name}</b> has reached 75% of the ${tierToPlan(BillingPlan.FREE).name} plan limit. Upgrade to ensure there are no service disruptions.`;
}
addNotification({
type: 'warning',
Expand Down Expand Up @@ -255,7 +255,7 @@ export async function checkForUsageLimit(org: Organization) {
}

export async function checkPaymentAuthorizationRequired(org: Organization) {
if (org.billingPlan === BillingPlan.STARTER) return;
if (org.billingPlan === BillingPlan.FREE) return;

const invoices = await sdk.forConsole.billing.listInvoices(org.$id, [
Query.equal('status', 'requires_authentication')
Expand Down Expand Up @@ -351,7 +351,7 @@ export async function checkForMandate(org: Organization) {

export async function checkForMissingPaymentMethod() {
const orgs = await sdk.forConsole.billing.listOrganization([
Query.notEqual('billingPlan', BillingPlan.STARTER),
Query.notEqual('billingPlan', BillingPlan.FREE),
Query.isNull('paymentMethodId'),
Query.isNull('backupPaymentMethodId')
]);
Expand Down
18 changes: 12 additions & 6 deletions src/routes/console/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
await goto(`/console/project-${$project.$id}/auth/security#${heading}`);
scrollBy({ top: -100 });
},
disabled: !$project?.$id,
group: 'security',
icon: 'pencil'
}) as const
Expand All @@ -161,7 +162,8 @@
callback: () => {
goto(`/console/project-${$project.$id}/settings`);
},
disabled: isOnSettingsLayout && $page.url.pathname.endsWith('settings'),
disabled:
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.endsWith('settings')),
group: isOnSettingsLayout ? 'navigation' : 'settings',
rank: isOnSettingsLayout ? 40 : -1
},
Expand All @@ -172,7 +174,8 @@
callback: () => {
goto(`/console/project-${$project.$id}/settings/domains`);
},
disabled: isOnSettingsLayout && $page.url.pathname.includes('domains'),
disabled:
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('domains')),
group: isOnSettingsLayout ? 'navigation' : 'settings',
rank: isOnSettingsLayout ? 30 : -1
},
Expand All @@ -182,7 +185,8 @@
callback: () => {
goto(`/console/project-${$project.$id}/settings/webhooks`);
},
disabled: isOnSettingsLayout && $page.url.pathname.includes('webhooks'),
disabled:
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('webhooks')),
group: isOnSettingsLayout ? 'navigation' : 'settings',
rank: isOnSettingsLayout ? 20 : -1
Expand All @@ -193,7 +197,8 @@
callback: () => {
goto(`/console/project-${$project.$id}/settings/migrations`);
},
disabled: isOnSettingsLayout && $page.url.pathname.includes('migrations'),
disabled:
!$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('migrations')),
group: isOnSettingsLayout ? 'navigation' : 'settings',
rank: isOnSettingsLayout ? 10 : -1
Expand All @@ -202,9 +207,10 @@
label: 'Go to SMTP settings',
keys: isOnSettingsLayout ? ['g', 's'] : undefined,
callback: () => {
console.log('withing callback of go to smtp');
goto(`/console/project-${$project.$id}/settings/smtp`);
},
disabled: isOnSettingsLayout && $page.url.pathname.includes('smtp'),
disabled: !$project?.$id || (isOnSettingsLayout && $page.url.pathname.includes('smtp')),
group: isOnSettingsLayout ? 'navigation' : 'settings',
rank: -1
},
Expand Down Expand Up @@ -260,7 +266,7 @@
if (isCloud) {
await checkForUsageLimit(org);
checkForMarkedForDeletion(org);
if (org?.billingPlan !== BillingPlan.STARTER) {
if (org?.billingPlan !== BillingPlan.FREE) {
await paymentExpired(org);
await checkPaymentAuthorizationRequired(org);
await checkForMandate(org);
Expand Down
4 changes: 2 additions & 2 deletions src/routes/console/account/organizations/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</svelte:fragment>
<svelte:fragment slot="status">
{#if isCloudOrg(organization)}
{#if organization?.billingPlan === BillingPlan.STARTER}
{#if organization?.billingPlan === BillingPlan.FREE}
<div
class="u-flex u-cross-center"
use:tooltip={{
Expand All @@ -81,7 +81,7 @@
<Pill>FREE</Pill>
</div>
{/if}
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.STARTER && $plansInfo.get(organization.billingPlan)?.trialDays}
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays}
<div
class="u-flex u-cross-center"
use:tooltip={{
Expand Down
Loading

0 comments on commit d2011db

Please sign in to comment.