From e511e023456fe77700e1ec79f70cdaee2812025e Mon Sep 17 00:00:00 2001 From: sourabpramanik Date: Sat, 6 Jan 2024 07:30:32 +0530 Subject: [PATCH 01/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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/25] 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 3d1b6b72034d5df4b27a298570c5922118fefcad Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 12:49:46 +0100 Subject: [PATCH 08/25] 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 09/25] 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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 14/25] 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 15/25] 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 16/25] 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 17/25] 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 18/25] 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 19/25] 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 20/25] 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 21/25] 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 22/25] 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 23/25] 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 10:46:13 +0100 Subject: [PATCH 24/25] fix: tests --- vite.config.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index fe5794f12..ca167b2f9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -41,6 +41,11 @@ const testConfig = defineConfig({ include: ['@analytics/type-utils'] } } + }, + server: { + deps: { + inline: ['@analytics/type-utils'] + } } } }); From 94fd7847c113dfaebf977d4ad3f7ffcc2053c50c Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 11 Mar 2024 10:57:45 +0100 Subject: [PATCH 25/25] chore: remove unused config --- vite.config.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index ca167b2f9..de1c825dd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,13 +35,6 @@ const testConfig = defineConfig({ globals: true, pool: 'threads', setupFiles: ['./tests/unit/setup.ts'], - deps: { - optimizer: { - web: { - include: ['@analytics/type-utils'] - } - } - }, server: { deps: { inline: ['@analytics/type-utils']