Merge remote-tracking branch 'origin/feat-project-changes' into feat-project-changes-2

This commit is contained in:
Damodar Lohani
2025-06-24 05:20:55 +00:00
10 changed files with 69 additions and 41 deletions
@@ -33,6 +33,7 @@
import { onMount } from 'svelte';
import { loadAvailableRegions } from '$routes/(console)/regions';
import EstimatedTotalBox from '$lib/components/billing/estimatedTotalBox.svelte';
import { Query } from '@appwrite.io/console';
export let data;
@@ -105,6 +106,34 @@
}
}
async function trackDowngradeFeedback() {
const paidInvoices = await sdk.forConsole.billing.listInvoices(data.organization.$id, [
Query.equal('status', 'succeeded'),
Query.greaterThan('grossAmount', 0)
]);
await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: tierToPlan(data.organization.billingPlan).name,
to: tierToPlan(selectedPlan).name,
email: data.account.email,
reason: feedbackDowngradeOptions.find(
(option) => option.value === feedbackDowngradeReason
)?.label,
orgId: data.organization.$id,
userId: data.account.$id,
orgAge: data.organization.$createdAt,
userAge: data.account.$createdAt,
paidInvoices: paidInvoices.total,
message: feedbackMessage ?? ''
})
});
}
async function downgrade() {
try {
await sdk.forConsole.billing.updatePlan(
@@ -114,23 +143,7 @@
null
);
await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: tierToPlan(data.organization.billingPlan).name,
to: tierToPlan(selectedPlan).name,
email: data.account.email,
reason: feedbackDowngradeOptions.find(
(option) => option.value === feedbackDowngradeReason
)?.label,
orgId: data.organization.$id,
userId: data.account.$id,
message: feedbackMessage ?? ''
})
});
trackDowngradeFeedback();
await invalidate(Dependencies.ORGANIZATION);
@@ -37,7 +37,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
error = 'Only .txt files allowed';
} else if (reason === InvalidFileType.SIZE) {
@@ -130,7 +130,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',
@@ -48,7 +48,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
error = 'Only .tar.gz files allowed';
} else if (reason === InvalidFileType.SIZE) {
@@ -58,7 +58,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
addNotification({
@@ -14,17 +14,13 @@
import { BuildRuntime, Framework, ID } from '@appwrite.io/console';
import type { Models } from '@appwrite.io/console';
import Configuration from '../configuration.svelte';
import { buildVerboseDomain } from '../store';
import {
project,
regionalConsoleVariables
} from '$routes/(console)/project-[region]-[project]/store';
import { organization } from '$lib/stores/organization';
import { regionalConsoleVariables } from '../../../store';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import { InvalidFileType, removeFile } from '$lib/helpers/files';
import { humanFileSize } from '$lib/helpers/sizeConvertion';
import { isCloud } from '$lib/system';
import { currentPlan } from '$lib/stores/organization';
import Domain from '../domain.svelte';
export let data;
let showExitModal = false;
@@ -34,7 +30,8 @@
let name = 'My website';
let id = ID.unique();
let domain = `${id}.${$regionalConsoleVariables._APP_DOMAIN_SITES}`;
let domain = data.domain;
let domainIsValid = true;
let framework: Models.Framework =
data.frameworks.frameworks?.find((f) => f.key === 'other') ??
data.frameworks.frameworks?.[0];
@@ -54,13 +51,13 @@
async function create() {
try {
domain = await buildVerboseDomain(
$regionalConsoleVariables._APP_DOMAIN_SITES,
name,
$organization.name,
$project.name,
id
);
if (!domainIsValid) {
addNotification({
type: 'error',
message: 'Domain is not valid'
});
return;
}
const fr = Object.values(Framework).find((f) => f === framework.key);
const buildRuntime = Object.values(BuildRuntime).find(
@@ -138,7 +135,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',
@@ -233,6 +230,8 @@
bind:selectedFramework={framework}
bind:variables
frameworks={data.frameworks.frameworks} />
<Domain bind:domain bind:domainIsValid />
</Layout.Stack>
</Form>
<svelte:fragment slot="aside">
@@ -1,9 +1,20 @@
import { sdk } from '$lib/stores/sdk';
import { ID } from '@appwrite.io/console';
import { buildVerboseDomain } from '../store';
export const load = async ({ parent, params }) => {
const { frameworks } = await parent();
const { frameworks, project, organization, regionalConsoleVariables } = await parent();
const domain = await buildVerboseDomain(
regionalConsoleVariables._APP_DOMAIN_SITES,
'', // name
organization.name,
project.name,
ID.unique()
);
return {
domain,
frameworks,
template: await sdk
.forProject(params.region, params.project)
@@ -28,10 +28,15 @@ export async function buildVerboseDomain(
: '';
const safeUnique = unique ? toURLSafe(unique).toLowerCase() : ID.unique();
let domain = `${safeName}`;
if (await checkDomain(domain, apex)) {
if (domain && (await checkDomain(domain, apex))) {
return domain;
}
domain += '-' + safeSpecifier;
if (domain) {
domain += '-';
}
domain += safeSpecifier;
if (await checkDomain(domain, apex)) {
return domain;
}
@@ -42,7 +42,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
error = 'Only .tar.gz files allowed';
} else if (reason === InvalidFileType.SIZE) {
@@ -76,7 +76,7 @@
}
function handleInvalid(e: CustomEvent) {
const reason = e.detail.reason;
const reason = e.detail?.reason ?? '';
if (reason === InvalidFileType.EXTENSION) {
addNotification({
type: 'error',