From e511e023456fe77700e1ec79f70cdaee2812025e Mon Sep 17 00:00:00 2001 From: sourabpramanik Date: Sat, 6 Jan 2024 07:30:32 +0530 Subject: [PATCH 01/40] fix: added writable store to toggle execute function modal --- .../functions/function-[function]/+page.svelte | 7 +++++-- .../functions/function-[function]/execute.svelte | 11 +++-------- .../function-[function]/executions/+page.svelte | 7 +++++-- .../settings/executeFunction.svelte | 9 +++++++-- .../functions/function-[function]/store.ts | 4 +++- 5 files changed, 23 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 1462e407d..aa0c3c17b 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -25,7 +25,7 @@ TableRow, TableScroll } from '$lib/elements/table'; - import { deploymentList, execute, func, proxyRuleList } from './store'; + import { deploymentList, execute, func, proxyRuleList, showFunctionExecute } from './store'; import { Container, ContainerHeader } from '$lib/layout'; import { app } from '$lib/stores/app'; import { calculateSize, humanFileSize } from '$lib/helpers/sizeConvertion'; @@ -151,7 +151,10 @@ diff --git a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte index 278a3ceab..4c10082c4 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte @@ -16,6 +16,7 @@ import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import type { Models } from '@appwrite.io/console'; + import { showFunctionExecute } from './store'; export let selectedFunction: Models.Function = null; @@ -34,13 +35,8 @@ { label: 'OPTIONS', value: 'OPTIONS' } ]; - let show = false; let submitting = false; - $: if (selectedFunction && !show) { - show = true; - } - const handleSubmit = async () => { submitting = true; try { @@ -80,7 +76,7 @@ function close() { selectedFunction = null; - show = false; + $showFunctionExecute = false; } afterNavigate(close); @@ -89,10 +85,9 @@

Manually execute your function. (selectedFunction = $func)}> + buttonMethod={() => { + selectedFunction = $func; + $showFunctionExecute = true; + }}>

The {tier} plan has limits

    diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/executeFunction.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/executeFunction.svelte index 112bc2758..ba4d81ea3 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/executeFunction.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/executeFunction.svelte @@ -2,7 +2,7 @@ import { CardGrid, Heading, SvgIcon } from '$lib/components'; import { Button } from '$lib/elements/forms'; import { toLocaleDateTime } from '$lib/helpers/date'; - import { execute, func } from '../store'; + import { execute, func, showFunctionExecute } from '../store'; @@ -26,6 +26,11 @@ - + diff --git a/src/routes/console/project-[project]/functions/function-[function]/store.ts b/src/routes/console/project-[project]/functions/function-[function]/store.ts index c08ec380a..c5bd1d726 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/store.ts +++ b/src/routes/console/project-[project]/functions/function-[function]/store.ts @@ -12,6 +12,8 @@ export const proxyRuleList = derived( ($page) => $page.data.proxyRuleList as Models.ProxyRuleList ); export const execute: Writable = writable(); +export const showFunctionExecute: Writable = writable(false); + export const repositories: Writable<{ search: string; installationId: string; @@ -22,4 +24,4 @@ export const repositories: Writable<{ repositories: [] }); -export const showCreateDeployment: Writable = writable(false); +export const showCreateDeployment: Writable = writable(false); \ No newline at end of file From 7d9dfc4b956eccdb2236159f67466fc5dd79088f Mon Sep 17 00:00:00 2001 From: sourabpramanik Date: Tue, 9 Jan 2024 01:44:18 +0530 Subject: [PATCH 02/40] fix: formatting in store --- .../project-[project]/functions/function-[function]/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/store.ts b/src/routes/console/project-[project]/functions/function-[function]/store.ts index c5bd1d726..0bc01a1d4 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/store.ts +++ b/src/routes/console/project-[project]/functions/function-[function]/store.ts @@ -24,4 +24,4 @@ export const repositories: Writable<{ repositories: [] }); -export const showCreateDeployment: Writable = writable(false); \ No newline at end of file +export const showCreateDeployment: Writable = writable(false); From 79730d8b47789870a6b3140fcb4b6aa99e67289b Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 12 Feb 2024 15:51:26 +0100 Subject: [PATCH 03/40] Add payment mandate setup and check for missing mandate --- src/lib/sdk/billing.ts | 21 +++++++++++++++++++++ src/routes/console/+layout.svelte | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 698f78377..751e42e58 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -18,6 +18,7 @@ export type PaymentMethodData = { clientSecret: string; failed: boolean; name: string; + mandateId?: string; }; export type PaymentList = { @@ -849,6 +850,26 @@ export class Billing { ); } + async setupPaymentMandate( + organizationId: string, + paymentMethodId: string + ): Promise { + const path = `/account/payment-methods/${paymentMethodId}/setup`; + const params = { + organizationId, + paymentMethodId + }; + const uri = new URL(this.client.config.endpoint + path); + return await this.client.call( + 'post', + uri, + { + 'content-type': 'application/json' + }, + params + ); + } + async listAddresses(queries: Query[] = []): Promise { const path = `/account/billing-addresses`; const params = { diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index dccfe71a4..8cd889e91 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -40,6 +40,7 @@ import UsageRates from './wizard/cloudOrganization/usageRates.svelte'; import { activeHeaderAlert, consoleVariables } from './store'; import { headerAlert } from '$lib/stores/headerAlert'; + import { sdk } from '$lib/stores/sdk'; function kebabToSentenceCase(str: string) { return str @@ -248,6 +249,13 @@ } }); + async function checkForMandate() { + const paymentMethods = await sdk.forConsole.billing.listPaymentMethods(); + const missingMandate = paymentMethods.paymentMethods.filter( + (method) => method.mandateId === null && method.country === 'in' + ); + } + function checkForFeedback(interval: number) { const minutes = interval / 60000; feedback.increaseElapsed(minutes); From fb0023dfd9e30c774f6cb1e7f9ae39b79cb85603 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 13 Feb 2024 14:54:09 +0100 Subject: [PATCH 04/40] feat: downgrade feedback options --- .../confirmDetails.svelte | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index e62c6af3f..6b38a5df7 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -2,7 +2,7 @@ import { Box, CreditCardBrandImage } from '$lib/components'; import { CouponInput } from '$lib/components/billing'; import { BillingPlan } from '$lib/constants'; - import { FormList, InputTextarea } from '$lib/elements/forms'; + import { FormList, InputSelect, InputTextarea } from '$lib/elements/forms'; import { toLocaleDate } from '$lib/helpers/date'; import { formatCurrency } from '$lib/helpers/numbers'; import { WizardStep } from '$lib/layout'; @@ -45,21 +45,58 @@ $: if (!$isUpgrade) { $changeOrganizationFinalAction = 'Confirm plan change'; } + + const options = [ + { + value: 'availableFeatures', + label: "The available features don't meet my needs" + }, + { + value: 'bugs', + label: 'I experienced bugs or unexpected outages while using the console' + }, + { + value: 'starter', + label: 'The Starter plan is enough for my projects' + }, + { + value: 'budget', + label: "I don't have the budget" + }, + { + value: 'tryOut', + label: 'I just wanted to try it out' + }, + { + value: 'alternative', + label: 'I found an alternative/competitor to meet my needs' + }, + { + value: 'other', + label: 'Other' + } + ]; {#if downgradeToStarter} Confirm plan change - Your feedback is important to us and helps us improve the services Appwrite offer. If - there is a specific reason you chose to change your plan at this time, please let us - know. + Your feedback is important to us and helps us improve the services Appwrite offers. + Please let us know if there is a specific reason for changing your plan. + From b482a7a3dad5b3789b180fc463f8c60fd9963bbc Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 13 Feb 2024 16:06:01 +0100 Subject: [PATCH 05/40] more work on the mandate flow --- .../billing/alerts/paymentMandate.svelte | 29 +++++++++++++++++++ src/lib/stores/billing.ts | 10 ++++++- src/routes/console/+layout.svelte | 12 ++------ 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 src/lib/components/billing/alerts/paymentMandate.svelte diff --git a/src/lib/components/billing/alerts/paymentMandate.svelte b/src/lib/components/billing/alerts/paymentMandate.svelte new file mode 100644 index 000000000..d8819b492 --- /dev/null +++ b/src/lib/components/billing/alerts/paymentMandate.svelte @@ -0,0 +1,29 @@ + + +{#if $actionRequiredInvoices && $actionRequiredInvoices?.invoices?.length && !$page.url.pathname.includes('/console/account')} + + Please authorize your upcoming payment for {$organization.name}. Your bank requires this + security measure to proceed with payment. + + + + + +{/if} diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 22b873828..3a20511ac 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -261,7 +261,15 @@ export function checkForMarkedForDeletion(org: Organization) { id: 'markedForDeletion', component: MarkedForDeletion, show: true, - importance: 5 + importance: 10 }); } } + +export async function checkForMandate(org: Organization) { + const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId; + const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentId); + if (paymentMethod.mandateId === null && paymentMethod.country === 'in') { + const method = sdk.forConsole.billing.setupPaymentMandate(org.$id, paymentId); + } +} diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index 8cd889e91..77e091d61 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -19,7 +19,8 @@ checkPaymentAuthorizationRequired, calculateTrialDay, paymentExpired, - checkForMarkedForDeletion + checkForMarkedForDeletion, + checkForMandate } from '$lib/stores/billing'; import { goto } from '$app/navigation'; import { CommandCenter, registerCommands, registerSearchers } from '$lib/commandCenter'; @@ -40,7 +41,6 @@ import UsageRates from './wizard/cloudOrganization/usageRates.svelte'; import { activeHeaderAlert, consoleVariables } from './store'; import { headerAlert } from '$lib/stores/headerAlert'; - import { sdk } from '$lib/stores/sdk'; function kebabToSentenceCase(str: string) { return str @@ -249,13 +249,6 @@ } }); - async function checkForMandate() { - const paymentMethods = await sdk.forConsole.billing.listPaymentMethods(); - const missingMandate = paymentMethods.paymentMethods.filter( - (method) => method.mandateId === null && method.country === 'in' - ); - } - function checkForFeedback(interval: number) { const minutes = interval / 60000; feedback.increaseElapsed(minutes); @@ -277,6 +270,7 @@ await checkForUsageLimit(org); checkForMarkedForDeletion(org); await checkPaymentAuthorizationRequired(org); + await checkForMandate(org); } }); From 599afa0f9044e36d300f4647624e06aa807dd7b6 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 13 Feb 2024 17:47:12 +0100 Subject: [PATCH 06/40] feat: mandate flow --- src/lib/actions/analytics.ts | 1 + .../billing/alerts/paymentMandate.svelte | 31 ++++++------- src/lib/stores/billing.ts | 21 ++++++++- src/lib/stores/stripe.ts | 43 ++++++++++++++++++- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 181592ef0..2c1d4d119 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -264,6 +264,7 @@ export enum Submit { PaymentMethodUpdate = 'submit_payment_method_update', PaymentMethodDelete = 'submit_payment_method_delete', RetryPayment = 'submit_retry_payment', + VerifyPayment = 'submit_verify_payment', BillingAddressCreate = 'submit_billing_address_create', BillingAddressUpdate = 'submit_billing_address_update', BillingAddressDelete = 'submit_billing_address_delete', diff --git a/src/lib/components/billing/alerts/paymentMandate.svelte b/src/lib/components/billing/alerts/paymentMandate.svelte index d8819b492..9799ddcc3 100644 --- a/src/lib/components/billing/alerts/paymentMandate.svelte +++ b/src/lib/components/billing/alerts/paymentMandate.svelte @@ -2,28 +2,25 @@ import { page } from '$app/stores'; import { Button } from '$lib/elements/forms'; import { HeaderAlert } from '$lib/layout'; - import { actionRequiredInvoices } from '$lib/stores/billing'; + import { paymentMissingMandate } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; - import { VARS } from '$lib/system'; + import { sdk } from '$lib/stores/sdk'; + import { confirmSetup } from '$lib/stores/stripe'; - const endpoint = VARS.APPWRITE_ENDPOINT ?? `${$page.url.origin}/v1`; + async function verifyPaymentMethod() { + const method = await sdk.forConsole.billing.setupPaymentMandate( + $organization.$id, + $paymentMissingMandate.$id + ); + await confirmSetup(method.clientSecret, method.$id); + } -{#if $actionRequiredInvoices && $actionRequiredInvoices?.invoices?.length && !$page.url.pathname.includes('/console/account')} - - Please authorize your upcoming payment for {$organization.name}. Your bank requires this - security measure to proceed with payment. +{#if $paymentMissingMandate && $paymentMissingMandate.country === 'in' && $paymentMissingMandate.mandateId === null && !$page.url.pathname.includes('/console/account')} + + The payment method for {$organization.name} needs to be verified. - - + {/if} diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 3a20511ac..d034acd0d 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -2,7 +2,14 @@ import { page } from '$app/stores'; import { derived, get, writable } from 'svelte/store'; import { sdk } from './sdk'; import { organization, type Organization } from './organization'; -import type { InvoiceList, AddressesList, Invoice, PaymentList, PlansMap } from '$lib/sdk/billing'; +import type { + InvoiceList, + AddressesList, + Invoice, + PaymentList, + PlansMap, + PaymentMethodData +} from '$lib/sdk/billing'; import { isCloud } from '$lib/system'; import { cachedStore } from '$lib/helpers/cache'; import { Query } from '@appwrite.io/console'; @@ -14,6 +21,7 @@ import { base } from '$app/paths'; import { activeHeaderAlert } from '$routes/console/store'; import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte'; import { BillingPlan } from '$lib/constants'; +import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte'; export type Tier = 'tier-0' | 'tier-1' | 'tier-2'; @@ -266,10 +274,19 @@ export function checkForMarkedForDeletion(org: Organization) { } } +export const paymentMissingMandate = writable(null); + export async function checkForMandate(org: Organization) { const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId; const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentId); if (paymentMethod.mandateId === null && paymentMethod.country === 'in') { - const method = sdk.forConsole.billing.setupPaymentMandate(org.$id, paymentId); + headerAlert.add({ + id: 'paymentMandate', + component: PaymentMandate, + show: true, + importance: 8 + }); + activeHeaderAlert.set(headerAlert.get()); + paymentMissingMandate.set(paymentMethod); } } diff --git a/src/lib/stores/stripe.ts b/src/lib/stores/stripe.ts index 5730a4c86..31cfff63d 100644 --- a/src/lib/stores/stripe.ts +++ b/src/lib/stores/stripe.ts @@ -5,6 +5,7 @@ import { get, writable } from 'svelte/store'; import type { PaymentMethodData } from '$lib/sdk/billing'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { addNotification } from './notifications'; +import { organization } from './organization'; export const stripe = writable(); let paymentMethod: PaymentMethodData; @@ -63,7 +64,8 @@ export async function submitStripeCard(name: string, urlRoute?: string) { clientSecret, confirmParams: { return_url: `${baseUrl}${ - urlRoute ?? `organization/billing?clientSecret=${clientSecret}` + urlRoute ?? + `organization-${get(organization).$id}/billing?clientSecret=${clientSecret}` }`, payment_method_data: { billing_details: { @@ -133,6 +135,45 @@ export async function confirmPayment( } } +export async function confirmSetup( + clientSecret: string, + paymentMethodId: string, + urlRoute?: string +) { + const baseUrl = 'https://cloud.appwrite.io/console/'; + + const { setupIntent, error } = await get(stripe).confirmCardSetup(clientSecret, { + payment_method: paymentMethodId, + return_url: `${baseUrl}${ + urlRoute ?? `organization-${get(organization).$id}/billing?clientSecret=${clientSecret}` + }` + }); + + if (error) { + const e = new Error(error.message); + trackError(e, Submit.VerifyPayment); + addNotification({ + message: error.message, + type: 'error' + }); + } + + if (setupIntent && setupIntent.status === 'succeeded') { + trackEvent(Submit.VerifyPayment); + addNotification({ + message: 'Payment method verified successfully', + type: 'success' + }); + } else { + const e = new Error('Something went wrong. Please try again later.'); + trackError(e, Submit.VerifyPayment); + addNotification({ + message: e.message, + type: 'error' + }); + } +} + const apperanceLight = { variables: { colorPrimary: '#606a7b', From b5b38cafcdd45d94c127cf9b7bddd10ba2b76133 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 16 Feb 2024 15:08:56 +0100 Subject: [PATCH 07/40] fix: missing coma --- src/routes/console/+layout.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index ceec6e3ac..c20fe1889 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -20,7 +20,7 @@ calculateTrialDay, paymentExpired, checkForMarkedForDeletion, - checkForMandate + checkForMandate, checkForMissingPaymentMethod } from '$lib/stores/billing'; import { goto } from '$app/navigation'; From ed19d79b2ded0c0a4e178d4fe6869a5dfa8d48e9 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:16:12 +0530 Subject: [PATCH 08/40] Update execution placeholder body --- .../functions/function-[function]/execute.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte index 278a3ceab..bac8b0303 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte @@ -123,7 +123,7 @@ {:else} @@ -214,7 +214,7 @@ From 358bda940cae7ffa7b91656b78a3a253c44496bc Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:21:12 +0530 Subject: [PATCH 09/40] Format document --- .../functions/function-[function]/execute.svelte | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte index bac8b0303..9f9780139 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte @@ -121,11 +121,7 @@ - + {:else} From 059560b5f8bcb2d4eebf4761a86c1657c9965579 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:17:13 +0530 Subject: [PATCH 10/40] Dropdown for secure protocol for custom smtp --- .../settings/smtp/+page.svelte | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/routes/console/project-[project]/settings/smtp/+page.svelte b/src/routes/console/project-[project]/settings/smtp/+page.svelte index e61255b17..735a0c5f8 100644 --- a/src/routes/console/project-[project]/settings/smtp/+page.svelte +++ b/src/routes/console/project-[project]/settings/smtp/+page.svelte @@ -23,6 +23,7 @@ import { organization } from '$lib/stores/organization'; import { wizard } from '$lib/stores/wizard'; import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; + import InputSelect from '$lib/elements/forms/inputSelect.svelte'; let enabled = false; let senderName: string; @@ -32,7 +33,13 @@ let port: number; let username: string; let password: string; - let secure = false; + let secure: string; + + const options = [ + { value: 'tls', label: 'TLS' }, + { value: 'ssl', label: 'SSL' }, + { value: '', label: 'None' } + ]; onMount(() => { enabled = $project.smtpEnabled ?? false; @@ -43,7 +50,7 @@ port = $project.smtpPort; username = $project.smtpUsername; password = $project.smtpPassword; - secure = $project.smtpSecure === 'tls'; + secure = $project.smtpSecure === 'tls' ? 'tls' : $project.smtpSecure === 'ssl' ? 'ssl' : ''; }); async function updateSmtp() { @@ -68,7 +75,7 @@ port ? port : undefined, username ? username : undefined, password ? password : undefined, - secure ? 'tls' : undefined + secure ? secure : undefined ); invalidate(Dependencies.PROJECT); @@ -97,7 +104,7 @@ port: $project.smtpPort, username: $project.smtpUsername, password: $project.smtpPassword, - secure: $project.smtpSecure === 'tls' + secure: $project.smtpSecure } ); @@ -109,7 +116,7 @@ port = undefined; username = undefined; password = undefined; - secure = false; + secure = undefined; } @@ -189,10 +196,12 @@ label="Password" bind:value={password} placeholder="Enter password" /> - - - Enable if TLS is supported on your SMTP server. - + {/if} {/if} From 7c22c42476a35da5d38ccea492679f3370e016bb Mon Sep 17 00:00:00 2001 From: Elad Shechter Date: Mon, 26 Feb 2024 11:20:06 +0800 Subject: [PATCH 11/40] Attribute items - reduce spacing between rows from 8px to 4px --- .../document-[document]/attributeItem.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte index 857e64584..0f08c8134 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte @@ -58,7 +58,7 @@ {:else} -
      +
        {#each [...formValues[attribute.key].keys()] as index}
      • From 942c2f729cfda064913e12cf2632919dba5eff61 Mon Sep 17 00:00:00 2001 From: Elad Shechter Date: Mon, 26 Feb 2024 22:19:24 +0800 Subject: [PATCH 12/40] Attribute items - reduce gap between field from 16px to 8px - Chen QA --- .../document-[document]/attributeItem.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte index 0f08c8134..1be558a2d 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributeItem.svelte @@ -60,7 +60,7 @@ {:else}
          {#each [...formValues[attribute.key].keys()] as index} -
        • +
        • Date: Tue, 5 Mar 2024 10:41:12 +0530 Subject: [PATCH 13/40] chore: disable the create project button explicitly to prevent accidental clicks --- .../organization-[organization]/createProject.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/createProject.svelte b/src/routes/console/organization-[organization]/createProject.svelte index e0f80e179..2a2bb6096 100644 --- a/src/routes/console/organization-[organization]/createProject.svelte +++ b/src/routes/console/organization-[organization]/createProject.svelte @@ -18,9 +18,11 @@ let name: string; let showCustomId = false; let error: string; + let disabled: boolean = false; async function create() { try { + disabled = true; const project = await sdk.forConsole.projects.create( id ?? ID.unique(), name, @@ -36,10 +38,12 @@ type: 'success', message: `${name} has been created` }); + show = false; await goto(`/console/project-${project.$id}`); } catch (e) { error = e.message; trackError(e, Submit.ProjectCreate); + disabled = false; } } @@ -61,6 +65,6 @@ - + From a49b361f827dd46ce7b6772109726954d82b2064 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 5 Mar 2024 10:41:20 +0530 Subject: [PATCH 14/40] chore: clean up --- .../console/organization-[organization]/createProject.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/createProject.svelte b/src/routes/console/organization-[organization]/createProject.svelte index 2a2bb6096..e77051022 100644 --- a/src/routes/console/organization-[organization]/createProject.svelte +++ b/src/routes/console/organization-[organization]/createProject.svelte @@ -29,6 +29,7 @@ teamId, 'default' ); + show = false; dispatch('created', project); trackEvent(Submit.ProjectCreate, { customId: !!id, @@ -38,7 +39,6 @@ type: 'success', message: `${name} has been created` }); - show = false; await goto(`/console/project-${project.$id}`); } catch (e) { error = e.message; From becd5bd62b9fd990944e94cfcd396a18f6e6602e Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 5 Mar 2024 18:38:24 +0000 Subject: [PATCH 15/40] chore: linter --- .../console/organization-[organization]/createProject.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/createProject.svelte b/src/routes/console/organization-[organization]/createProject.svelte index e77051022..ae0dca20c 100644 --- a/src/routes/console/organization-[organization]/createProject.svelte +++ b/src/routes/console/organization-[organization]/createProject.svelte @@ -65,6 +65,6 @@ - + From 3d1b6b72034d5df4b27a298570c5922118fefcad Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 12:49:46 +0100 Subject: [PATCH 16/40] feat: add enpoint --- .../console/changeOrganizationTierCloud.svelte | 15 +++++++++++++++ .../confirmDetails.svelte | 5 ++--- .../wizard/cloudOrganizationChangeTier/store.ts | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index aeb45a657..235296675 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -25,6 +25,7 @@ import { tierToPlan } from '$lib/stores/billing'; import { user } from '$lib/stores/user'; import { feedback } from '$lib/stores/feedback'; + import { VARS } from '$lib/system'; const dispatch = createEventDispatcher(); @@ -49,6 +50,20 @@ $user.email ); + await fetch(`${VARS.GROWTH_ENDPOINT}/billing`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + from: $organization.billingPlan, + to: $changeOrganizationTier.billingPlan, + email: $user.email, + message: $changeOrganizationTier.feedbackMessage, + reason: $changeOrganizationTier.feedbackDowngradeReason + }) + }); + addNotification({ type: 'success', isHtml: true, diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index 6b38a5df7..b6c029801 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -28,7 +28,6 @@ status: null, credits: null }; - let comment: string = null; async function fetchCard() { try { @@ -92,12 +91,12 @@ placeholder="Select one" required {options} - bind:value={comment} /> + bind:value={$changeOrganizationTier.feedbackDowngradeReason} /> + bind:value={$changeOrganizationTier.feedbackMessage} /> {:else} diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts index f9f97b578..8554b5e61 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts @@ -23,6 +23,7 @@ export const changeOrganizationTier = writable<{ }; taxId?: string; feedbackMessage?: string; + feedbackDowngradeReason?: string; couponCode?: string; }>({ billingPlan: BillingPlan.PRO, From ef3dc0c009e03d1b4380c04c45b23e197d9ec79e Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 13:55:40 +0100 Subject: [PATCH 17/40] fix: hide trial tag on starter orgs --- src/routes/console/account/organizations/+page.svelte | 2 +- src/routes/console/organization-[organization]/header.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/account/organizations/+page.svelte b/src/routes/console/account/organizations/+page.svelte index a82d76a58..0216b5621 100644 --- a/src/routes/console/account/organizations/+page.svelte +++ b/src/routes/console/account/organizations/+page.svelte @@ -82,7 +82,7 @@ FREE
          {/if} - {#if organization?.billingTrialStartDate && $daysLeftInTrial > 0} + {#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.STARTER}
          FREE {/if} - {#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0} + {#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.STARTER}
          Date: Wed, 6 Mar 2024 14:40:05 +0100 Subject: [PATCH 18/40] feat: improve message sent --- .../changeOrganizationTierCloud.svelte | 19 ++++----- .../confirmDetails.svelte | 40 ++++--------------- .../cloudOrganizationChangeTier/store.ts | 31 ++++++++++++++ 3 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index 235296675..fd0055b81 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -14,6 +14,7 @@ changeOrganizationFinalAction, changeOrganizationTier, changeTierSteps, + feedbackDowngradeOptions, isUpgrade } from './wizard/cloudOrganizationChangeTier/store'; import { goto, invalidate } from '$app/navigation'; @@ -24,7 +25,6 @@ import { wizard } from '$lib/stores/wizard'; import { tierToPlan } from '$lib/stores/billing'; import { user } from '$lib/stores/user'; - import { feedback } from '$lib/stores/feedback'; import { VARS } from '$lib/system'; const dispatch = createEventDispatcher(); @@ -43,24 +43,21 @@ $changeOrganizationTier.paymentMethodId, $changeOrganizationTier.billingAddressId ); - feedback.submitFeedback( - 'downgrade', - $changeOrganizationTier.feedbackMessage, - $user?.name ?? '', - $user.email - ); - await fetch(`${VARS.GROWTH_ENDPOINT}/billing`, { + await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - from: $organization.billingPlan, - to: $changeOrganizationTier.billingPlan, + from: tierToPlan($organization.billingPlan).name, + to: tierToPlan($changeOrganizationTier.billingPlan).name, email: $user.email, message: $changeOrganizationTier.feedbackMessage, - reason: $changeOrganizationTier.feedbackDowngradeReason + reason: feedbackDowngradeOptions.find( + (option) => + option.value === $changeOrganizationTier.feedbackDowngradeReason + )?.label }) }); diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index b6c029801..a67c5086e 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -10,7 +10,12 @@ import { plansInfo } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; - import { changeOrganizationFinalAction, changeOrganizationTier, isUpgrade } from './store'; + import { + changeOrganizationFinalAction, + changeOrganizationTier, + feedbackDowngradeOptions, + isUpgrade + } from './store'; const plan = $plansInfo.get($changeOrganizationTier.billingPlan); const collaboratorPrice = plan?.addons.member?.price ?? 0; @@ -44,37 +49,6 @@ $: if (!$isUpgrade) { $changeOrganizationFinalAction = 'Confirm plan change'; } - - const options = [ - { - value: 'availableFeatures', - label: "The available features don't meet my needs" - }, - { - value: 'bugs', - label: 'I experienced bugs or unexpected outages while using the console' - }, - { - value: 'starter', - label: 'The Starter plan is enough for my projects' - }, - { - value: 'budget', - label: "I don't have the budget" - }, - { - value: 'tryOut', - label: 'I just wanted to try it out' - }, - { - value: 'alternative', - label: 'I found an alternative/competitor to meet my needs' - }, - { - value: 'other', - label: 'Other' - } - ]; {#if downgradeToStarter} @@ -90,7 +64,7 @@ label="What made you decide to change your plan?*" placeholder="Select one" required - {options} + options={feedbackDowngradeOptions} bind:value={$changeOrganizationTier.feedbackDowngradeReason} /> Date: Wed, 6 Mar 2024 17:24:20 +0100 Subject: [PATCH 19/40] feat: add org id and user id to dowgrade feedback --- src/routes/console/changeOrganizationTierCloud.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index fd0055b81..2e2ad4544 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -53,11 +53,13 @@ from: tierToPlan($organization.billingPlan).name, to: tierToPlan($changeOrganizationTier.billingPlan).name, email: $user.email, - message: $changeOrganizationTier.feedbackMessage, reason: feedbackDowngradeOptions.find( (option) => option.value === $changeOrganizationTier.feedbackDowngradeReason - )?.label + )?.label, + orgId: $organization.$id, + userId: $user.$id, + message: $changeOrganizationTier?.feedbackMessage ?? '' }) }); From 8ca43dfa8e69802c6c96625a14c634d5fbc84e2d Mon Sep 17 00:00:00 2001 From: Arman Date: Sat, 9 Mar 2024 17:35:48 +0100 Subject: [PATCH 20/40] feat: add downgrade reason --- .../console/wizard/cloudOrganizationChangeTier/store.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts index 6cb6d12b0..846dbabcc 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts @@ -39,6 +39,10 @@ export const feedbackDowngradeOptions = [ value: 'availableFeatures', label: "The available features don't meet my needs" }, + { + value: 'traction', + label: "My project isn't getting traction" + }, { value: 'bugs', label: 'I experienced bugs or unexpected outages while using the console' From 21e845bbe159364d7ed054e489130f85b7b83baa Mon Sep 17 00:00:00 2001 From: Arman Date: Sun, 10 Mar 2024 12:01:01 +0100 Subject: [PATCH 21/40] fix: providers modals not opening correctly, move modals to custom folder --- src/lib/stores/oauth-providers.ts | 18 +++++++++--------- .../auth/{ => (providers)}/appleOAuth.svelte | 5 +++-- .../auth/{ => (providers)}/auth0OAuth.svelte | 5 +++-- .../{ => (providers)}/authentikOAuth.svelte | 5 +++-- .../auth/{ => (providers)}/gitlabOAuth.svelte | 5 +++-- .../auth/{ => (providers)}/googleOAuth.svelte | 5 +++-- .../auth/{ => (providers)}/mainOAuth.svelte | 5 +++-- .../{ => (providers)}/microsoftOAuth.svelte | 5 +++-- .../auth/{ => (providers)}/oidcOAuth.svelte | 5 +++-- .../auth/{ => (providers)}/oktaOAuth.svelte | 5 +++-- .../auth/settings/+page.svelte | 10 ++++++++-- 11 files changed, 44 insertions(+), 29 deletions(-) rename src/routes/console/project-[project]/auth/{ => (providers)}/appleOAuth.svelte (95%) rename src/routes/console/project-[project]/auth/{ => (providers)}/auth0OAuth.svelte (95%) rename src/routes/console/project-[project]/auth/{ => (providers)}/authentikOAuth.svelte (95%) rename src/routes/console/project-[project]/auth/{ => (providers)}/gitlabOAuth.svelte (95%) rename src/routes/console/project-[project]/auth/{ => (providers)}/googleOAuth.svelte (95%) rename src/routes/console/project-[project]/auth/{ => (providers)}/mainOAuth.svelte (94%) rename src/routes/console/project-[project]/auth/{ => (providers)}/microsoftOAuth.svelte (95%) rename src/routes/console/project-[project]/auth/{ => (providers)}/oidcOAuth.svelte (96%) rename src/routes/console/project-[project]/auth/{ => (providers)}/oktaOAuth.svelte (95%) diff --git a/src/lib/stores/oauth-providers.ts b/src/lib/stores/oauth-providers.ts index c5752e8ac..09c5bf539 100644 --- a/src/lib/stores/oauth-providers.ts +++ b/src/lib/stores/oauth-providers.ts @@ -1,15 +1,15 @@ import type { Models } from '@appwrite.io/console'; import type { SvelteComponent } from 'svelte'; import { writable } from 'svelte/store'; -import Apple from '../../routes/console/project-[project]/auth/appleOAuth.svelte'; -import Auth0 from '../../routes/console/project-[project]/auth/auth0OAuth.svelte'; -import Authentik from '../../routes/console/project-[project]/auth/authentikOAuth.svelte'; -import GitLab from '../../routes/console/project-[project]/auth/gitlabOAuth.svelte'; -import Google from '../../routes/console/project-[project]/auth/googleOAuth.svelte'; -import Main from '../../routes/console/project-[project]/auth/mainOAuth.svelte'; -import Microsoft from '../../routes/console/project-[project]/auth/microsoftOAuth.svelte'; -import Oidc from '../../routes/console/project-[project]/auth/oidcOAuth.svelte'; -import Okta from '../../routes/console/project-[project]/auth/oktaOAuth.svelte'; +import Apple from '../../routes/console/project-[project]/auth/(providers)/appleOAuth.svelte'; +import Auth0 from '../../routes/console/project-[project]/auth/(providers)/auth0OAuth.svelte'; +import Authentik from '../../routes/console/project-[project]/auth/(providers)/authentikOAuth.svelte'; +import GitLab from '../../routes/console/project-[project]/auth/(providers)/gitlabOAuth.svelte'; +import Google from '../../routes/console/project-[project]/auth/(providers)/googleOAuth.svelte'; +import Main from '../../routes/console/project-[project]/auth/(providers)/mainOAuth.svelte'; +import Microsoft from '../../routes/console/project-[project]/auth/(providers)/microsoftOAuth.svelte'; +import Oidc from '../../routes/console/project-[project]/auth/(providers)/oidcOAuth.svelte'; +import Okta from '../../routes/console/project-[project]/auth/(providers)/oktaOAuth.svelte'; export type Provider = Models.Provider & { key: string; diff --git a/src/routes/console/project-[project]/auth/appleOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/appleOAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/appleOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/appleOAuth.svelte index c14b2e5f7..982422b3f 100644 --- a/src/routes/console/project-[project]/auth/appleOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/appleOAuth.svelte @@ -5,11 +5,12 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; const projectId = $page.params.project; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -37,7 +38,7 @@ $: secret = keyID && teamID && p8 ? JSON.stringify({ keyID, teamID, p8 }) : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/auth0OAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/auth0OAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/auth0OAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/auth0OAuth.svelte index 51a25c834..0607180a5 100644 --- a/src/routes/console/project-[project]/auth/auth0OAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/auth0OAuth.svelte @@ -5,9 +5,10 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -38,7 +39,7 @@ : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/authentikOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/authentikOAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/authentikOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/authentikOAuth.svelte index 7df8877a5..f7d6dcd37 100644 --- a/src/routes/console/project-[project]/auth/authentikOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/authentikOAuth.svelte @@ -5,9 +5,10 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -38,7 +39,7 @@ : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/gitlabOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/gitlabOAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/gitlabOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/gitlabOAuth.svelte index e93d4ae8f..95f80675e 100644 --- a/src/routes/console/project-[project]/auth/gitlabOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/gitlabOAuth.svelte @@ -5,9 +5,10 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -36,7 +37,7 @@ clientSecret && endpoint ? JSON.stringify({ clientSecret, endpoint }) : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/googleOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/googleOAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/googleOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/googleOAuth.svelte index c06c99b6f..defd59038 100644 --- a/src/routes/console/project-[project]/auth/googleOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/googleOAuth.svelte @@ -5,9 +5,10 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; export let provider: Provider; + export let show = false; const projectId = $page.params.project; @@ -34,7 +35,7 @@ }; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/mainOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/mainOAuth.svelte similarity index 94% rename from src/routes/console/project-[project]/auth/mainOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/mainOAuth.svelte index f8c11649e..184fcd00c 100644 --- a/src/routes/console/project-[project]/auth/mainOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/mainOAuth.svelte @@ -5,9 +5,10 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; export let provider: Provider; + export let show = false; const projectId = $page.params.project; @@ -34,7 +35,7 @@ }; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/microsoftOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/microsoftOAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/microsoftOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/microsoftOAuth.svelte index 266713e8e..7fd451af5 100644 --- a/src/routes/console/project-[project]/auth/microsoftOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/microsoftOAuth.svelte @@ -5,9 +5,10 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -37,7 +38,7 @@ clientSecret && tenantID ? JSON.stringify({ clientSecret, tenantID }) : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/oidcOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/oidcOAuth.svelte similarity index 96% rename from src/routes/console/project-[project]/auth/oidcOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/oidcOAuth.svelte index 719759e14..f00f07e30 100644 --- a/src/routes/console/project-[project]/auth/oidcOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/oidcOAuth.svelte @@ -5,11 +5,12 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; const projectId = $page.params.project; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -60,7 +61,7 @@ : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/oktaOAuth.svelte b/src/routes/console/project-[project]/auth/(providers)/oktaOAuth.svelte similarity index 95% rename from src/routes/console/project-[project]/auth/oktaOAuth.svelte rename to src/routes/console/project-[project]/auth/(providers)/oktaOAuth.svelte index b9e640f8d..6e23ca60c 100644 --- a/src/routes/console/project-[project]/auth/oktaOAuth.svelte +++ b/src/routes/console/project-[project]/auth/(providers)/oktaOAuth.svelte @@ -5,11 +5,12 @@ import type { Provider } from '$lib/stores/oauth-providers'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { updateOAuth } from './updateOAuth'; + import { updateOAuth } from '../updateOAuth'; const projectId = $page.params.project; export let provider: Provider; + export let show = false; let appId: string = null; let enabled: boolean = null; @@ -42,7 +43,7 @@ : provider.secret; - + {provider.name} OAuth2 Settings

          diff --git a/src/routes/console/project-[project]/auth/settings/+page.svelte b/src/routes/console/project-[project]/auth/settings/+page.svelte index fea2bad07..610733117 100644 --- a/src/routes/console/project-[project]/auth/settings/+page.svelte +++ b/src/routes/console/project-[project]/auth/settings/+page.svelte @@ -14,6 +14,7 @@ import { project } from '../../store'; const projectId = $page.params.project; + let showProvider = false; $: { authMethods.load($project); @@ -74,6 +75,7 @@ class="card u-flex u-flex-vertical u-cross-center u-width-full-line" on:click={() => { selectedProvider = provider; + showProvider = true; trackEvent(`click_select_provider`, { provider: provider.key.toLowerCase() }); @@ -99,9 +101,13 @@ {/if} -{#if selectedProvider} +{#if selectedProvider && showProvider} (selectedProvider = null)} /> + bind:show={showProvider} + on:close={() => { + selectedProvider = null; + showProvider = false; + }} /> {/if} From f3b069501567a1faee7b660eed55b27ae4e0356a Mon Sep 17 00:00:00 2001 From: Arman Date: Sun, 10 Mar 2024 15:44:38 +0100 Subject: [PATCH 22/40] fix: execute modal --- .../functions/function-[function]/+layout.svelte | 4 ++-- .../functions/function-[function]/execute.svelte | 13 +++++-------- .../function-[function]/executions/+page.svelte | 11 ++--------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/+layout.svelte b/src/routes/console/project-[project]/functions/function-[function]/+layout.svelte index d693ef604..8ae5bc6d4 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+layout.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+layout.svelte @@ -5,7 +5,7 @@ import { Dependencies } from '$lib/constants'; import { invalidate, goto } from '$app/navigation'; import { registerCommands } from '$lib/commandCenter'; - import { execute, func, showCreateDeployment } from './store'; + import { func, showCreateDeployment } from './store'; import { project } from '../../store'; import type { Models } from '@appwrite.io/console'; import Execute from './execute.svelte'; @@ -147,4 +147,4 @@ - + diff --git a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte index 65fe792c5..070c0af0c 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/execute.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/execute.svelte @@ -15,10 +15,7 @@ import Label from '$lib/elements/forms/label.svelte'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; - import type { Models } from '@appwrite.io/console'; - import { showFunctionExecute } from './store'; - - export let selectedFunction: Models.Function = null; + import { showFunctionExecute, execute } from './store'; let path = '/'; let method = 'GET'; @@ -47,7 +44,7 @@ } await sdk.forProject.functions.createExecution( - selectedFunction.$id, + $execute.$id, body, true, path, @@ -56,7 +53,7 @@ ); if (!$page.url?.toString()?.includes('/executions')) { await goto( - `${base}/console/project-${$page.params.project}/functions/function-${selectedFunction.$id}/executions` + `${base}/console/project-${$page.params.project}/functions/function-${$execute.$id}/executions` ); } invalidate(Dependencies.EXECUTIONS); @@ -75,7 +72,7 @@ }; function close() { - selectedFunction = null; + $execute = null; $showFunctionExecute = false; } @@ -100,7 +97,7 @@

          - {#if selectedFunction?.version !== 'v3'} + {#if $execute?.version !== 'v3'} Customizable execution data now available for functions v3.0 diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index 57ee9f4f3..0b14ea74f 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -19,19 +19,16 @@ import { log } from '$lib/stores/logs'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { func, showFunctionExecute } from '../store'; + import { func, execute, showFunctionExecute } from '../store'; import type { Models } from '@appwrite.io/console'; import { organization } from '$lib/stores/organization'; import { getServiceLimit, showUsageRatesModal } from '$lib/stores/billing'; import { project } from '$routes/console/project-[project]/store'; import Create from '../create.svelte'; - import Execute from '../execute.svelte'; import { abbreviateNumber } from '$lib/helpers/numbers'; export let data; - let selectedFunction: Models.Function = null; - onMount(() => { return sdk.forConsole.client.subscribe('console', (response) => { if (response.events.includes('functions.*.executions.*')) { @@ -55,7 +52,7 @@ buttonText="Execute now" buttonEvent="execute_function" buttonMethod={() => { - selectedFunction = $func; + $execute = $func; $showFunctionExecute = true; }}> @@ -172,7 +169,3 @@ {/if} - - - - From 6f08a1cfbba31580a7af54823f9724b9c47e412f Mon Sep 17 00:00:00 2001 From: Arman Date: Sun, 10 Mar 2024 16:49:02 +0100 Subject: [PATCH 23/40] fix: zrender cloud --- vite.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 754fb4acc..d1d53436e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,7 +13,8 @@ const config = defineConfig({ '@analytics/google-analytics', 'analytics', 'dayjs', - 'dotenv' + 'dotenv', + 'zrender' ] }, define: { From a9827f3a35fd4628a79a18691ae029aa9cfaaf4b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 10 Mar 2024 17:16:42 +0100 Subject: [PATCH 24/40] fix: tests --- .github/workflows/tests.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 865a0bd9e..109c3bac4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,13 +1,8 @@ name: Tests on: - push: - branches: [main] - paths-ignore: - - '**/*.md' - - 'static/**/*' pull_request: - branches: [main] + branches: ['**'] paths-ignore: - '**/*.md' - 'static/**/*' @@ -23,9 +18,9 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: 18 - # - name: Audit dependencies - # run: npm audit --audit-level low + node-version: 20 + - name: Audit dependencies + run: npm audit --audit-level low - name: Install dependencies run: npm ci - name: Svelte Diagnostics @@ -35,4 +30,4 @@ jobs: - name: Unit Tests run: npm test - name: Build Console - run: npm run build + run: npm run build \ No newline at end of file From 683cd7f600f170735d01ac13b5b647402a2c9c55 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 10 Mar 2024 17:18:29 +0100 Subject: [PATCH 25/40] fix: audit level --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 109c3bac4..c533dcbf8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: with: node-version: 20 - name: Audit dependencies - run: npm audit --audit-level low + run: npm audit --audit-level critical - name: Install dependencies run: npm ci - name: Svelte Diagnostics From 49084e253832eda7804d64922fe07cdcf65b6958 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 10 Mar 2024 17:20:36 +0100 Subject: [PATCH 26/40] chore: run formatter --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c533dcbf8..a0490076e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,4 +30,4 @@ jobs: - name: Unit Tests run: npm test - name: Build Console - run: npm run build \ No newline at end of file + run: npm run build From 31921a7495c174c0d56093b0ed73cb6136c2394b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Sun, 10 Mar 2024 17:23:57 +0100 Subject: [PATCH 27/40] fix: vitest config --- vite.config.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index d1d53436e..db9f16dc8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -37,7 +37,11 @@ const testConfig = defineConfig({ pool: 'threads', setupFiles: ['./tests/unit/setup.ts'], deps: { - inline: ['@analytics/type-utils'] + optimizer: { + web: { + include: ['@analytics/type-utils'] + } + } } } }); From f74b39d189c2e8bb642bf3f12c3e9ccdf6bc7cab Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 21 Feb 2024 15:20:03 +0100 Subject: [PATCH 28/40] chore: update limits tag copy --- src/lib/layout/containerHeader.svelte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib/layout/containerHeader.svelte b/src/lib/layout/containerHeader.svelte index 80585507e..7377fa8f2 100644 --- a/src/lib/layout/containerHeader.svelte +++ b/src/lib/layout/containerHeader.svelte @@ -113,12 +113,11 @@ {#if hasProjectLimitation} (showDropdown = !showDropdown)}> - {total}/{limit} - {title} used + {total}/{limit} created {:else} (showDropdown = !showDropdown)}> - {title} limited + Limits applied {/if} From 86441d73df10df6d15e27ab7645b4bfc97ec4b8a Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 21 Feb 2024 16:29:55 +0100 Subject: [PATCH 29/40] fix: copy --- src/lib/layout/containerHeader.svelte | 4 ++-- .../storage/bucket-[bucket]/+page.svelte | 20 +++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/lib/layout/containerHeader.svelte b/src/lib/layout/containerHeader.svelte index 7377fa8f2..3a22c3c58 100644 --- a/src/lib/layout/containerHeader.svelte +++ b/src/lib/layout/containerHeader.svelte @@ -124,7 +124,7 @@ {#if hasProjectLimitation}

          - Your are limited to {limit} + You are limited to {limit} {title.toLocaleLowerCase()} per project on the {tier} plan. {#if $organization?.billingPlan === BillingPlan.STARTER} - for addtional {title.toLocaleLowerCase()}. + for additional {title.toLocaleLowerCase()}. {/if}

          {:else if hasUsageFees} diff --git a/src/routes/console/project-[project]/storage/bucket-[bucket]/+page.svelte b/src/routes/console/project-[project]/storage/bucket-[bucket]/+page.svelte index d02d6dd5c..318a0b7cb 100644 --- a/src/routes/console/project-[project]/storage/bucket-[bucket]/+page.svelte +++ b/src/routes/console/project-[project]/storage/bucket-[bucket]/+page.svelte @@ -33,17 +33,23 @@ TableRowLink } from '$lib/elements/table'; import { toLocaleDate } from '$lib/helpers/date'; - import { bytesToSize, calculateSize } from '$lib/helpers/sizeConvertion'; + import { + bytesToSize, + calculateSize, + humanFileSize, + sizeToBytes + } from '$lib/helpers/sizeConvertion'; import { Container, ContainerHeader } from '$lib/layout'; import type { Models } from '@appwrite.io/console'; import { addNotification } from '$lib/stores/notifications'; import { uploader } from '$lib/stores/uploader'; import { wizard } from '$lib/stores/wizard'; import { tooltip } from '$lib/actions/tooltip'; - import { showUsageRatesModal } from '$lib/stores/billing'; + import { getServiceLimit, showUsageRatesModal } from '$lib/stores/billing'; import { sdk } from '$lib/stores/sdk.js'; import Create from './create-file/create.svelte'; import DeleteFile from './deleteFile.svelte'; + import { isCloud } from '$lib/system'; export let data; @@ -77,6 +83,10 @@ trackError(error, Submit.FileDelete); } } + + $: maxFileSize = isCloud + ? humanFileSize(sizeToBytes(getServiceLimit('fileSize'), 'MB', 1000)) + : null; @@ -101,10 +111,12 @@ {#if tier === 'Starter'}

          - You are limited to {limit} GB of storage on the {tier} plan. + You are limited to {limit} GB of total storage and {Math.floor( + parseInt(maxFileSize.value) + )}{maxFileSize.unit} on the {tier} plan. - for addtional storage. + for additional storage.

          {:else}

          From 9e03fec2ea34c95a600d7cdd6273e49b63f6d67f Mon Sep 17 00:00:00 2001 From: Arman Date: Sun, 10 Mar 2024 18:03:52 +0100 Subject: [PATCH 30/40] feat: fix table margins --- src/lib/components/permissions/team.svelte | 22 ++++++++++--------- src/lib/elements/table/table.svelte | 8 +++++-- src/lib/elements/table/tableScroll.svelte | 3 +++ .../billing/paymentHistory.svelte | 4 ++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/lib/components/permissions/team.svelte b/src/lib/components/permissions/team.svelte index 5056e1186..e8d900df2 100644 --- a/src/lib/components/permissions/team.svelte +++ b/src/lib/components/permissions/team.svelte @@ -6,6 +6,8 @@ import { AvatarInitials, EmptySearch, Modal, PaginationInline } from '..'; import type { Writable } from 'svelte/store'; import type { Permission } from './permissions.svelte'; + import Table from '$lib/elements/table/table.svelte'; + import { TableBody, TableCell, TableRow } from '$lib/elements/table'; export let show: boolean; export let groups: Writable>; @@ -77,13 +79,13 @@ bind:value={search} /> {#if results?.teams?.length}

          - - +
          + {#each results.teams as team (team.$id)} {@const role = `team:${team.$id}`} {@const exists = $groups.has(role)} - - - - + + {/each} - -
          + + onSelection(event, role)} /> - + + -
          + +

          Total results: {results?.total}

          diff --git a/src/lib/elements/table/table.svelte b/src/lib/elements/table/table.svelte index 81df3e41a..a9bd44acf 100644 --- a/src/lib/elements/table/table.svelte +++ b/src/lib/elements/table/table.svelte @@ -3,10 +3,14 @@ export let noStyles = false; export let style = ''; export let transparent = false; + export let isAutoLayout = false; + export let tag: 'div' | 'table' = 'div'; -
          -
          + diff --git a/src/lib/elements/table/tableScroll.svelte b/src/lib/elements/table/tableScroll.svelte index b586b58f5..9a8c4d1d8 100644 --- a/src/lib/elements/table/tableScroll.svelte +++ b/src/lib/elements/table/tableScroll.svelte @@ -5,6 +5,8 @@ export let noMargin = false; export let style = ''; export let transparent = false; + export let noStyles = false; + let isOverflowing = false; const hasOverflow: Action = (node) => { @@ -44,6 +46,7 @@
          (isOverflowing = v)}> diff --git a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte index eb3ea4b31..a8caf4348 100644 --- a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte @@ -65,7 +65,7 @@

          {#if invoiceList.total - 1 > 0} - + Due Date Status @@ -94,7 +94,7 @@ {formatCurrency(invoice.amount)} - + Date: Sun, 10 Mar 2024 21:22:15 +0100 Subject: [PATCH 31/40] fix: org usage execution formatting --- .../organization-[organization]/usage/[[invoice]]/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.svelte b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.svelte index ccd10c321..38779b21b 100644 --- a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.svelte +++ b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.svelte @@ -225,7 +225,7 @@ {@const max = getServiceLimit('executions', tier)} Date: Mon, 11 Mar 2024 16:55:20 +0100 Subject: [PATCH 32/40] fix: platform loading issues --- .../overview/platforms/createAndroid.svelte | 6 +----- .../overview/platforms/createApple.svelte | 7 ++----- .../overview/platforms/createFlutter.svelte | 7 ++----- .../project-[project]/overview/platforms/createWeb.svelte | 7 ++----- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/routes/console/project-[project]/overview/platforms/createAndroid.svelte b/src/routes/console/project-[project]/overview/platforms/createAndroid.svelte index 05fcfe438..f2d1e3267 100644 --- a/src/routes/console/project-[project]/overview/platforms/createAndroid.svelte +++ b/src/routes/console/project-[project]/overview/platforms/createAndroid.svelte @@ -4,7 +4,6 @@ import { wizard } from '$lib/stores/wizard'; import { createPlatform } from './wizard/store'; import { Dependencies } from '$lib/constants'; - import { onboarding } from '../../store'; import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import Step1 from './wizard/android/step1.svelte'; import Step2 from './wizard/android/step2.svelte'; @@ -12,10 +11,7 @@ import Step4 from './wizard/step4.svelte'; async function onFinish() { - await Promise.all([ - $onboarding && invalidate(Dependencies.PROJECT), - invalidate(Dependencies.PLATFORMS) - ]); + await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]); createPlatform.reset(); wizard.hide(); } diff --git a/src/routes/console/project-[project]/overview/platforms/createApple.svelte b/src/routes/console/project-[project]/overview/platforms/createApple.svelte index 745a9b537..33baa5870 100644 --- a/src/routes/console/project-[project]/overview/platforms/createApple.svelte +++ b/src/routes/console/project-[project]/overview/platforms/createApple.svelte @@ -9,13 +9,10 @@ import Step3 from './wizard/apple/step3.svelte'; import Step4 from './wizard/step4.svelte'; import { Dependencies } from '$lib/constants'; - import { onboarding } from '../../store'; async function onFinish() { - await Promise.all([ - $onboarding && invalidate(Dependencies.PROJECT), - invalidate(Dependencies.PLATFORMS) - ]); + await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]); + createPlatform.reset(); wizard.hide(); } diff --git a/src/routes/console/project-[project]/overview/platforms/createFlutter.svelte b/src/routes/console/project-[project]/overview/platforms/createFlutter.svelte index 5be9b2568..f4cd90823 100644 --- a/src/routes/console/project-[project]/overview/platforms/createFlutter.svelte +++ b/src/routes/console/project-[project]/overview/platforms/createFlutter.svelte @@ -9,13 +9,10 @@ import Step3 from './wizard/flutter/step3.svelte'; import Step4 from './wizard/step4.svelte'; import { Dependencies } from '$lib/constants'; - import { onboarding } from '../../store'; async function onFinish() { - await Promise.all([ - $onboarding && invalidate(Dependencies.PROJECT), - invalidate(Dependencies.PLATFORMS) - ]); + await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]); + createPlatform.reset(); wizard.hide(); } diff --git a/src/routes/console/project-[project]/overview/platforms/createWeb.svelte b/src/routes/console/project-[project]/overview/platforms/createWeb.svelte index c24248ca3..1fe89255e 100644 --- a/src/routes/console/project-[project]/overview/platforms/createWeb.svelte +++ b/src/routes/console/project-[project]/overview/platforms/createWeb.svelte @@ -9,13 +9,10 @@ import Step3 from './wizard/web/step3.svelte'; import Step4 from './wizard/step4.svelte'; import { Dependencies } from '$lib/constants'; - import { onboarding } from '../../store'; async function onFinish() { - await Promise.all([ - $onboarding && invalidate(Dependencies.PROJECT), - invalidate(Dependencies.PLATFORMS) - ]); + await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]); + createPlatform.reset(); wizard.hide(); } From cf82b17fc70ba672840eb328ce0e4589439af90c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 13 Mar 2024 11:57:00 +0100 Subject: [PATCH 33/40] fix: add payment from account page --- src/routes/console/account/payments/paymentModal.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/console/account/payments/paymentModal.svelte b/src/routes/console/account/payments/paymentModal.svelte index abe6767fe..ddf83bc27 100644 --- a/src/routes/console/account/payments/paymentModal.svelte +++ b/src/routes/console/account/payments/paymentModal.svelte @@ -6,6 +6,7 @@ import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; import { addNotification } from '$lib/stores/notifications'; + import { base } from '$app/paths'; export let show = false; @@ -20,7 +21,7 @@ async function handleSubmit() { try { - const card = await submitStripeCard(name); + const card = await submitStripeCard(name, '/account/payments'); invalidate(Dependencies.PAYMENT_METHODS); dispatch('submit', card); show = false; From 31a4ff88d5a9b2f2edf9da46f3f82f2737eafbd7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 13 Mar 2024 11:58:34 +0100 Subject: [PATCH 34/40] revert: base import --- src/routes/console/account/payments/paymentModal.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/console/account/payments/paymentModal.svelte b/src/routes/console/account/payments/paymentModal.svelte index ddf83bc27..dfd8b3caf 100644 --- a/src/routes/console/account/payments/paymentModal.svelte +++ b/src/routes/console/account/payments/paymentModal.svelte @@ -6,7 +6,6 @@ import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; import { addNotification } from '$lib/stores/notifications'; - import { base } from '$app/paths'; export let show = false; From 920ec185b23cfef3cc846d53a0265bf2611d2a03 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 13 Mar 2024 18:44:50 +0100 Subject: [PATCH 35/40] fix: confirm payments --- src/lib/stores/stripe.ts | 16 ++++++++++------ src/routes/console/account/payments/+page.svelte | 13 +++++++++++++ .../console/account/payments/paymentModal.svelte | 3 ++- .../billing/replaceCard.svelte | 2 +- .../billing/retryPaymentModal.svelte | 2 +- .../billing/wizard/paymentDetails.svelte | 3 ++- .../paymentDetails.svelte | 3 ++- 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/lib/stores/stripe.ts b/src/lib/stores/stripe.ts index 959b46ffc..93b4576ae 100644 --- a/src/lib/stores/stripe.ts +++ b/src/lib/stores/stripe.ts @@ -51,7 +51,7 @@ export async function unmountPaymentElement() { elements = null; } -export async function submitStripeCard(name: string, urlRoute?: string) { +export async function submitStripeCard(name: string, organizationId?: string) { try { // If a payment method was created during initialization, use it, otherwise create a new one if (!paymentMethod) { @@ -62,16 +62,20 @@ export async function submitStripeCard(name: string, urlRoute?: string) { // // Element needs to be submitted before confirming the setup intent elements.submit(); - const baseUrl = 'https://cloud.appwrite.io/console/'; + const baseUrl = 'https://cloud.appwrite.io/console'; + const accountUrl = `${baseUrl}/account/payments?clientSecret=${clientSecret}`; + const orgUrl = `${baseUrl}/organization-${organizationId}/billing?clientSecret=${clientSecret}`; + + const returnUrl = new URL(organizationId ? orgUrl : accountUrl); + + returnUrl.searchParams.append('clientSecret', clientSecret); + returnUrl.searchParams.append('paymentMethodId', paymentMethod.$id); const { setupIntent, error } = await get(stripe).confirmSetup({ elements, clientSecret, confirmParams: { - return_url: `${baseUrl}${ - urlRoute ?? - `organization-${get(organization).$id}/billing?clientSecret=${clientSecret}` - }`, + return_url: returnUrl.toString(), payment_method_data: { billing_details: { name diff --git a/src/routes/console/account/payments/+page.svelte b/src/routes/console/account/payments/+page.svelte index 8cca7e6f8..f4a654ac8 100644 --- a/src/routes/console/account/payments/+page.svelte +++ b/src/routes/console/account/payments/+page.svelte @@ -3,8 +3,21 @@ import { Container } from '$lib/layout'; import PaymentMethods from './paymentMethods.svelte'; import BillingAddress from './billingAddress.svelte'; + import { onMount } from 'svelte'; + import { page } from '$app/stores'; + import { confirmPayment } from '$lib/stores/stripe'; + import { user } from '$lib/stores/user'; let showPayment = false; + user; + + onMount(async () => { + if ($page.url.searchParams.has('clientSecret')) { + const clientSecret = $page.url.searchParams.get('clientSecret'); + const paymentMethodId = $page.url.searchParams.get('paymentMethodId'); + await confirmPayment('', clientSecret, paymentMethodId); + } + }); diff --git a/src/routes/console/account/payments/paymentModal.svelte b/src/routes/console/account/payments/paymentModal.svelte index dfd8b3caf..2ac93e0b2 100644 --- a/src/routes/console/account/payments/paymentModal.svelte +++ b/src/routes/console/account/payments/paymentModal.svelte @@ -6,6 +6,7 @@ import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; import { addNotification } from '$lib/stores/notifications'; + import { page } from '$app/stores'; export let show = false; @@ -20,7 +21,7 @@ async function handleSubmit() { try { - const card = await submitStripeCard(name, '/account/payments'); + const card = await submitStripeCard(name, $page?.params?.organization ?? null); invalidate(Dependencies.PAYMENT_METHODS); dispatch('submit', card); show = false; diff --git a/src/routes/console/organization-[organization]/billing/replaceCard.svelte b/src/routes/console/organization-[organization]/billing/replaceCard.svelte index e25348990..639964119 100644 --- a/src/routes/console/organization-[organization]/billing/replaceCard.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceCard.svelte @@ -33,7 +33,7 @@ async function handleSubmit() { try { if (!selectedPaymentMethodId) { - const method = await submitStripeCard(name); + const method = await submitStripeCard(name, $organization.$id); selectedPaymentMethodId = method.$id; } isBackup diff --git a/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte b/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte index 828782773..e0f034029 100644 --- a/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte +++ b/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte @@ -39,7 +39,7 @@ try { if (paymentMethodId === null) { try { - const method = await submitStripeCard(name); + const method = await submitStripeCard(name, $organization.$id); const card = await sdk.forConsole.billing.getPaymentMethod(method.$id); if (card?.last4) { paymentMethodId = card.$id; diff --git a/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte b/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte index b4f54264d..f9d34c28e 100644 --- a/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte +++ b/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte @@ -9,6 +9,7 @@ import { sdk } from '$lib/stores/sdk'; import { PaymentBoxes } from '$lib/components/billing'; import { addCreditWizardStore } from '../store'; + import { organization } from '$lib/stores/organization'; let methods: PaymentList; let name: string; @@ -21,7 +22,7 @@ async function handleSubmit() { try { - const method = await submitStripeCard(name); + const method = await submitStripeCard(name, $organization.$id); $addCreditWizardStore.paymentMethodId = method.$id; invalidate(Dependencies.PAYMENT_METHODS); } catch (e) { diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte index b82943719..f03feecca 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte @@ -13,6 +13,7 @@ import { symmetricDifference } from '$lib/helpers/array'; import { showUsageRatesModal } from '$lib/stores/billing'; import { PaymentBoxes } from '$lib/components/billing'; + import { page } from '$app/stores'; let methods: PaymentList; let filteredMethods: PaymentMethodData[]; @@ -48,7 +49,7 @@ } } else { try { - await submitStripeCard(name); + await submitStripeCard(name, $page?.params?.organization ?? null); const latestMethods = await sdk.forConsole.billing.listPaymentMethods(); const paymentMethod = symmetricDifference( methods.paymentMethods, From 1fe27cf03cd9e6e1fcbc815f63405c010aa576e0 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 13 Mar 2024 18:45:13 +0100 Subject: [PATCH 36/40] fix: 500 errors! --- src/hooks.client.ts | 13 +++++++++++++ src/routes/+error.svelte | 2 +- src/routes/console/+error.svelte | 8 +++++--- src/routes/console/project-[project]/+error.svelte | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/hooks.client.ts diff --git a/src/hooks.client.ts b/src/hooks.client.ts new file mode 100644 index 000000000..2345ffb2c --- /dev/null +++ b/src/hooks.client.ts @@ -0,0 +1,13 @@ +import { AppwriteException } from '@appwrite.io/console'; +import type { HandleClientError } from '@sveltejs/kit'; + +export const handleError: HandleClientError = async ({ error, message, status }) => { + if (error instanceof AppwriteException && error.code === 0) { + status = undefined; + message = error.message; + } + return { + message, + status + }; +}; diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index 4e9d8e540..8b914f299 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -6,7 +6,7 @@ - {$page.status} + {$page.error.status || 'Invalid Argument'} {$page.error.message} diff --git a/src/routes/console/+error.svelte b/src/routes/console/+error.svelte index 9a50e9be7..408a5afaa 100644 --- a/src/routes/console/+error.svelte +++ b/src/routes/console/+error.svelte @@ -6,7 +6,9 @@ - {$page.status} - {$page.error.message} - +
          + {$page.error.status || 'Invalid Argument'} + {$page.error.message} + +
          diff --git a/src/routes/console/project-[project]/+error.svelte b/src/routes/console/project-[project]/+error.svelte index 243be6e42..be0053176 100644 --- a/src/routes/console/project-[project]/+error.svelte +++ b/src/routes/console/project-[project]/+error.svelte @@ -5,6 +5,6 @@ - {$page.status} + {$page.error.status || 'Invalid Argument'}

          {$page.error.message}

          From 355a8628ca264c93ce3126542f352720200928cd Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 13 Mar 2024 18:47:38 +0100 Subject: [PATCH 37/40] fix: remove unused code --- src/routes/console/account/payments/+page.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/routes/console/account/payments/+page.svelte b/src/routes/console/account/payments/+page.svelte index f4a654ac8..1e00b42eb 100644 --- a/src/routes/console/account/payments/+page.svelte +++ b/src/routes/console/account/payments/+page.svelte @@ -6,10 +6,8 @@ import { onMount } from 'svelte'; import { page } from '$app/stores'; import { confirmPayment } from '$lib/stores/stripe'; - import { user } from '$lib/stores/user'; let showPayment = false; - user; onMount(async () => { if ($page.url.searchParams.has('clientSecret')) { From 8185fab2572d1a24343799c426c2521072aad203 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 14 Mar 2024 21:03:07 +0000 Subject: [PATCH 38/40] chore: fix-upgrade-wizard-flow --- .../paymentDetails.svelte | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte index f03feecca..99116f394 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte @@ -10,7 +10,6 @@ import { Dependencies } from '$lib/constants'; import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe'; import { organization } from '$lib/stores/organization'; - import { symmetricDifference } from '$lib/helpers/array'; import { showUsageRatesModal } from '$lib/stores/billing'; import { PaymentBoxes } from '$lib/components/billing'; import { page } from '$app/stores'; @@ -49,15 +48,10 @@ } } else { try { - await submitStripeCard(name, $page?.params?.organization ?? null); - const latestMethods = await sdk.forConsole.billing.listPaymentMethods(); - const paymentMethod = symmetricDifference( - methods.paymentMethods, - latestMethods.paymentMethods - )[0] as PaymentMethodData; - const card = await sdk.forConsole.billing.getPaymentMethod(paymentMethod.$id); + const method = await submitStripeCard(name, $page?.params?.organization ?? null); + const card = await sdk.forConsole.billing.getPaymentMethod(method.$id); if (card?.last4) { - $changeOrganizationTier.paymentMethodId = paymentMethod.$id; + $changeOrganizationTier.paymentMethodId = method.$id; } else { throw new Error( 'The payment method you selected is not valid. Please select a different one.' From 71bb3fc7d4e541fa01273a4a195e25f894bba6a7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 19 Mar 2024 11:20:37 +0200 Subject: [PATCH 39/40] fix: state waterfall --- src/routes/+layout.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 14cb350c0..84fdba79b 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -13,9 +13,10 @@ export const ssr = false; export const load: LayoutLoad = async ({ depends, url }) => { depends(Dependencies.ACCOUNT); - redirectTo.set(url.searchParams.get('forceRedirect') || null); - - url.searchParams.delete('forceRedirect'); + if (url.searchParams.has('forceRedirect')) { + redirectTo.set(url.searchParams.get('forceRedirect') || null); + url.searchParams.delete('forceRedirect'); + } try { const account = await sdk.forConsole.account.get<{ organization?: string }>(); From 636fa27e2f5a9ff7fbdc21cf8aaef42f8e2c6341 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Mar 2024 10:53:12 +0100 Subject: [PATCH 40/40] fix: billings checks on load --- src/lib/stores/billing.ts | 1 + src/routes/console/+layout.svelte | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index b2f00db39..c213a7147 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -279,6 +279,7 @@ export const paymentMissingMandate = writable(null); export async function checkForMandate(org: Organization) { const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId; + if (!paymentId) return; const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentId); if (paymentMethod.mandateId === null && paymentMethod.country === 'in') { headerAlert.add({ diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index b12da8a70..6e59612b4 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -1,6 +1,6 @@