From 1b0d94372155053977b9d881fd9e6319dc9a6f27 Mon Sep 17 00:00:00 2001
From: Ananya Nayak
Date: Mon, 19 Jun 2023 08:58:26 +0000
Subject: [PATCH 01/97] ci: added paths-ignore option
---
.github/workflows/tests.yml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index aaac70173..4abdcee24 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -3,8 +3,18 @@ name: Tests
on:
push:
branches: [main]
+ paths-ignore:
+ - "**/*.md"
+ - ".prettierrc"
+ - ".npmrc"
+ - ".gitignore"
pull_request:
branches: [main]
+ paths-ignore:
+ - "**/*.md"
+ - ".prettierrc"
+ - ".npmrc"
+ - ".gitignore"
env:
VITE_APPWRITE_ENDPOINT: http://appwrite.test/v1
From c53c845641f25c55cc5a78ec8567cd2891948b37 Mon Sep 17 00:00:00 2001
From: Ananya Nayak
Date: Sun, 13 Aug 2023 10:41:58 +0530
Subject: [PATCH 02/97] ci: ignore assets during tests workflow
---
.github/workflows/tests.yml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 4abdcee24..76ba7543a 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,6 +8,10 @@ on:
- ".prettierrc"
- ".npmrc"
- ".gitignore"
+ - ".env.example"
+ - ".eslintrc.cjs"
+ - ".eslintignore"
+ - "static/*"
pull_request:
branches: [main]
paths-ignore:
@@ -15,6 +19,10 @@ on:
- ".prettierrc"
- ".npmrc"
- ".gitignore"
+ - ".env.example"
+ - ".eslintrc.cjs"
+ - ".eslintignore"
+ - "static/*"
env:
VITE_APPWRITE_ENDPOINT: http://appwrite.test/v1
From adbbe45b568c5ed6ec63592281a5e63fbf50679d Mon Sep 17 00:00:00 2001
From: Ananya Nayak
Date: Sun, 13 Aug 2023 10:41:58 +0530
Subject: [PATCH 03/97] ci: ignore assets during tests workflow
---
.github/workflows/tests.yml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 4abdcee24..aca5daad5 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,6 +8,10 @@ on:
- ".prettierrc"
- ".npmrc"
- ".gitignore"
+ - ".env.example"
+ - ".eslintrc.cjs"
+ - ".eslintignore"
+ - "static/**/*"
pull_request:
branches: [main]
paths-ignore:
@@ -15,6 +19,10 @@ on:
- ".prettierrc"
- ".npmrc"
- ".gitignore"
+ - ".env.example"
+ - ".eslintrc.cjs"
+ - ".eslintignore"
+ - "static/**/*"
env:
VITE_APPWRITE_ENDPOINT: http://appwrite.test/v1
From 6c0683f4035fb01efa82bec5899d0536d7867741 Mon Sep 17 00:00:00 2001
From: Amit Gurbani
Date: Fri, 20 Oct 2023 20:44:48 +0530
Subject: [PATCH 04/97] Fix: Clear Datetime Attribute
---
src/lib/elements/forms/inputDateTime.svelte | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/lib/elements/forms/inputDateTime.svelte b/src/lib/elements/forms/inputDateTime.svelte
index cd13a5f65..15eeaf2ae 100644
--- a/src/lib/elements/forms/inputDateTime.svelte
+++ b/src/lib/elements/forms/inputDateTime.svelte
@@ -6,7 +6,7 @@
export let showLabel = true;
export let optionalText: string | undefined = undefined;
export let id: string;
- export let value = '';
+ export let value: string;
export let required = false;
export let disabled = false;
export let readonly = false;
@@ -33,6 +33,11 @@
error = element.validationMessage;
}
+ function handleInput(event: Event) {
+ const { value: currentValue } = event.currentTarget as HTMLInputElement;
+ value = currentValue || null;
+ }
+
$: if (value) {
error = null;
}
@@ -49,12 +54,13 @@
{disabled}
{readonly}
{required}
+ {value}
step=".001"
autocomplete={autocomplete ? 'on' : 'off'}
type="datetime-local"
class="input-text"
- bind:value
bind:this={element}
+ on:input={handleInput}
on:invalid={handleInvalid} />
{#if error}
From 3456c58710c3b9c6079078972c5e5fcb0df4f18a Mon Sep 17 00:00:00 2001
From: Torsten Dittmann
Date: Tue, 7 Nov 2023 13:59:17 +0100
Subject: [PATCH 05/97] draft: cookie consent
---
src/lib/components/consent.svelte | 133 ++++++++++++++++++++++++++++++
src/routes/+layout.svelte | 2 +
2 files changed, 135 insertions(+)
create mode 100644 src/lib/components/consent.svelte
diff --git a/src/lib/components/consent.svelte b/src/lib/components/consent.svelte
new file mode 100644
index 000000000..739695e69
--- /dev/null
+++ b/src/lib/components/consent.svelte
@@ -0,0 +1,133 @@
+
+
+{#if show}
+
+
+ By clicking "Accept all", you agree to the storing of cookies on your device to analyze
+ site usage.
+
+
+
+
+ (settings = true)}>Cookie settings
+
+
+ Only required
+ Accept all
+
+
+
+{/if}
+
+{#if settings}
+
+
+ We use cookies to improve your site experience. The "strictly necessary" cookies are
+ required for Appwrite to function.
+
+
+
+
+
+
+ Strictly Necessary Cookies
+
+
+
+
+
+
+ These are the cookies required for Appwrite to function.
+
+
+
+
+
+
+
+
+ Product Analytics
+ (optional)
+
+
+
+
+
+
+ We include analytics cookies to understand how you use our product and
+ design better experiences.
+
+
+
+
+
+
+ confirmChoices(selected)} text>Confirm my choices
+ Only required
+ Allow all
+
+
+{/if}
+
+
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index ef73495de..e9ca9e41f 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -16,6 +16,7 @@
import Loading from './loading.svelte';
import { loading, requestedMigration } from './store';
import { parseIfString } from '$lib/helpers/object';
+ import Consent from '$lib/components/consent.svelte';
if (browser) {
window.VERCEL_ANALYTICS_ID = import.meta.env.VERCEL_ANALYTICS_ID?.toString() ?? false;
@@ -124,6 +125,7 @@
+
From 2ccd44316a57781cf0ea8ed4cc0858377b89289c Mon Sep 17 00:00:00 2001
From: Elad Shechter
Date: Thu, 14 Dec 2023 11:59:34 +0700
Subject: [PATCH 06/97] Floating Action Bar - Was using old variable color name
and was transparent. Now got the updated color names variables
---
src/lib/components/floatingActionBar.svelte | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/lib/components/floatingActionBar.svelte b/src/lib/components/floatingActionBar.svelte
index 066852314..28b7a8e3b 100644
--- a/src/lib/components/floatingActionBar.svelte
+++ b/src/lib/components/floatingActionBar.svelte
@@ -26,13 +26,13 @@
}
:global(.theme-dark) .floating-action-bar {
- border: 1px solid hsl(var(--color-neutral-200));
- background: hsl(var(--color-neutral-300));
+ border: 1px solid hsl(var(--color-neutral-85));
+ background: hsl(var(--color-neutral-90));
box-shadow: 0px 6px 16px 8px #14141f;
}
:global(.theme-light) .floating-action-bar {
- border: 1px solid hsl(var(--color-neutral-30));
+ border: 1px solid hsl(var(--color-neutral-15));
background: hsl(var(--color-neutral-0));
box-shadow: 0px 6px 16px 0px rgba(55, 59, 77, 0.14);
}
From 316ae87a663e3523e45ad10954e2ba5ccd8c2304 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 10:28:35 +0100
Subject: [PATCH 07/97] fix: usage page broken when no projects
---
.../organization-[organization]/usage/[[invoice]]/+page.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts
index 8f5203de9..b1ef9a272 100644
--- a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts
+++ b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts
@@ -43,7 +43,7 @@ export const load: PageLoad = async ({ params, parent }) => {
const queries: string[] = [];
- if (usage.projects.length > 0) {
+ if (usage?.projects?.length > 0) {
queries.push(
Query.equal(
'$id',
From 759cf2b924cb2aa2ea4327fb596b23cff6a42258 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 10:32:01 +0100
Subject: [PATCH 08/97] fix: `de` to `fra`
---
src/lib/sdk/billing.ts | 2 +-
src/routes/console/onboarding/+page.svelte | 2 +-
.../organization-[organization]/createProjectCloud.svelte | 2 +-
src/routes/console/organization-[organization]/wizard/store.ts | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 7f535263d..32f6f0a2b 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -185,7 +185,7 @@ export type AggregationList = {
};
export type AllowedRegions =
- | 'eu-de'
+ | 'eu-fra'
| 'us-nyc'
| 'us-sfo'
| 'ap-in'
diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte
index 244d86136..c2b26314e 100644
--- a/src/routes/console/onboarding/+page.svelte
+++ b/src/routes/console/onboarding/+page.svelte
@@ -39,7 +39,7 @@
id ?? ID.unique(),
name,
org.$id,
- isCloud ? 'eu-de' : 'default'
+ isCloud ? 'eu-fra' : 'default'
);
await invalidate(Dependencies.ACCOUNT);
goto(`/console/project-${project.$id}`);
diff --git a/src/routes/console/organization-[organization]/createProjectCloud.svelte b/src/routes/console/organization-[organization]/createProjectCloud.svelte
index 03dc414a8..6128fea00 100644
--- a/src/routes/console/organization-[organization]/createProjectCloud.svelte
+++ b/src/routes/console/organization-[organization]/createProjectCloud.svelte
@@ -52,7 +52,7 @@
$createProject = {
id: null,
name: null,
- region: 'eu-de'
+ region: 'eu-fra'
};
});
diff --git a/src/routes/console/organization-[organization]/wizard/store.ts b/src/routes/console/organization-[organization]/wizard/store.ts
index d171e8202..5bcbc4472 100644
--- a/src/routes/console/organization-[organization]/wizard/store.ts
+++ b/src/routes/console/organization-[organization]/wizard/store.ts
@@ -7,5 +7,5 @@ export const createProject = writable<{
}>({
id: null,
name: null,
- region: 'eu-de'
+ region: 'eu-fra'
});
From e1a70395a799713587b8170926564089f4b7e17b Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 10:39:49 +0100
Subject: [PATCH 09/97] fix: regions
---
src/lib/sdk/billing.ts | 18 +++++++++---------
src/routes/console/onboarding/+page.svelte | 2 +-
.../createProjectCloud.svelte | 2 +-
.../wizard/store.ts | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 32f6f0a2b..31c2a0797 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -185,15 +185,15 @@ export type AggregationList = {
};
export type AllowedRegions =
- | 'eu-fra'
- | 'us-nyc'
- | 'us-sfo'
- | 'ap-in'
- | 'eu-gb'
- | 'eu-nl'
- | 'ap-sg'
- | 'ap-ca'
- | 'ap-au'
+ | 'fra'
+ | 'nyc'
+ | 'sfo'
+ | 'blr'
+ | 'lon'
+ | 'ams'
+ | 'sgp'
+ | 'tor'
+ | 'syd'
| 'default'; //TODO: remove after migration
export type Region = {
diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte
index c2b26314e..5cf93944c 100644
--- a/src/routes/console/onboarding/+page.svelte
+++ b/src/routes/console/onboarding/+page.svelte
@@ -39,7 +39,7 @@
id ?? ID.unique(),
name,
org.$id,
- isCloud ? 'eu-fra' : 'default'
+ isCloud ? 'fra' : 'default'
);
await invalidate(Dependencies.ACCOUNT);
goto(`/console/project-${project.$id}`);
diff --git a/src/routes/console/organization-[organization]/createProjectCloud.svelte b/src/routes/console/organization-[organization]/createProjectCloud.svelte
index 6128fea00..7072e6b0f 100644
--- a/src/routes/console/organization-[organization]/createProjectCloud.svelte
+++ b/src/routes/console/organization-[organization]/createProjectCloud.svelte
@@ -52,7 +52,7 @@
$createProject = {
id: null,
name: null,
- region: 'eu-fra'
+ region: 'fra'
};
});
diff --git a/src/routes/console/organization-[organization]/wizard/store.ts b/src/routes/console/organization-[organization]/wizard/store.ts
index 5bcbc4472..d79bd1ded 100644
--- a/src/routes/console/organization-[organization]/wizard/store.ts
+++ b/src/routes/console/organization-[organization]/wizard/store.ts
@@ -7,5 +7,5 @@ export const createProject = writable<{
}>({
id: null,
name: null,
- region: 'eu-fra'
+ region: 'fra'
});
From 2adcafa470fe9ada07481dc8947208507402d30b Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 12:23:21 +0100
Subject: [PATCH 10/97] fix: credit under zero
---
.../wizard/cloudOrganizationChangeTier/confirmDetails.svelte | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
index db1e8b24a..03e529630 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
@@ -125,7 +125,9 @@
Estimated total
${couponData?.status === 'active'
- ? totalExpences - couponData.credits || 0
+ ? totalExpences - couponData.credits >= 0
+ ? totalExpences - couponData.credits
+ : 0
: totalExpences}
From 18c9275a865aea171a9f1dfec17a4df9a54c7e4d Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 12:50:49 +0100
Subject: [PATCH 11/97] refactor: add billing id to create and upgrade org
---
src/lib/sdk/billing.ts | 12 ++++--
src/lib/stores/billing.ts | 1 +
.../changeOrganizationTierCloud.svelte | 41 ++-----------------
.../console/createOrganizationCloud.svelte | 37 +----------------
.../cloudOrganization/addressDetails.svelte | 40 ++++++++++++++----
.../console/wizard/cloudOrganization/store.ts | 11 -----
.../addressDetails.svelte | 40 ++++++++++++++----
.../cloudOrganizationChangeTier/store.ts | 11 -----
8 files changed, 79 insertions(+), 114 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 31c2a0797..8773bb77b 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -276,14 +276,16 @@ export class Billing {
organizationId: string,
name: string,
billingPlan: string,
- paymentMethodId: string
+ paymentMethodId: string,
+ billingAddressId: string
): Promise {
const path = `/organizations`;
const params = {
organizationId,
name,
billingPlan,
- paymentMethodId
+ paymentMethodId,
+ billingAddressId
};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
@@ -331,13 +333,15 @@ export class Billing {
async updatePlan(
organizationId: string,
billingPlan: string,
- paymentMethodId: string
+ paymentMethodId: string,
+ billingAddressId: string
): Promise {
const path = `/organizations/${organizationId}/plan`;
const params = {
organizationId,
billingPlan,
- paymentMethodId
+ paymentMethodId,
+ billingAddressId
};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index d139f71c6..63d6b4dfa 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -283,6 +283,7 @@ export async function checkForFreeOrgOverflow(orgs: Models.TeamList>) {
diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte
index a4001b887..64afb5bc2 100644
--- a/src/routes/console/changeOrganizationTierCloud.svelte
+++ b/src/routes/console/changeOrganizationTierCloud.svelte
@@ -40,7 +40,8 @@
await sdk.forConsole.billing.updatePlan(
$organization.$id,
$changeOrganizationTier.billingPlan,
- $changeOrganizationTier.paymentMethodId
+ $changeOrganizationTier.paymentMethodId,
+ $changeOrganizationTier.billingAddressId
);
feedback.submitFeedback(
'downgrade',
@@ -78,35 +79,10 @@
const org = await sdk.forConsole.billing.updatePlan(
$organization.$id,
$changeOrganizationTier.billingPlan,
- $changeOrganizationTier.paymentMethodId
+ $changeOrganizationTier.paymentMethodId,
+ $changeOrganizationTier.billingAddressId
);
- //Add billing address
- if ($changeOrganizationTier.billingAddressId) {
- await sdk.forConsole.billing.setBillingAddress(
- org.$id,
- $changeOrganizationTier.billingAddressId
- );
- } else if (
- $changeOrganizationTier.billingAddress &&
- $changeOrganizationTier.billingAddress.streetAddress
- ) {
- const response = await sdk.forConsole.billing.createAddress(
- $changeOrganizationTier.billingAddress.country,
- $changeOrganizationTier.billingAddress.streetAddress,
- $changeOrganizationTier.billingAddress.city,
- $changeOrganizationTier.billingAddress.state,
- $changeOrganizationTier.billingAddress.postalCode
- ? $changeOrganizationTier.billingAddress.postalCode
- : undefined,
- $changeOrganizationTier.billingAddress.addressLine2
- ? $changeOrganizationTier.billingAddress.addressLine2
- : undefined
- );
-
- await sdk.forConsole.billing.setBillingAddress(org.$id, response.$id);
- }
-
//Add coupon
if ($changeOrganizationTier.couponCode) {
await sdk.forConsole.billing.addCredit(
@@ -193,15 +169,6 @@
paymentMethodId: null,
collaborators: [],
billingAddressId: null,
- billingAddress: {
- $id: null,
- streetAddress: null,
- addressLine2: null,
- city: null,
- state: null,
- postalCode: null,
- country: null
- },
taxId: null,
feedbackMessage: null
};
diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte
index 9e958a28c..8c0fb58f7 100644
--- a/src/routes/console/createOrganizationCloud.svelte
+++ b/src/routes/console/createOrganizationCloud.svelte
@@ -32,33 +32,9 @@
$createOrganization.id ?? ID.unique(),
$createOrganization.name,
$createOrganization.billingPlan,
- $createOrganization.paymentMethodId
+ $createOrganization.paymentMethodId,
+ $createOrganization.billingAddressId
);
- //Add billing address
- if ($createOrganization.billingAddressId) {
- await sdk.forConsole.billing.setBillingAddress(
- org.$id,
- $createOrganization.billingAddressId
- );
- } else if (
- $createOrganization.billingAddress &&
- $createOrganization.billingAddress.streetAddress
- ) {
- const response = await sdk.forConsole.billing.createAddress(
- $createOrganization.billingAddress.country,
- $createOrganization.billingAddress.streetAddress,
- $createOrganization.billingAddress.city,
- $createOrganization.billingAddress.state,
- $createOrganization.billingAddress.postalCode
- ? $createOrganization.billingAddress.postalCode
- : undefined,
- $createOrganization.billingAddress.addressLine2
- ? $createOrganization.billingAddress.addressLine2
- : undefined
- );
-
- await sdk.forConsole.billing.setBillingAddress(org.$id, response.$id);
- }
//Add budget
if ($createOrganization?.billingBudget) {
@@ -121,15 +97,6 @@
paymentMethodId: null,
collaborators: [],
billingAddressId: null,
- billingAddress: {
- $id: null,
- streetAddress: null,
- addressLine2: null,
- city: null,
- state: null,
- postalCode: null,
- country: null
- },
taxId: null
};
});
diff --git a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
index af7cbce05..608833f9c 100644
--- a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
@@ -14,6 +14,30 @@
}
];
let addressList: AddressesList;
+ let country: string;
+ let streetAddress: string;
+ let city: string;
+ let state: string;
+ let postalCode: string;
+ let addressLine2: string;
+
+ async function handleAddress() {
+ if (!$createOrganization.billingAddressId) {
+ try {
+ const response = await sdk.forConsole.billing.createAddress(
+ country,
+ streetAddress,
+ city,
+ state,
+ postalCode ? postalCode : undefined,
+ addressLine2 ? addressLine2 : undefined
+ );
+ $createOrganization.billingAddressId = response.$id;
+ } catch (error) {
+ throw new Error(error.message);
+ }
+ }
+ }
onMount(async () => {
addressList = await sdk.forConsole.billing.listAddresses();
@@ -21,7 +45,7 @@
const countryList = await sdk.forProject.locale.listCountries();
const locale = await sdk.forProject.locale.get();
if (locale?.countryCode) {
- $createOrganization.billingAddress.country = locale.countryCode;
+ country = locale.countryCode;
}
options = countryList.countries.map((country) => {
return {
@@ -32,7 +56,7 @@
});
-
+
Billing address
Add a billing address for your organization.
@@ -70,25 +94,25 @@
placeholder="Enter tax ID"
optionalText="(optional)" />
diff --git a/src/routes/console/wizard/cloudOrganization/store.ts b/src/routes/console/wizard/cloudOrganization/store.ts
index 7c1247fe3..481924e9d 100644
--- a/src/routes/console/wizard/cloudOrganization/store.ts
+++ b/src/routes/console/wizard/cloudOrganization/store.ts
@@ -1,5 +1,4 @@
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
-import type { Address } from '$lib/sdk/billing';
import type { Tier } from '$lib/stores/billing';
import { writable } from 'svelte/store';
@@ -12,7 +11,6 @@ export const createOrganization = writable<{
billingPlan: Tier;
paymentMethodId: string;
billingAddressId: string;
- billingAddress?: Address;
collaborators?: string[];
billingBudget?: number;
taxId?: string;
@@ -23,14 +21,5 @@ export const createOrganization = writable<{
paymentMethodId: null,
collaborators: [],
billingAddressId: null,
- billingAddress: {
- $id: null,
- streetAddress: null,
- addressLine2: null,
- city: null,
- state: null,
- postalCode: null,
- country: null
- },
taxId: null
});
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte
index 03861a9c0..5bd9ebaf5 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte
@@ -15,6 +15,30 @@
}
];
let addressList: AddressesList;
+ let country: string;
+ let streetAddress: string;
+ let city: string;
+ let state: string;
+ let postalCode: string;
+ let addressLine2: string;
+
+ async function handleAddress() {
+ if (!$changeOrganizationTier.billingAddressId) {
+ try {
+ const response = await sdk.forConsole.billing.createAddress(
+ country,
+ streetAddress,
+ city,
+ state,
+ postalCode ? postalCode : undefined,
+ addressLine2 ? addressLine2 : undefined
+ );
+ $changeOrganizationTier.billingAddressId = response.$id;
+ } catch (error) {
+ throw new Error(error.message);
+ }
+ }
+ }
onMount(async () => {
addressList = await sdk.forConsole.billing.listAddresses();
@@ -23,7 +47,7 @@
: addressList.billingAddresses?.[0]?.$id ?? null;
const locale = await sdk.forProject.locale.get();
if (locale?.countryCode && !$changeOrganizationTier.billingAddressId) {
- $changeOrganizationTier.billingAddress.country = locale.countryCode;
+ country = locale.countryCode;
}
const countryList = await sdk.forProject.locale.listCountries();
options = countryList.countries.map((country) => {
@@ -35,7 +59,7 @@
});
-
+
Billing address
Add a billing address for your organization.
@@ -73,25 +97,25 @@
placeholder="Enter tax ID"
optionalText="(optional)" />
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
index 25f69bf5d..0721a89c3 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
@@ -1,5 +1,4 @@
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
-import type { Address } from '$lib/sdk/billing';
import type { Tier } from '$lib/stores/billing';
import { writable } from 'svelte/store';
@@ -12,7 +11,6 @@ export const changeOrganizationTier = writable<{
billingPlan: Tier;
paymentMethodId: string;
billingAddressId: string;
- billingAddress?: Address;
billingBudget?: number;
collaborators?: string[];
isOverLimit?: boolean;
@@ -33,14 +31,5 @@ export const changeOrganizationTier = writable<{
collaborators: [],
isOverLimit: false,
billingAddressId: null,
- billingAddress: {
- $id: null,
- streetAddress: null,
- addressLine2: null,
- city: null,
- state: null,
- postalCode: null,
- country: null
- },
taxId: null
});
From d715b80b1c611651f1a10197942e09cb91537f2e Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 13:05:15 +0100
Subject: [PATCH 12/97] fix: error check
---
src/routes/console/onboarding/+page.svelte | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte
index 5cf93944c..55ebefea7 100644
--- a/src/routes/console/onboarding/+page.svelte
+++ b/src/routes/console/onboarding/+page.svelte
@@ -62,6 +62,7 @@
ID.unique(),
'Personal Projects',
'tier-0',
+ null,
null
);
} else return await sdk.forConsole.teams.create(ID.unique(), 'Personal Projects');
From 0a40599b6d126a687b07946e1fe2c3617ef6db44 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 15:41:43 +0100
Subject: [PATCH 13/97] fix: github login route
---
src/routes/login/+page.svelte | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte
index 7d4da5a0d..a46062288 100644
--- a/src/routes/login/+page.svelte
+++ b/src/routes/login/+page.svelte
@@ -61,10 +61,12 @@
url = `${base}/console${$page.url.search ?? ''}`;
}
}
- sdk.forConsole.account.createOAuth2Session('github', url, window.location.origin, [
- 'read:user',
- 'user:email'
- ]);
+ sdk.forConsole.account.createOAuth2Session(
+ 'github',
+ window.location.origin + url,
+ window.location.origin,
+ ['read:user', 'user:email']
+ );
}
From 1ca379f01b77fb9d880b7474fca7b76b7f283c89 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 15:56:20 +0100
Subject: [PATCH 14/97] fix: org presistency when switchin org
---
src/routes/console/organization-[organization]/+layout.ts | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/routes/console/organization-[organization]/+layout.ts b/src/routes/console/organization-[organization]/+layout.ts
index aea1df5dd..16c152cfe 100644
--- a/src/routes/console/organization-[organization]/+layout.ts
+++ b/src/routes/console/organization-[organization]/+layout.ts
@@ -9,6 +9,7 @@ import Header from './header.svelte';
import { headerAlert } from '$lib/stores/headerAlert';
import ProjectsAtRisk from '$lib/components/billing/alerts/projectsAtRisk.svelte';
import { get } from 'svelte/store';
+import { preferences } from '$lib/stores/preferences';
export const load: LayoutLoad = async ({ params, depends }) => {
depends(Dependencies.ORGANIZATION);
@@ -28,6 +29,10 @@ export const load: LayoutLoad = async ({ params, depends }) => {
}
try {
+ const prefs = await sdk.forConsole.account.getPrefs();
+ const newPrefs = { ...prefs, organization: params.organization };
+ sdk.forConsole.account.updatePrefs(newPrefs);
+ preferences.loadTeamPrefs(params.organization);
return {
header: Header,
breadcrumbs: Breadcrumbs,
@@ -35,6 +40,9 @@ export const load: LayoutLoad = async ({ params, depends }) => {
members: await sdk.forConsole.teams.listMemberships(params.organization)
};
} catch (e) {
+ const prefs = await sdk.forConsole.account.getPrefs();
+ const newPrefs = { ...prefs, organization: '' };
+ sdk.forConsole.account.updatePrefs(newPrefs);
localStorage.removeItem('organization');
throw error(e.code, e.message);
}
From 94b14d1d83f80e2319437599156ad4448a39a873 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 16:01:58 +0100
Subject: [PATCH 15/97] fix: only throw error message
---
src/lib/stores/stripe.ts | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lib/stores/stripe.ts b/src/lib/stores/stripe.ts
index c0ba12ef8..4f81173de 100644
--- a/src/lib/stores/stripe.ts
+++ b/src/lib/stores/stripe.ts
@@ -71,7 +71,7 @@ export async function submitStripeCard(name: string, urlRoute?: string) {
if (error) {
const e = new Error(error.message);
trackError(e, Submit.PaymentMethodCreate);
- throw error;
+ throw e;
}
if (setupIntent && setupIntent.status === 'succeeded') {
@@ -87,11 +87,11 @@ export async function submitStripeCard(name: string, urlRoute?: string) {
} else {
const e = new Error('Something went wrong');
trackError(e, Submit.PaymentMethodCreate);
- throw e;
+ throw e.message;
}
} catch (e) {
trackError(e, Submit.PaymentMethodCreate);
- throw e;
+ throw e.message;
}
}
@@ -109,7 +109,7 @@ export async function confirmPayment(orgId: string, clientSecret: string, paymen
}
});
if (error) {
- throw new Error();
+ throw error.message;
}
} catch (e) {
addNotification({
From 872ae79c9d6c2422fd2458aa73b1a8b46d60a862 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 16:12:56 +0100
Subject: [PATCH 16/97] fix: header alert too many free orgs
---
.../components/billing/alerts/tooManyFreeOrgs.svelte | 11 ++++-------
src/lib/stores/billing.ts | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
index f5fa340d4..5cd439e86 100644
--- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
+++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
@@ -1,11 +1,8 @@
-{#if $failedInvoice}
-
- All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024 .
- You can add a payment method or transfer projects from your settings.
-
-{/if}
+
+ All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024 . You
+ can add a payment method or transfer projects from your settings.
+
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 63d6b4dfa..ea24fff91 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -282,8 +282,8 @@ export async function checkForFreeOrgOverflow(orgs: Models.TeamList>) {
From 206c3ee3c9f22dda3da665c616b93a46530b84c1 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 16:44:53 +0100
Subject: [PATCH 17/97] fix: show upgrade cta only to free users
---
src/lib/layout/activity.svelte | 7 +++++--
src/lib/layout/logs.svelte | 16 +++++++++-------
.../functions/function-[function]/+page.svelte | 9 ++++-----
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/lib/layout/activity.svelte b/src/lib/layout/activity.svelte
index 03d0577b2..908ab6b8a 100644
--- a/src/lib/layout/activity.svelte
+++ b/src/lib/layout/activity.svelte
@@ -21,6 +21,7 @@
import { tierToPlan, type PlanServices } from '$lib/stores/billing';
import { isCloud } from '$lib/system';
import { organization } from '$lib/stores/organization';
+ import { Button } from '$lib/elements/forms';
export let logs: Models.LogList;
export let offset = 0;
@@ -50,8 +51,10 @@
Logs are retained in rolling {hoursToDays(limit)} intervals with the
{tierToPlan($organization.billingPlan).name}
plan.
- Upgrade to increase your log retention for a longer period.
+ {#if $organization?.billingPlan === 'tier-0'}
+ Upgrade to increase your log
+ retention for a longer period.
+ {/if}
{#each logs.logs as log}
diff --git a/src/lib/layout/logs.svelte b/src/lib/layout/logs.svelte
index a7abce0c4..19be13b4c 100644
--- a/src/lib/layout/logs.svelte
+++ b/src/lib/layout/logs.svelte
@@ -19,6 +19,7 @@
import { getServiceLimit, tierToPlan } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { app } from '$lib/stores/app';
+ import { Button } from '$lib/elements/forms';
let selectedRequest = 'parameters';
let selectedResponse = 'logs';
@@ -310,13 +311,14 @@
Logs are retained in rolling {hoursToDays(limit)} intervals
with the {tier} plan.
-
- wizard.start(ChangeOrganizationTierCloud)}
- >Upgrade to increase your log retention for
- a longer period.
+ {#if $organization.billingPlan === 'tier-0'}
+
+ wizard.start(ChangeOrganizationTierCloud)}
+ >Upgrade to increase your log retention
+ for a longer period.
+ {/if}
{/if}
diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte
index da05c0b6f..5f32548a1 100644
--- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte
+++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte
@@ -221,11 +221,10 @@
Logs are retained in rolling {hoursToDays(limit)} intervals with the
{tierToPlan($organization.billingPlan).name}
plan.
- Upgrade to increase
- your log retention for a longer period.
+ {#if $organization.billingPlan === 'tier-0'}
+ Upgrade to increase
+ your log retention for a longer period.
+ {/if}
{#each $deploymentList.deployments as deployment, index (deployment.$id)}
From 4996b49b2fbc0bb3b4a01f8184bbee5735d78f4a Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 16:47:28 +0100
Subject: [PATCH 18/97] fix: remove warning in deployment page
---
.../functions/function-[function]/+page.svelte | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte
index 5f32548a1..1462e407d 100644
--- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte
+++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte
@@ -40,9 +40,7 @@
import DeploymentCreatedBy from './deploymentCreatedBy.svelte';
import DeploymentDomains from './deploymentDomains.svelte';
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
- import { readOnly, tierToPlan } from '$lib/stores/billing';
- import { hoursToDays } from '$lib/helpers/date';
- import { organization } from '$lib/stores/organization';
+ import { readOnly } from '$lib/stores/billing';
export let data;
@@ -215,18 +213,7 @@
Size
-
-
-
- Logs are retained in rolling {hoursToDays(limit)} intervals with the
- {tierToPlan($organization.billingPlan).name}
- plan.
- {#if $organization.billingPlan === 'tier-0'}
- Upgrade to increase
- your log retention for a longer period.
- {/if}
-
-
+
{#each $deploymentList.deployments as deployment, index (deployment.$id)}
{@const status = deployment.status}
From 52038f1389a6f1db114dd1f3cd892307851ec946 Mon Sep 17 00:00:00 2001
From: Arman
Date: Wed, 20 Dec 2023 17:30:44 +0100
Subject: [PATCH 19/97] fix: add cta to tooManyFreeOrg header alert
---
src/lib/components/billing/alerts/tooManyFreeOrgs.svelte | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
index 5cd439e86..4f02244ae 100644
--- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
+++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
@@ -1,8 +1,13 @@
All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024 . You
can add a payment method or transfer projects from your settings.
+
+
+ View organizations
+
From 0b3f30dedccf167ef1a6385cd232c116e699f1a8 Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 10:54:00 +0100
Subject: [PATCH 20/97] fix: project usage dropdown
---
src/lib/components/cardGrid.svelte | 2 +-
src/lib/components/collapsibleItem.svelte | 2 +-
.../usage/[[invoice]]/ProjectBreakdown.svelte | 50 +++++++++----------
3 files changed, 26 insertions(+), 28 deletions(-)
diff --git a/src/lib/components/cardGrid.svelte b/src/lib/components/cardGrid.svelte
index 33dff20d1..67e0d2ad4 100644
--- a/src/lib/components/cardGrid.svelte
+++ b/src/lib/components/cardGrid.svelte
@@ -10,7 +10,7 @@
-
diff --git a/src/lib/components/collapsibleItem.svelte b/src/lib/components/collapsibleItem.svelte
index cd44bc824..8397454dc 100644
--- a/src/lib/components/collapsibleItem.svelte
+++ b/src/lib/components/collapsibleItem.svelte
@@ -9,7 +9,7 @@
Project breakdown
-
-
-
- Project
- Usage
-
-
-
- {#each groupByProject(metric).sort((a, b) => b.usage - a.usage) as project}
-
-
- {getProjectName(project.projectId)}
-
- {format(project.usage)}
-
- View project usage
-
-
- {/each}
-
-
-
+
+
+ Project
+ Usage
+
+
+
+ {#each groupByProject(metric).sort((a, b) => b.usage - a.usage) as project}
+
+
+ {getProjectName(project.projectId)}
+
+ {format(project.usage)}
+
+ View project usage
+
+
+ {/each}
+
+
From 5a7598df2aadca8c6f6b2d4148b03a885ef2e61b Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 12:11:01 +0100
Subject: [PATCH 21/97] fix: upgrade flow
---
.../cloudOrganizationChangeTier/choosePlan.svelte | 4 ++--
.../cloudOrganizationChangeTier/inviteMembers.svelte | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
index e1aea276e..64d01a71c 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
@@ -64,10 +64,10 @@
$changeOrganizationTier.limitOverflow.members > 0
) {
$changeOrganizationTier.isOverLimit = true;
- $changeTierSteps = updateStepStatus($changeTierSteps, 4, false);
+ $changeTierSteps = updateStepStatus($changeTierSteps, 5, false);
} else {
$changeOrganizationTier.isOverLimit = false;
- $changeTierSteps = updateStepStatus($changeTierSteps, 4, true);
+ $changeTierSteps = updateStepStatus($changeTierSteps, 5, true);
}
}
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
index 61a5f1154..b1eee6a60 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
@@ -12,12 +12,24 @@
} from '$lib/elements/table';
import { WizardStep } from '$lib/layout';
import { plansInfo } from '$lib/stores/billing';
+ import { onMount } from 'svelte';
import { changeOrganizationTier } from './store';
+ import { sdk } from '$lib/stores/sdk';
+ import { user } from '$lib/stores/user';
const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
let email: string;
+ onMount(async () => {
+ const members = await sdk.forConsole.teams.listMemberships($changeOrganizationTier.id);
+ if (members.total) {
+ $changeOrganizationTier.collaborators = members.memberships.map((m) => {
+ if (m.userEmail !== $user.email) return m.userEmail;
+ });
+ }
+ });
+
function addCollaborator() {
if (!email) return;
if ($changeOrganizationTier.collaborators.includes(email)) return;
From de4b86ac000c52677f7a18fd4c1b0b1bfc5f2731 Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 12:35:49 +0100
Subject: [PATCH 22/97] fix: wrong parameter for end of trial
---
src/lib/stores/billing.ts | 4 ++--
src/lib/stores/organization.ts | 2 +-
src/routes/console/account/organizations/+page.svelte | 2 +-
.../organization-[organization]/billing/planSummary.svelte | 2 +-
src/routes/console/organization-[organization]/header.svelte | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index ea24fff91..b79693b10 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -158,7 +158,7 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num
export function calculateTrialDay(org: Organization) {
if (org?.billingPlan === 'tier-0') return false;
- const endDate = new Date(org?.billingTrialEndDate);
+ const endDate = new Date(org?.billingStartDate);
const today = new Date();
const days = diffDays(today, endDate);
daysLeftInTrial.set(days);
@@ -176,7 +176,7 @@ export function checkForTrialEnding(org: Organization) {
tierToPlan(org.billingPlan).name
} plan.
You will be billed on a recurring 30-day cycle after your trial period ends on ${toLocaleDate(
- org.billingTrialEndDate
+ org.billingStartDate
)} `
});
localStorage.setItem('trialEndingNotification', 'true');
diff --git a/src/lib/stores/organization.ts b/src/lib/stores/organization.ts
index f7fadb9be..38914e5b0 100644
--- a/src/lib/stores/organization.ts
+++ b/src/lib/stores/organization.ts
@@ -14,7 +14,7 @@ export type Organization = Models.Team> & {
billingCurrentInvoiceDate: string;
billingNextInvoiceDate: string;
billingTrialStartDate?: string;
- billingTrialEndDate?: string;
+ billingStartDate?: string;
billingTrialDays?: number;
billingAddressId?: string;
amount: number;
diff --git a/src/routes/console/account/organizations/+page.svelte b/src/routes/console/account/organizations/+page.svelte
index 1a1cf9ac1..f7eb4272c 100644
--- a/src/routes/console/account/organizations/+page.svelte
+++ b/src/routes/console/account/organizations/+page.svelte
@@ -86,7 +86,7 @@
class="u-flex u-cross-center"
use:tooltip={{
content: `Your trial ends on ${toLocaleDate(
- organization.billingTrialEndDate
+ organization.billingStartDate
)}. ${$daysLeftInTrial} days remaining.`
}}>
FREE TRIAL
diff --git a/src/routes/console/organization-[organization]/billing/planSummary.svelte b/src/routes/console/organization-[organization]/billing/planSummary.svelte
index a756fa509..bbd7def2a 100644
--- a/src/routes/console/organization-[organization]/billing/planSummary.svelte
+++ b/src/routes/console/organization-[organization]/billing/planSummary.svelte
@@ -27,7 +27,7 @@
$: currentPlan = $plansInfo.plans.find((p) => p.$id === $organization?.billingPlan);
$: extraUsage = currentInvoice?.amount - currentPlan?.price;
- $: isTrial = new Date($organization?.billingTrialEndDate).getTime() - today.getTime() > 0;
+ $: isTrial = new Date($organization?.billingStartDate).getTime() - today.getTime() > 0;
{#if $organization}
diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte
index 0a8476867..fbc193c3f 100644
--- a/src/routes/console/organization-[organization]/header.svelte
+++ b/src/routes/console/organization-[organization]/header.svelte
@@ -97,7 +97,7 @@
class="u-flex u-cross-center"
use:tooltip={{
content: `Your trial ends on ${toLocaleDate(
- $organization.billingTrialEndDate
+ $organization.billingStartDate
)}. ${$daysLeftInTrial} days remaining.`
}}>
FREE TRIAL
From 00fcfea171597b2d1555d144878b52861f1631c0 Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 13:21:28 +0100
Subject: [PATCH 23/97] fix: remove falsy values
---
.../cloudOrganizationChangeTier/inviteMembers.svelte | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
index b1eee6a60..aa83d85ce 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
@@ -24,9 +24,11 @@
onMount(async () => {
const members = await sdk.forConsole.teams.listMemberships($changeOrganizationTier.id);
if (members.total) {
- $changeOrganizationTier.collaborators = members.memberships.map((m) => {
- if (m.userEmail !== $user.email) return m.userEmail;
- });
+ $changeOrganizationTier.collaborators = members.memberships
+ .map((m) => {
+ if (m.userEmail !== $user.email) return m.userEmail;
+ })
+ .filter(Boolean);
}
});
From bf0965907c6903a3a335c6d3bc97b8119f454e35 Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 15:40:54 +0100
Subject: [PATCH 24/97] fix: old region issue, wrap address in if
---
.../console/organization-[organization]/+page.svelte | 10 ++++++----
.../billing/billingAddress.svelte | 8 ++++++--
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte
index 513fd7843..baf090007 100644
--- a/src/routes/console/organization-[organization]/+page.svelte
+++ b/src/routes/console/organization-[organization]/+page.svelte
@@ -131,6 +131,7 @@
});
function findRegion(project: Partial) {
+ console.log(project, regions);
const region = regions.regions.find((region) => region.$id === project.region);
return region;
}
@@ -165,6 +166,9 @@
offset={data.offset}
on:click={handleCreateProject}>
{#each data.projects.projects as project}
+ {@const platforms = filterPlatforms(
+ project.platforms.map((platform) => getPlatformInfo(platform.type))
+ )}
@@ -178,9 +182,7 @@
All services are disabled.
{/if}
- {@const platforms = filterPlatforms(
- project.platforms.map((platform) => getPlatformInfo(platform.type))
- )}
+
{#each platforms as platform, i}
{#if i < 3}
@@ -198,7 +200,7 @@
{#if isCloud && regions}
{@const region = findRegion(project)}
- {region.name}
+ {region?.name}
{/if}
diff --git a/src/routes/console/organization-[organization]/billing/billingAddress.svelte b/src/routes/console/organization-[organization]/billing/billingAddress.svelte
index ab8c8afbc..aa432851b 100644
--- a/src/routes/console/organization-[organization]/billing/billingAddress.svelte
+++ b/src/routes/console/organization-[organization]/billing/billingAddress.svelte
@@ -155,8 +155,12 @@
-
-
+{#if showCreate}
+
+{/if}
+{#if showEdit}
+
+{/if}
{#if showReplace}
{/if}
From 94bdc167b7b75233e807f976f6c51644a39f2a9c Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 15:41:14 +0100
Subject: [PATCH 25/97] chore: remove log
---
src/routes/console/organization-[organization]/+page.svelte | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte
index baf090007..9dd8d2580 100644
--- a/src/routes/console/organization-[organization]/+page.svelte
+++ b/src/routes/console/organization-[organization]/+page.svelte
@@ -131,7 +131,6 @@
});
function findRegion(project: Partial) {
- console.log(project, regions);
const region = regions.regions.find((region) => region.$id === project.region);
return region;
}
From 707c37b32bd65f9eff130f7ae6cc6bc6d1f31b34 Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 15:51:54 +0100
Subject: [PATCH 26/97] tmp fix: login logout login not loading org
---
.../organization-[organization]/+page.svelte | 169 +++++++++---------
.../breadcrumbs.svelte | 4 +-
.../organization-[organization]/header.svelte | 166 ++++++++---------
3 files changed, 172 insertions(+), 167 deletions(-)
diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte
index 9dd8d2580..337589afc 100644
--- a/src/routes/console/organization-[organization]/+page.svelte
+++ b/src/routes/console/organization-[organization]/+page.svelte
@@ -31,6 +31,7 @@
import type { RegionList } from '$lib/sdk/billing';
import { onMount } from 'svelte';
import CreateOrganizationCloud from '../createOrganizationCloud.svelte';
+ import { organization } from '$lib/stores/organization';
export let data;
@@ -136,94 +137,96 @@
}
-
-
-
Projects
+{#if $organization?.$id}
+
+
+
Projects
-
-
-
- Create project
-
-
- (showCreate = true)}>Empty project
-
-
- Import project Experimental
-
-
-
-
-
+
+
+
+ Create project
+
+
+ (showCreate = true)}>Empty project
+
+
+ Import project Experimental
+
+
+
+
+
- {#if data.projects.total}
-
- {#each data.projects.projects as project}
- {@const platforms = filterPlatforms(
- project.platforms.map((platform) => getPlatformInfo(platform.type))
- )}
-
-
-
- {project?.platforms?.length ? project?.platforms?.length : 'No'} apps
-
-
- {project.name}
-
- {#if allServiceDisabled(project)}
-
- All services are disabled.
-
- {/if}
+ {#if data.projects.total}
+
+ {#each data.projects.projects as project}
+ {@const platforms = filterPlatforms(
+ project.platforms.map((platform) => getPlatformInfo(platform.type))
+ )}
+
+
+
+ {project?.platforms?.length ? project?.platforms?.length : 'No'} apps
+
+
+ {project.name}
+
+ {#if allServiceDisabled(project)}
+
+ All services are disabled.
+
+ {/if}
- {#each platforms as platform, i}
- {#if i < 3}
+ {#each platforms as platform, i}
+ {#if i < 3}
+
+
+ {platform.name}
+
+ {/if}
+ {/each}
+ {#if platforms?.length > 3}
-
- {platform.name}
+ +{project.platforms.length - 3}
{/if}
- {/each}
- {#if platforms?.length > 3}
-
- +{project.platforms.length - 3}
-
- {/if}
-
- {#if isCloud && regions}
- {@const region = findRegion(project)}
-
- {region?.name}
-
- {/if}
-
-
-
- {/each}
-
- Create a new project
-
-
- {:else}
-
- {/if}
+
+ {#if isCloud && regions}
+ {@const region = findRegion(project)}
+
+ {region?.name}
+
+ {/if}
+
+
+
+ {/each}
+
+ Create a new project
+
+
+ {:else}
+
+ {/if}
-
-
+
+
-
-
+
+
+{/if}
diff --git a/src/routes/console/organization-[organization]/breadcrumbs.svelte b/src/routes/console/organization-[organization]/breadcrumbs.svelte
index 62b3a6f20..e2a847beb 100644
--- a/src/routes/console/organization-[organization]/breadcrumbs.svelte
+++ b/src/routes/console/organization-[organization]/breadcrumbs.svelte
@@ -4,8 +4,8 @@
$: breadcrumbs = [
{
- href: `/console/organization-${$organization.$id}`,
- title: $organization.name
+ href: `/console/organization-${$organization?.$id}`,
+ title: $organization?.name
}
];
diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte
index fbc193c3f..df325e0c7 100644
--- a/src/routes/console/organization-[organization]/header.svelte
+++ b/src/routes/console/organization-[organization]/header.svelte
@@ -80,86 +80,88 @@
: permanentTabs;
-
-
-
- (showDropdown = !showDropdown)}>
-
-
- {$organization.name}
- {#if isCloud && $organization?.billingPlan === 'tier-0'}
- FREE
- {/if}
- {#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0}
-
- {/if}
-
-
-
-
-
- {#each $organizationList.teams as org}
- (showDropdown = false)}>
- {org.name}
-
- {/each}
-
-
-
-
-
-
-
-
-
-
-
newMemberModal.set(true)}
- disabled={areMembersLimited}>
-
- Invite
-
+{#if $organization.$id}
+
+
+
+ (showDropdown = !showDropdown)}>
+
+
+ {$organization.name}
+ {#if isCloud && $organization?.billingPlan === 'tier-0'}
+ FREE
+ {/if}
+ {#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0}
+
+ {/if}
+
+
+
+
+
+ {#each $organizationList.teams as org}
+ (showDropdown = false)}>
+ {org.name}
+
+ {/each}
+
+
+
+
+
+
+
+
+
+
+ newMemberModal.set(true)}
+ disabled={areMembersLimited}>
+
+ Invite
+
+
-
-
-
- {#each tabs as tab}
-
- {tab.title}
-
- {/each}
-
-
+
+
+ {#each tabs as tab}
+
+ {tab.title}
+
+ {/each}
+
+
+{/if}
From abf53641624ca8537011f8bf374f7c085dd0174b Mon Sep 17 00:00:00 2001
From: tglide <26071571+TGlide@users.noreply.github.com>
Date: Thu, 21 Dec 2023 15:51:03 +0000
Subject: [PATCH 27/97] fix conditional chaining
---
src/routes/console/organization-[organization]/header.svelte | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte
index df325e0c7..65bf1e582 100644
--- a/src/routes/console/organization-[organization]/header.svelte
+++ b/src/routes/console/organization-[organization]/header.svelte
@@ -80,7 +80,7 @@
: permanentTabs;
-{#if $organization.$id}
+{#if $organization?.$id}
From 4fa8a30a7b36d719098a77b7e19dcb7d1195147e Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 17:53:52 +0100
Subject: [PATCH 28/97] fix: free date extension
---
.../console/organization-[organization]/excesLimitModal.svelte | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte
index 1e58d381f..2a04c277d 100644
--- a/src/routes/console/organization-[organization]/excesLimitModal.svelte
+++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte
@@ -62,7 +62,7 @@
Appwrite Pro is now available. To facilitate a smooth transition for your projects, Starter plan
will maintain its current state of unlimited resource usage. This extension will be in effect
- until January 15th, 2024.
+ until February 1st, 2024.
{#if $organization.billingPlan === 'tier-0'}
From 17c0d4b500ec7169835b7bda1460aefe3689f06f Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 17:59:33 +0100
Subject: [PATCH 29/97] fix: date
---
.../console/organization-[organization]/excesLimitModal.svelte | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte
index 2a04c277d..1b4053f43 100644
--- a/src/routes/console/organization-[organization]/excesLimitModal.svelte
+++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte
@@ -62,7 +62,7 @@
Appwrite Pro is now available. To facilitate a smooth transition for your projects, Starter plan
will maintain its current state of unlimited resource usage. This extension will be in effect
- until February 1st, 2024.
+ until January 31st, 2024.
{#if $organization.billingPlan === 'tier-0'}
From 969743ddbe67423a09ec8c44e36e5e695e8116af Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 17:59:59 +0100
Subject: [PATCH 30/97] fix: another date
---
src/lib/components/billing/alerts/tooManyFreeOrgs.svelte | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
index 4f02244ae..cf37e4d45 100644
--- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
+++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte
@@ -4,8 +4,8 @@
- All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024 . You
- can add a payment method or transfer projects from your settings.
+ All but one organization will be automatically upgraded to a Pro plan on 31 January 2024 .
+ You can add a payment method or transfer projects from your settings.
View organizations
From 5d2cf0241a05f83c540da0e1ff3cf516ccf6d8de Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 21 Dec 2023 19:04:24 +0100
Subject: [PATCH 31/97] fix: plan limit tag shown for users, upgrade flow wrong
step, upgrade flow invited member
---
src/lib/stores/billing.ts | 9 +++++++--
src/routes/console/+layout.svelte | 2 +-
src/routes/console/changeOrganizationTierCloud.svelte | 3 ---
.../cloudOrganizationChangeTier/choosePlan.svelte | 11 ++++++-----
.../cloudOrganizationChangeTier/confirmDetails.svelte | 4 ----
.../cloudOrganizationChangeTier/inviteMembers.svelte | 3 ++-
.../cloudOrganizationChangeTier/planExcess.svelte | 2 ++
.../wizard/cloudOrganizationChangeTier/store.ts | 2 --
8 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index b79693b10..7b7174e0f 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -183,18 +183,23 @@ export function checkForTrialEnding(org: Organization) {
}
}
-export function checkForUsageLimit(org: Organization) {
+export async function checkForUsageLimit(org: Organization) {
if (!org?.billingLimits) {
readOnly.set(false);
return;
}
const { bandwidth, documents, executions, storage, users } = org.billingLimits;
+ const members = await sdk.forConsole.teams.listMemberships(org.$id);
+ const plan = get(plansInfo).plans.find((plan) => plan.$id === org.billingPlan);
+ const membersOverflow =
+ members?.total > plan.members ? members.total - (plan.members || Infinity) : 0;
if (
bandwidth >= 100 ||
documents >= 100 ||
executions >= 100 ||
storage >= 100 ||
- users >= 100
+ users >= 100 ||
+ membersOverflow > 0
) {
readOnly.set(true);
} else readOnly.set(false);
diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte
index 479647d18..4035a9a31 100644
--- a/src/routes/console/+layout.svelte
+++ b/src/routes/console/+layout.svelte
@@ -284,7 +284,7 @@
calculateTrialDay(org);
checkForTrialEnding(org);
await paymentExpired(org);
- checkForUsageLimit(org);
+ await checkForUsageLimit(org);
checkForMarkedForDeletion(org);
await checkPaymentAuthorizationRequired(org);
}
diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte
index 64afb5bc2..56374d08d 100644
--- a/src/routes/console/changeOrganizationTierCloud.svelte
+++ b/src/routes/console/changeOrganizationTierCloud.svelte
@@ -61,7 +61,6 @@
wizard.hide();
trackEvent(Submit.OrganizationDowngrade, {
- customId: !!$changeOrganizationTier.id,
plan: tierToPlan($changeOrganizationTier.billingPlan)?.name
});
} catch (e) {
@@ -144,7 +143,6 @@
});
}
trackEvent($isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade, {
- customId: !!$changeOrganizationTier.id,
plan: tierToPlan($changeOrganizationTier.billingPlan)?.name
});
wizard.hide();
@@ -164,7 +162,6 @@
onDestroy(() => {
$changeOrganizationTier = {
- id: null,
billingPlan: 'tier-1',
paymentMethodId: null,
collaborators: [],
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
index 64d01a71c..058651b90 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
@@ -57,11 +57,12 @@
members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0
};
if (
- $changeOrganizationTier.limitOverflow.bandwidth > 0 ||
- $changeOrganizationTier.limitOverflow.storage > 0 ||
- $changeOrganizationTier.limitOverflow.users > 0 ||
- $changeOrganizationTier.limitOverflow.executions > 0 ||
- $changeOrganizationTier.limitOverflow.members > 0
+ ($changeOrganizationTier.limitOverflow.bandwidth > 0 ||
+ $changeOrganizationTier.limitOverflow.storage > 0 ||
+ $changeOrganizationTier.limitOverflow.users > 0 ||
+ $changeOrganizationTier.limitOverflow.executions > 0 ||
+ $changeOrganizationTier.limitOverflow.members > 0) &&
+ $changeOrganizationTier.billingPlan === 'tier-0'
) {
$changeOrganizationTier.isOverLimit = true;
$changeTierSteps = updateStepStatus($changeTierSteps, 5, false);
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
index 03e529630..f6095b62f 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
@@ -1,7 +1,6 @@
diff --git a/src/routes/console/organization-[organization]/createMember.svelte b/src/routes/console/organization-[organization]/createMember.svelte
index a1cf2b682..57500de0d 100644
--- a/src/routes/console/organization-[organization]/createMember.svelte
+++ b/src/routes/console/organization-[organization]/createMember.svelte
@@ -17,7 +17,7 @@
const dispatch = createEventDispatcher();
const url = `${$page.url.origin}/invite`;
- $: plan = $plansInfo?.plans?.find((p) => p.$id === $organization?.billingPlan);
+ $: plan = $plansInfo?.get($organization?.billingPlan);
let email: string, name: string, error: string;
diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte
index 1b4053f43..62d853221 100644
--- a/src/routes/console/organization-[organization]/excesLimitModal.svelte
+++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte
@@ -15,7 +15,7 @@
import { last } from '$lib/helpers/array';
export let show = false;
- const plan = $plansInfo.plans.find((plan) => plan.$id === $organization.billingPlan);
+ const plan = $plansInfo?.get($organization.billingPlan);
let usage: OrganizationUsage = null;
let members: Models.MembershipList = null;
let excess: Record = null;
diff --git a/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte
index 114403c34..dddf24fa2 100644
--- a/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte
@@ -7,7 +7,7 @@
import { sdk } from '$lib/stores/sdk';
import { createOrganization, createOrganizationFinalAction } from './store';
- const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan);
+ const plan = $plansInfo?.get($createOrganization.billingPlan);
const collaboratorPrice = plan?.addons.member?.price ?? 0;
const collaboratorsNumber = $createOrganization?.collaborators?.length ?? 0;
const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber;
diff --git a/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte
index 4c3dda396..c0f88e257 100644
--- a/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte
+++ b/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte
@@ -30,7 +30,7 @@
);
}
- const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan);
+ const plan = $plansInfo?.get($createOrganization.billingPlan);
diff --git a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte
index 8cedbdafe..552e71372 100644
--- a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte
@@ -29,9 +29,9 @@
$createOrgSteps = updateStepStatus($createOrgSteps, 4, false);
}
- $: freePlan = $plansInfo.plans.find((p) => p.$id === 'tier-0');
- $: proPlan = $plansInfo.plans.find((p) => p.$id === 'tier-1');
- $: scalePlan = $plansInfo.plans.find((p) => p.$id === 'tier-2');
+ $: freePlan = $plansInfo.get('tier-0');
+ $: proPlan = $plansInfo.get('tier-1');
+ $: scalePlan = $plansInfo.get('tier-2');
diff --git a/src/routes/console/wizard/cloudOrganization/usageRates.svelte b/src/routes/console/wizard/cloudOrganization/usageRates.svelte
index 55d94d6a3..489915463 100644
--- a/src/routes/console/wizard/cloudOrganization/usageRates.svelte
+++ b/src/routes/console/wizard/cloudOrganization/usageRates.svelte
@@ -12,13 +12,13 @@
import { toLocaleDate } from '$lib/helpers/date';
import { organization } from '$lib/stores/organization';
import { createOrganization } from './store';
- import { plansInfo } from '$lib/stores/billing';
+ import { plansInfo, type Tier } from '$lib/stores/billing';
import { abbreviateNumber } from '$lib/helpers/numbers';
export let show = false;
- export let tier: string;
+ export let tier: Tier;
- $: plan = $plansInfo.plans.find((p) => p.$id === tier);
+ $: plan = $plansInfo?.get(tier);
$: nextDate = $createOrganization?.name
? new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1).toString()
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
index 058651b90..5b177bc61 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
@@ -37,9 +37,7 @@
function checkOverUsage() {
if (!usage) return;
- const plan = $plansInfo.plans.find(
- (plan) => plan.$id === $changeOrganizationTier.billingPlan
- );
+ const plan = $plansInfo?.get($changeOrganizationTier.billingPlan);
const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0;
const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0;
@@ -97,9 +95,9 @@
}
}
- $: freePlan = $plansInfo.plans.find((p) => p.$id === 'tier-0');
- $: proPlan = $plansInfo.plans.find((p) => p.$id === 'tier-1');
- $: scalePlan = $plansInfo.plans.find((p) => p.$id === 'tier-2');
+ $: freePlan = $plansInfo?.get('tier-0');
+ $: proPlan = $plansInfo?.get('tier-1');
+ $: scalePlan = $plansInfo?.get('tier-2');
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
index f6095b62f..9236781df 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
@@ -10,7 +10,7 @@
import { sdk } from '$lib/stores/sdk';
import { changeOrganizationFinalAction, changeOrganizationTier, isUpgrade } from './store';
- const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
+ const plan = $plansInfo.get($changeOrganizationTier.billingPlan);
const collaboratorPrice = plan?.addons.member?.price ?? 0;
const collaboratorsNumber = $changeOrganizationTier?.collaborators?.length ?? 0;
const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber;
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
index 173ce045f..5fb8b167a 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte
@@ -18,7 +18,7 @@
import { user } from '$lib/stores/user';
import { organization } from '$lib/stores/organization';
- const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
+ const plan = $plansInfo.get($changeOrganizationTier.billingPlan);
let email: string;
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte
index 21e69ed67..ed545fd89 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte
@@ -26,7 +26,7 @@
} = null;
export let currentTier: Tier;
- const plan = $plansInfo.plans.find((p) => p.$id === currentTier);
+ const plan = $plansInfo?.get(currentTier);
const collaboratorPrice = plan?.addons.member?.price ?? 0;
From f851e61124d323b8a856500c68da58398b613128 Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 22 Dec 2023 17:47:49 +0100
Subject: [PATCH 42/97] refactor: tiers into enum
---
src/lib/components/support.svelte | 7 +++-
src/lib/constants.ts | 6 +++
src/lib/layout/activity.svelte | 3 +-
src/lib/layout/containerButton.svelte | 3 +-
src/lib/layout/containerHeader.svelte | 9 +++--
src/lib/layout/header.svelte | 3 +-
src/lib/layout/logs.svelte | 3 +-
src/lib/layout/navigation.svelte | 3 +-
src/lib/stores/billing.ts | 13 ++++---
src/routes/console/+layout.svelte | 4 +-
.../account/organizations/+page.svelte | 3 +-
.../changeOrganizationTierCloud.svelte | 6 +--
.../console/createOrganizationCloud.svelte | 6 +--
src/routes/console/onboarding/+page.svelte | 4 +-
.../billing/+page.svelte | 3 +-
.../billing/budgetCap.svelte | 4 +-
.../billing/planSummary.svelte | 7 ++--
.../createMember.svelte | 6 +--
.../excesLimitModal.svelte | 3 +-
.../organization-[organization]/header.svelte | 5 ++-
.../usage/[[invoice]]/+page.svelte | 9 +++--
.../auth/templates/+page.svelte | 3 +-
.../executions/+page.svelte | 4 +-
.../settings/smtp/+page.svelte | 7 ++--
.../settings/usage/[[invoice]]/+page.svelte | 9 +++--
.../bucket-[bucket]/create-file/step1.svelte | 5 ++-
.../settings/updateMaxFileSize.svelte | 5 ++-
.../cloudOrganization/confirmDetails.svelte | 11 +++---
.../cloudOrganization/inviteMembers.svelte | 9 +++--
.../organizationDetails.svelte | 15 ++++----
.../console/wizard/cloudOrganization/store.ts | 3 +-
.../cloudOrganization/usageRates.svelte | 7 ++--
.../choosePlan.svelte | 37 ++++++++++---------
.../confirmDetails.svelte | 7 ++--
.../inviteMembers.svelte | 9 +++--
.../planExcess.svelte | 11 +++---
.../cloudOrganizationChangeTier/store.ts | 3 +-
37 files changed, 146 insertions(+), 109 deletions(-)
diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte
index 06bf93f2a..c63200f73 100644
--- a/src/lib/components/support.svelte
+++ b/src/lib/components/support.svelte
@@ -10,10 +10,13 @@
import { isSupportOnline, showSupportModal } from '../../routes/console/wizard/support/store';
import { isCloud } from '$lib/system';
import { organization } from '$lib/stores/organization';
+ import { BillingPlan } from '$lib/constants';
export let show = false;
- $: isPaid = $organization?.billingPlan === 'tier-1' || $organization?.billingPlan === 'tier-2';
+ $: isPaid =
+ $organization?.billingPlan === BillingPlan.PRO ||
+ $organization?.billingPlan === BillingPlan.SCALE;
{#if isCloud}
@@ -39,7 +42,7 @@
{/if}
- {#if $organization?.billingPlan === 'tier-0'}
+ {#if $organization?.billingPlan === BillingPlan.STARTER}
Get Premium support
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 52d2b999b..4b9dedb14 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -616,3 +616,9 @@ export const limitRates = {
}
]
};
+
+export enum BillingPlan {
+ STARTER = 'tier-0',
+ PRO = 'tier-1',
+ SCALE = 'tier-2'
+}
diff --git a/src/lib/layout/activity.svelte b/src/lib/layout/activity.svelte
index 908ab6b8a..e888b3b2e 100644
--- a/src/lib/layout/activity.svelte
+++ b/src/lib/layout/activity.svelte
@@ -22,6 +22,7 @@
import { isCloud } from '$lib/system';
import { organization } from '$lib/stores/organization';
import { Button } from '$lib/elements/forms';
+ import { BillingPlan } from '$lib/constants';
export let logs: Models.LogList;
export let offset = 0;
@@ -51,7 +52,7 @@
Logs are retained in rolling {hoursToDays(limit)} intervals with the
{tierToPlan($organization.billingPlan).name}
plan.
- {#if $organization?.billingPlan === 'tier-0'}
+ {#if $organization?.billingPlan === BillingPlan.STARTER}
Upgrade to increase your log
retention for a longer period.
{/if}
diff --git a/src/lib/layout/containerButton.svelte b/src/lib/layout/containerButton.svelte
index 48459fb81..6c39746ad 100644
--- a/src/lib/layout/containerButton.svelte
+++ b/src/lib/layout/containerButton.svelte
@@ -1,12 +1,13 @@
@@ -53,7 +54,7 @@
{/if}
- {#if $createOrganization.billingPlan !== 'tier-0'}
+ {#if $createOrganization.billingPlan !== BillingPlan.STARTER}
Additional members
{collaboratorsNumber} members
@@ -75,7 +76,7 @@
{/if}
- {#if $createOrganization.billingPlan !== 'tier-0'}
+ {#if $createOrganization.billingPlan !== BillingPlan.STARTER}
{plan.name} plan
${plan.price}
@@ -91,7 +92,7 @@
${totalExpences}
- {#if $createOrganization.billingPlan !== 'tier-0'}
+ {#if $createOrganization.billingPlan !== BillingPlan.STARTER}
This amount, and any additional usage fees, will be charged on a recurring 30-day
billing cycle after your trial period ends on
import { Alert } from '$lib/components';
+ import { BillingPlan } from '$lib/constants';
import { Button, Form, FormList, InputEmail } from '$lib/elements/forms';
import {
Table,
@@ -41,10 +42,10 @@
- {#if $createOrganization.billingPlan === 'tier-2'}
+ {#if $createOrganization.billingPlan === BillingPlan.SCALE}
You can add unlimited organization members on the {plan.name} plan at no cost. Each member
added will receive an email invite to your organization on completion.
- {:else if $createOrganization.billingPlan === 'tier-1'}
+ {:else if $createOrganization.billingPlan === BillingPlan.PRO}
You can add unlimited organization members on the {plan.name} plan for
${plan.addons.member.price} each per month . Each member added will receive an
email invite to your organization on completion.
@@ -70,7 +71,7 @@
Collaborator
- {#if $createOrganization.billingPlan === 'tier-1'}
+ {#if $createOrganization.billingPlan === BillingPlan.PRO}
Cost
{/if}
@@ -79,7 +80,7 @@
{#each $createOrganization.collaborators as collaborator}
{collaborator}
- {#if $createOrganization.billingPlan === 'tier-1'}
+ {#if $createOrganization.billingPlan === BillingPlan.PRO}
15$
{/if}
diff --git a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte
index 8cedbdafe..785b74862 100644
--- a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte
@@ -1,5 +1,6 @@
diff --git a/src/routes/console/wizard/cloudOrganization/store.ts b/src/routes/console/wizard/cloudOrganization/store.ts
index 481924e9d..0c2e71e7a 100644
--- a/src/routes/console/wizard/cloudOrganization/store.ts
+++ b/src/routes/console/wizard/cloudOrganization/store.ts
@@ -1,3 +1,4 @@
+import { BillingPlan } from '$lib/constants';
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
import type { Tier } from '$lib/stores/billing';
import { writable } from 'svelte/store';
@@ -17,7 +18,7 @@ export const createOrganization = writable<{
}>({
id: null,
name: null,
- billingPlan: 'tier-1',
+ billingPlan: BillingPlan.PRO,
paymentMethodId: null,
collaborators: [],
billingAddressId: null,
diff --git a/src/routes/console/wizard/cloudOrganization/usageRates.svelte b/src/routes/console/wizard/cloudOrganization/usageRates.svelte
index 55d94d6a3..7810b8e3e 100644
--- a/src/routes/console/wizard/cloudOrganization/usageRates.svelte
+++ b/src/routes/console/wizard/cloudOrganization/usageRates.svelte
@@ -14,6 +14,7 @@
import { createOrganization } from './store';
import { plansInfo } from '$lib/stores/billing';
import { abbreviateNumber } from '$lib/helpers/numbers';
+ import { BillingPlan } from '$lib/constants';
export let show = false;
export let tier: string;
@@ -49,7 +50,7 @@
}
];
- $: isFree = tier === 'tier-0';
+ $: isFree = tier === BillingPlan.STARTER;
@@ -57,12 +58,12 @@
Usage on the Starter plan is limited for the following resources. Next billing period: {toLocaleDate(
nextDate
)}.
- {:else if tier === 'tier-1'}
+ {:else if tier === BillingPlan.PRO}
Usage on the Pro plan will be charged at the end of each billing period at the following
rates. Next billing period: {toLocaleDate(nextDate)}.
- {:else if tier === 'tier-2'}
+ {:else if tier === BillingPlan.SCALE}
Usage on the Scale plan will be charged at the end of each billing period at the
following rates. Next billing period: {toLocaleDate(nextDate)}.
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
index 058651b90..7c3095ddd 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
@@ -11,19 +11,20 @@
import type { Models } from '@appwrite.io/console';
import { sizeToBytes } from '$lib/helpers/sizeConvertion';
import { Pill } from '$lib/elements';
+ import { BillingPlan } from '$lib/constants';
let usage: OrganizationUsage = null;
let members: Models.MembershipList = null;
- $: if ($changeOrganizationTier.billingPlan === 'tier-0' && $changeTierSteps) {
+ $: if ($changeOrganizationTier.billingPlan === BillingPlan.STARTER && $changeTierSteps) {
$changeTierSteps = updateStepStatus($changeTierSteps, 2, true);
$changeTierSteps = updateStepStatus($changeTierSteps, 3, true);
$changeTierSteps = updateStepStatus($changeTierSteps, 4, true);
}
$: if (
- $changeOrganizationTier.billingPlan === 'tier-2' ||
- $changeOrganizationTier.billingPlan === 'tier-1'
+ $changeOrganizationTier.billingPlan === BillingPlan.SCALE ||
+ $changeOrganizationTier.billingPlan === BillingPlan.PRO
) {
$changeTierSteps = updateStepStatus($changeTierSteps, 2, false);
$changeTierSteps = updateStepStatus($changeTierSteps, 3, false);
@@ -62,7 +63,7 @@
$changeOrganizationTier.limitOverflow.users > 0 ||
$changeOrganizationTier.limitOverflow.executions > 0 ||
$changeOrganizationTier.limitOverflow.members > 0) &&
- $changeOrganizationTier.billingPlan === 'tier-0'
+ $changeOrganizationTier.billingPlan === BillingPlan.STARTER
) {
$changeOrganizationTier.isOverLimit = true;
$changeTierSteps = updateStepStatus($changeTierSteps, 5, false);
@@ -77,14 +78,14 @@
members = await sdk.forConsole.teams.listMemberships($organization.$id);
//Select closest tier from starting one
- // if ($organization.billingPlan === 'tier-2') {
- // $changeOrganizationTier.billingPlan = 'tier-1';
+ // if ($organization.billingPlan === BillingPlan.SCALE) {
+ // $changeOrganizationTier.billingPlan = BillingPlan.PRO;
// }
// else
- if ($organization.billingPlan === 'tier-1') {
- $changeOrganizationTier.billingPlan = 'tier-0';
- } else if ($organization.billingPlan === 'tier-0') {
- $changeOrganizationTier.billingPlan = 'tier-1';
+ if ($organization.billingPlan === BillingPlan.PRO) {
+ $changeOrganizationTier.billingPlan = BillingPlan.STARTER;
+ } else if ($organization.billingPlan === BillingPlan.STARTER) {
+ $changeOrganizationTier.billingPlan = BillingPlan.PRO;
}
});
@@ -92,14 +93,14 @@
if (!$changeOrganizationTier.billingPlan) {
throw new Error('Please select a plan.');
}
- if ($changeOrganizationTier.billingPlan === 'tier-0') {
+ if ($changeOrganizationTier.billingPlan === BillingPlan.STARTER) {
$changeOrganizationTier.collaborators = [];
}
}
- $: freePlan = $plansInfo.plans.find((p) => p.$id === 'tier-0');
- $: proPlan = $plansInfo.plans.find((p) => p.$id === 'tier-1');
- $: scalePlan = $plansInfo.plans.find((p) => p.$id === 'tier-2');
+ $: freePlan = $plansInfo.plans.find((p) => p.$id === BillingPlan.STARTER);
+ $: proPlan = $plansInfo.plans.find((p) => p.$id === BillingPlan.PRO);
+ $: scalePlan = $plansInfo.plans.find((p) => p.$id === BillingPlan.SCALE);
@@ -122,7 +123,7 @@
name="plan"
bind:group={$changeOrganizationTier.billingPlan}
value="tier-0"
- disabled={$organization.billingPlan === 'tier-0'}>
+ disabled={$organization.billingPlan === BillingPlan.STARTER}>
{tierFree.description}
- {#if $organization.billingPlan === 'tier-0'}
+ {#if $organization.billingPlan === BillingPlan.STARTER}
CURRENT PLAN
{/if}
@@ -145,7 +146,7 @@
name="plan"
bind:group={$changeOrganizationTier.billingPlan}
value="tier-1"
- disabled={$organization.billingPlan === 'tier-1'}>
+ disabled={$organization.billingPlan === BillingPlan.PRO}>