diff --git a/package.json b/package.json index f83b6c58e..64818c5f9 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@appwrite.io/pink-icons": "0.25.0", "@appwrite.io/pink-icons-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c2131", "@appwrite.io/pink-legacy": "^1.0.1", - "@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@011c2131", + "@appwrite.io/pink-svelte": "https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@e87d552", "@popperjs/core": "^2.11.8", "@sentry/sveltekit": "^8.38.0", "@stripe/stripe-js": "^3.5.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85b8a35ec..5bab9a8b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ importers: specifier: ^1.0.1 version: 1.0.1 '@appwrite.io/pink-svelte': - specifier: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@011c2131 - version: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@011c2131(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19) + specifier: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@e87d552 + version: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@e87d552(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19) '@popperjs/core': specifier: ^2.11.8 version: 2.11.8 @@ -221,8 +221,8 @@ packages: peerDependencies: svelte: ^4.0.0 - '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c21311ddfbacaa53563f02a1dcba32db8b595': - resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c21311ddfbacaa53563f02a1dcba32db8b595} + '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@e87d5523b50e063bfe0d3b846d5db171a24b0792': + resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@e87d5523b50e063bfe0d3b846d5db171a24b0792} version: 1.0.0-next.7 peerDependencies: svelte: ^4.0.0 @@ -236,8 +236,8 @@ packages: '@appwrite.io/pink-legacy@1.0.1': resolution: {integrity: sha512-e5IZx2drqSxgl2WXvmr0eLfg/WiOCzuqQE8oksD+9GoFBkcL9HWvXul5GjFni3RBAN9XFRL3nUExGk4T0H8sFw==} - '@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@011c2131': - resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@011c2131} + '@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@e87d552': + resolution: {tarball: https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@e87d552} version: 1.0.0-next.85 peerDependencies: react-dom: ^18.0.0 @@ -4103,7 +4103,7 @@ snapshots: dependencies: svelte: 4.2.19 - '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c21311ddfbacaa53563f02a1dcba32db8b595(svelte@4.2.19)': + '@appwrite.io/pink-icons-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@e87d5523b50e063bfe0d3b846d5db171a24b0792(svelte@4.2.19)': dependencies: svelte: 4.2.19 @@ -4116,9 +4116,9 @@ snapshots: '@appwrite.io/pink-icons': 1.0.0 the-new-css-reset: 1.11.3 - '@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@011c2131(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19)': + '@appwrite.io/pink-svelte@https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-svelte@e87d552(react-dom@18.3.1(react@18.3.1))(svelte@4.2.19)': dependencies: - '@appwrite.io/pink-icons-svelte': https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@011c21311ddfbacaa53563f02a1dcba32db8b595(svelte@4.2.19) + '@appwrite.io/pink-icons-svelte': https://pkg.pr.new/appwrite/pink/@appwrite.io/pink-icons-svelte@e87d5523b50e063bfe0d3b846d5db171a24b0792(svelte@4.2.19) '@floating-ui/dom': 1.6.13 '@melt-ui/pp': 0.3.2(@melt-ui/svelte@0.86.3(svelte@4.2.19))(svelte@4.2.19) '@melt-ui/svelte': 0.86.3(svelte@4.2.19) diff --git a/src/lib/components/confirm.svelte b/src/lib/components/confirm.svelte index 6faebac89..6e37223d5 100644 --- a/src/lib/components/confirm.svelte +++ b/src/lib/components/confirm.svelte @@ -1,5 +1,5 @@
@@ -25,13 +29,30 @@ {error} {/if} - + + + + + {#if confirmDeletion} + + {/if} + + {#if canDelete} - + {/if} diff --git a/src/lib/components/navbar.svelte b/src/lib/components/navbar.svelte index 0585199b5..f867e519f 100644 --- a/src/lib/components/navbar.svelte +++ b/src/lib/components/navbar.svelte @@ -44,6 +44,7 @@ import { isTabletViewport } from '$lib/stores/viewport'; import { isCloud } from '$lib/system.js'; import { user } from '$lib/stores/user'; + import { trackEvent } from '$lib/actions/analytics'; let showSupport = false; @@ -68,6 +69,10 @@ : 'light' : theme; + trackEvent('select_theme', { + value: theme === 'auto' ? 'system' : theme + }); + app.update(() => ({ themeInUse: themeInUse, theme: theme @@ -115,7 +120,7 @@ {#if selectedProject && selectedProject.pingCount === 0} -
+
{ + trackEvent('click_organization_upgrade', { + from: 'button', + source: 'top_nav' + }); + }} href={`${base}/organization-${currentOrg.$id}/change-plan`} >Upgrade {/if} - toggleFeedback()} + { + toggleFeedback(); + trackEvent('click_menu_feedback', { source: 'top_nav' }); + }} >Feedback @@ -152,7 +169,10 @@ (showSupport = !showSupport)}> + on:click={() => { + showSupport = !showSupport; + trackEvent('click_menu_support', { source: 'top_nav' }); + }}> Support @@ -174,6 +194,9 @@ { showAccountMenu = !showAccountMenu; + if (showAccountMenu) { + trackEvent('click_menu_dropdown'); + } }}>
diff --git a/src/lib/components/sidebar.svelte b/src/lib/components/sidebar.svelte index 74ab11d61..d47bcf2d3 100644 --- a/src/lib/components/sidebar.svelte +++ b/src/lib/components/sidebar.svelte @@ -34,6 +34,7 @@ import MobileFeedbackModal from '$routes/(console)/wizard/feedback/mobileFeedbackModal.svelte'; import { getSidebarState, updateSidebarState } from '$lib/helpers/sidebar'; import { isTabletViewport } from '$lib/stores/viewport'; + import { trackEvent } from '$lib/actions/analytics'; type $$Props = HTMLElement & { state?: 'closed' | 'open' | 'icons'; @@ -66,6 +67,7 @@ $: state = $isTabletViewport ? 'closed' : getSidebarState(); $: pathname = $page.url.pathname; + $: isOnProjectSettings = /^\/console\/project-[a-zA-Z0-9-]+\/settings$/.test(pathname); const projectOptions = [ { name: 'Auth', icon: IconUserGroup, slug: 'auth' }, @@ -111,6 +113,7 @@ class="progress-card" href={`/console/project-${project.$id}/get-started`} on:click={() => { + trackEvent('click_menu_get_started'); sideBarIsOpen = false; }}>
@@ -138,6 +141,7 @@ class="link" class:active={pathname.includes('overview')} on:click={() => { + trackEvent('click_menu_overview'); sideBarIsOpen = false; }} > { + trackEvent(`click_menu_${projectOption.slug}`); sideBarIsOpen = false; }} >
- { + trackEvent('click_menu_settings'); + }} + class="link" > toggleFeedback()} + on:click={() => { + toggleFeedback(); + trackEvent('click_menu_feedback', { source: 'side_nav' }); + }} >Feedback @@ -212,7 +225,10 @@ ($showSupportModal = true)}> + on:click={() => { + $showSupportModal = true; + trackEvent('click_menu_support', { source: 'side_nav' }); + }}> Support @@ -232,7 +248,10 @@ { + trackEvent('click_menu_settings'); + }} + class:active={isOnProjectSettings} > toggleFeedback()} + on:click={() => { + toggleFeedback(); + trackEvent('click_menu_feedback', { source: 'side_nav' }); + }} >Feedback @@ -263,7 +285,10 @@ ($showSupportModal = true)}> + on:click={() => { + $showSupportModal = true; + trackEvent('click_menu_support', { source: 'side_nav' }); + }}> Support diff --git a/src/lib/components/usageCard.svelte b/src/lib/components/usageCard.svelte index 2d4d4a0b7..af652f91d 100644 --- a/src/lib/components/usageCard.svelte +++ b/src/lib/components/usageCard.svelte @@ -16,7 +16,7 @@ {value} {:else} - + {/if} diff --git a/src/lib/elements/forms/inputCheckbox.svelte b/src/lib/elements/forms/inputCheckbox.svelte index 844f18c25..9ccb04f53 100644 --- a/src/lib/elements/forms/inputCheckbox.svelte +++ b/src/lib/elements/forms/inputCheckbox.svelte @@ -11,6 +11,7 @@ element?: HTMLInputElement | undefined; indeterminate?: boolean; size?: 's' | 'm'; + description?: string; } export let id: string = ''; @@ -20,6 +21,7 @@ export let disabled = false; export let element: HTMLInputElement | undefined = undefined; export let size: $$Props['size'] = 's'; + export let description = ''; let error: string; const handleInvalid = (event: Event) => { @@ -47,6 +49,7 @@ {size} {label} {required} + {description} on:invalid={handleInvalid} on:click on:change /> diff --git a/src/lib/pages/domains/delete.svelte b/src/lib/pages/domains/delete.svelte index 98090caee..a1edc8f14 100644 --- a/src/lib/pages/domains/delete.svelte +++ b/src/lib/pages/domains/delete.svelte @@ -1,11 +1,9 @@ -a - Are you sure you want to delete {selectedDomain?.domain}? You will no longer be able to - execute your function by visiting this domain. +

Are you sure you want to delete {selectedDomain?.domain}?

+

You will no longer be able to {getCorrectMessage()} by visiting this domain.

diff --git a/src/lib/wizards/functions/createTemplate.svelte b/src/lib/wizards/functions/createTemplate.svelte index e41bf78dc..ae703bc45 100644 --- a/src/lib/wizards/functions/createTemplate.svelte +++ b/src/lib/wizards/functions/createTemplate.svelte @@ -55,10 +55,6 @@ $templateConfig.repositoryBehaviour === 'manual' ? undefined : $choices.rootDir || undefined, - $template.providerRepositoryId || undefined, - $template.providerOwner || undefined, - runtimeDetail.providerRootDirectory || undefined, - $template.providerVersion || undefined, $templateConfig.specification || undefined ); diff --git a/src/routes/(console)/account/delete.svelte b/src/routes/(console)/account/delete.svelte index d81d4fe7b..b7bf6fa15 100644 --- a/src/routes/(console)/account/delete.svelte +++ b/src/routes/(console)/account/delete.svelte @@ -3,10 +3,8 @@ import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; import Confirm from '$lib/components/confirm.svelte'; import { Dependencies } from '$lib/constants'; - import { Button, Form } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; - import { Dialog, Layout } from '@appwrite.io/pink-svelte'; export let showDelete = false; let error: string; diff --git a/src/routes/(console)/account/deleteMfa.svelte b/src/routes/(console)/account/deleteMfa.svelte index b709f001d..e37bd9d49 100644 --- a/src/routes/(console)/account/deleteMfa.svelte +++ b/src/routes/(console)/account/deleteMfa.svelte @@ -38,6 +38,6 @@ title="Delete authentication method" bind:open={showDelete} bind:error> - Are you sure you want to delete this authentication method? You will no longer be able to use - this method to authenticate your account. +

Are you sure you want to delete this authentication method?

+

You will no longer be able to use this method to authenticate your account.

diff --git a/src/routes/(console)/onboarding/+page.svelte b/src/routes/(console)/onboarding/+page.svelte deleted file mode 100644 index e4c1f1ae7..000000000 --- a/src/routes/(console)/onboarding/+page.svelte +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Create a new organization - - - - {#if isCloud} -
-

Plan

-

- For more details on our plans, visit our . -

- - - -
- {/if} - -
- -
-
diff --git a/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte b/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte index 56b5d9b9f..bbe3b6924 100644 --- a/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/deleteDomainModal.svelte @@ -1,5 +1,4 @@ - - {#if selectedDomain} -

- Are you sure you want to delete {selectedDomain.domain}? You will no longer be - able to execute your function by visiting this domain. -

- {/if} - - - - - + +

Are you sure you want to delete {selectedDomain?.domain}?

+

You will no longer be able to {getCorrectMessage()} by visiting this domain.

diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte index ef2ed13c0..f0f5ec638 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/deleteCertificateModal.svelte @@ -30,11 +30,5 @@ - - Are you sure you want to delete SSL certificate? This action is irreversible. - - - - - + Are you sure you want to delete SSL certificate? This action is irreversible. diff --git a/src/routes/(console)/project-[project]/functions/create-function/store.ts b/src/routes/(console)/project-[project]/functions/create-function/store.ts index 79a1345b4..b248d6630 100644 --- a/src/routes/(console)/project-[project]/functions/create-function/store.ts +++ b/src/routes/(console)/project-[project]/functions/create-function/store.ts @@ -14,6 +14,7 @@ export const templateConfig = writable<{ repositoryId: string; execute?: boolean; scopes?: string[]; + specification?: string; }>(); export const choices = writable<{ diff --git a/src/routes/(console)/project-[project]/functions/create-function/wizard/createTemplate.svelte b/src/routes/(console)/project-[project]/functions/create-function/wizard/createTemplate.svelte index e9f07cc22..11107b9ef 100644 --- a/src/routes/(console)/project-[project]/functions/create-function/wizard/createTemplate.svelte +++ b/src/routes/(console)/project-[project]/functions/create-function/wizard/createTemplate.svelte @@ -49,10 +49,7 @@ $templateConfig.repositoryBehaviour === 'manual' ? undefined : $choices.rootDir || undefined, - $template.providerRepositoryId || undefined, - $template.providerOwner || undefined, - runtimeDetail.providerRootDirectory || undefined, - $template.providerVersion || undefined + $templateConfig.specification ); if ($templateConfig.variables) { diff --git a/src/routes/(console)/project-[project]/overview/header.svelte b/src/routes/(console)/project-[project]/overview/header.svelte index be16c1b39..d3251dceb 100644 --- a/src/routes/(console)/project-[project]/overview/header.svelte +++ b/src/routes/(console)/project-[project]/overview/header.svelte @@ -10,6 +10,7 @@ import { user } from '$lib/stores/user'; import { isSmallViewport } from '$lib/stores/viewport'; import { Dependencies } from '$lib/constants'; + import { trackEvent } from '$lib/actions/analytics'; {#if !$page.url.pathname.includes('get-started')} @@ -45,6 +46,7 @@ variant="secondary" size="s" on:click={async () => { + trackEvent('onboarding_hub_platform_dismiss'); await setHasOnboardingDismissed($project.$id); goto(`${base}/project-${$project.$id}/overview`); requestAnimationFrame(() => { diff --git a/src/routes/(console)/project-[project]/overview/onboard.svelte b/src/routes/(console)/project-[project]/overview/onboard.svelte index feeb49746..4c191ff50 100644 --- a/src/routes/(console)/project-[project]/overview/onboard.svelte +++ b/src/routes/(console)/project-[project]/overview/onboard.svelte @@ -37,8 +37,15 @@ import { AvatarGroup } from '$lib/components'; import type { Models } from '@appwrite.io/console'; import { getPlatformInfo } from '$lib/helpers/platform'; + import { trackEvent } from '$lib/actions/analytics'; + import { redirect } from '@sveltejs/kit'; + import { goto } from '$app/navigation'; function createKey() { + trackEvent('onboarding_hub_platform', { + platform: 'server', + state: 'add' + }); wizard.start(Wizard); } @@ -386,7 +393,12 @@ - addPlatform(0)} padding="s" + { + trackEvent('onboarding_hub_setup_databases'); + goto(`${base}/project-${projectId}/databases`); + }} + padding="s" >
{ + trackEvent( + 'onboarding_hub_api_references' + ); + }} target="_blank">API references { + trackEvent('onboarding_hub_tutorials'); + }} target="_blank">Tutorials { + trackEvent( + 'onboarding_hub_storage_quick_start' + ); + }} target="_blank" >Storage quick start { + trackEvent( + 'onboarding_hub_functions_quick_start' + ); + }} target="_blank" >Functions quick start @@ -458,16 +488,29 @@ { + trackEvent( + 'onboarding_hub_auth_email_password' + ); + }} >E-mail and password OAuth 2 + on:click={() => { + trackEvent( + 'onboarding_hub_auth_oauth2' + ); + }}>OAuth 2 View all methods + on:click={() => { + trackEvent( + 'onboarding_hub_auth_all_methods' + ); + }}>View all methods
- + { + trackEvent('onboarding_hub_discord'); + }}>
diff --git a/src/routes/(console)/project-[project]/overview/platforms/+page.svelte b/src/routes/(console)/project-[project]/overview/platforms/+page.svelte index 370775bf8..0842bffc4 100644 --- a/src/routes/(console)/project-[project]/overview/platforms/+page.svelte +++ b/src/routes/(console)/project-[project]/overview/platforms/+page.svelte @@ -1,6 +1,4 @@

{#if deployment.providerCommitAuthor} - - {capitalize(timeFromNow(deployment.$updatedAt))} - + + + {capitalize(timeFromNow(deployment.$updatedAt))} + + {toLocaleDateTime(deployment.$updatedAt)} + by {deployment.providerCommitAuthor} {:else} - - {capitalize(timeFromNow(deployment.$updatedAt))} - + + + {capitalize(timeFromNow(deployment.$updatedAt))} + + {toLocaleDateTime(deployment.$updatedAt)} + {/if}

diff --git a/src/routes/(console)/project-[project]/sites/(components)/deploymentSource.svelte b/src/routes/(console)/project-[project]/sites/(components)/deploymentSource.svelte index ff94b5d96..3dce20f83 100644 --- a/src/routes/(console)/project-[project]/sites/(components)/deploymentSource.svelte +++ b/src/routes/(console)/project-[project]/sites/(components)/deploymentSource.svelte @@ -28,7 +28,7 @@
- + {#if deployment?.providerCommitMessage && deployment?.providerCommitHash && deployment?.providerCommitUrl} -
{#key buildLogs} - + {/key} {#if ['processing', 'building'].includes(status)} diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/+page.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/+page.svelte index 582454b82..abda0ca03 100644 --- a/src/routes/(console)/project-[project]/sites/site-[site]/+page.svelte +++ b/src/routes/(console)/project-[project]/sites/site-[site]/+page.svelte @@ -7,23 +7,33 @@ import { Button } from '$lib/elements/forms'; import { protocol } from '$routes/(console)/store'; import InstantRollbackDomain from './instantRollbackDomain.svelte'; - import { base } from '$app/paths'; - import { page } from '$app/stores'; - import { invalidate } from '$app/navigation'; - import { Dependencies } from '$lib/constants'; import { app } from '$lib/stores/app'; import EmptyDeploymentDark from './empty-deployment-dark.svg'; import EmptyDeploymentLight from './empty-deployment-light.svg'; + import { sdk } from '$lib/stores/sdk'; + import { invalidate } from '$app/navigation'; + import { Dependencies } from '$lib/constants'; + import { onMount } from 'svelte'; + import { page } from '$app/stores'; export let data; let showRollback = false; - $: console.log(data.site); - $: console.log(data.deployment); - $: console.log(data.deploymentList); - $: console.log(data.proxyRuleList); + let unsubscribe: { (): void }; - // TODO: dark mode empty state + onMount(() => { + unsubscribe = sdk.forConsole.client.subscribe('console', (response) => { + if (response.events.includes(`sites.${$page.params.site}.deployments.*`)) { + console.log('test'); + invalidate(Dependencies.SITE); + } + }); + }); + + // $: console.log(data.site); + $: console.log(data.deployment); + // $: console.log(data.deploymentList); + // $: console.log(data.proxyRuleList); @@ -37,7 +47,7 @@ >Instant rollback - {:else} + {:else if data.deployment?.status === 'building'} - - - - - + + + {:else} + + + + You haven't deployed any sites yet. Get started by deploying your first + site. + {/if} diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte index 097c73a92..0b696c04f 100644 --- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte @@ -94,11 +94,12 @@ Create deployment - - + + { + on:click={(e) => { + toggle(e); if (!hasInstallation) { showConnectRepo = true; } else { @@ -108,13 +109,15 @@ Git { + on:click={(e) => { + toggle(e); showConnectCLI = true; }}> CLI { + on:click={(e) => { + toggle(e); showConnectManual = true; }}> Manual diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte index 7122848cd..223784b0b 100644 --- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte @@ -4,80 +4,81 @@ import { Repositories } from '$lib/components/git'; import { Dependencies } from '$lib/constants'; import { Link } from '$lib/elements'; - import { Button } from '$lib/elements/forms'; - import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; + import { Button, InputCheckbox, InputSelect } from '$lib/elements/forms'; + import { timeFromNow } from '$lib/helpers/date'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; import { installation, repository, sortBranches } from '$lib/stores/vcs'; - import type { BuildRuntime, Framework, Models } from '@appwrite.io/console'; + import { Type, type Models } from '@appwrite.io/console'; import { IconGithub } from '@appwrite.io/pink-icons-svelte'; - import { Icon, InlineCode, Layout, Spinner, Typography } from '@appwrite.io/pink-svelte'; - import { onMount } from 'svelte'; + import { Icon, Layout, Skeleton, Typography } from '@appwrite.io/pink-svelte'; export let show = false; export let site: Models.Site; let installations = { installations: [], total: 0 }; let hasRepository = !!site?.providerRepositoryId; - let selectedRepository: string = null; + let selectedRepository: string = site.providerRepositoryId; let branch: string = null; + let activate = true; let error = ''; - onMount(async () => { - installations = await sdk.forProject.vcs.listInstallations(); - if (!site?.installationId && installations.total > 0) { - installation.set(installations.installations[0]); - } - if (!$repository?.id && hasRepository) { - $repository = await sdk.forProject.vcs.getRepository( - $installation.$id, - site.providerRepositoryId + async function loadInstallations() { + try { + installations = await sdk.forProject.vcs.listInstallations(); + if (!site?.installationId && installations.total > 0) { + installation.set(installations.installations[0]); + } + $installation = installations.installations.find( + (installation) => installation.$id === site.installationId ); + if (!$installation?.$id) { + $installation = installations.installations[0]; + } + } catch (error) { + console.log(error); } - console.log(installations); - }); + } - async function loadBranches() { - const { branches } = await sdk.forProject.vcs.listRepositoryBranches( - $installation.$id, - selectedRepository - ); - const sorted = sortBranches(branches); - branch = sorted[0]?.name ?? null; + async function load() { + try { + await loadInstallations(); + if (!$repository?.id && hasRepository) { + $repository = await sdk.forProject.vcs.getRepository( + $installation.$id, + site.providerRepositoryId + ); + } + const branchList = await sdk.forProject.vcs.listRepositoryBranches( + $installation.$id, + selectedRepository + ); - if (!branch) { - branch = 'main'; + console.log(branchList); + + const sorted = sortBranches(branchList.branches); + branch = sorted[0]?.name ?? null; + + if (!branch) { + branch = 'main'; + } + + return sorted; + } catch (error) { + console.log(installations); + console.log(error); } - - return sorted; } async function createDeployment() { try { - if (!site.installationId || !site.providerRepositoryId || !branch) { - await sdk.forProject.sites.update( - site.$id, - site.name, - site?.framework as Framework, - site.enabled || undefined, - site.timeout || undefined, - site.installCommand || undefined, - site.buildCommand || undefined, - site.outputDirectory || undefined, - (site?.buildRuntime as BuildRuntime) || undefined, - site.adapter || undefined, - site.fallbackFile || undefined, - site.installationId || $installation.$id || undefined, - site.providerRepositoryId || $repository.id || undefined, - branch, - site.providerSilentMode || undefined, - undefined //TODO: add dir? - ); - } + await sdk.forProject.sites.createVcsDeployment(site.$id, Type.Branch, branch, activate); show = false; invalidate(Dependencies.DEPLOYMENTS); addNotification({ - message: 'Deployment has been created successfully', + message: activate + ? 'Deployment is in progress. It will be automatically activated after build step completes.' + : 'Deployment is in progress. You can activate it after build step completes.', type: 'success' }); } catch (e) { @@ -88,26 +89,26 @@ - Enter a valid commit reference to create a new deployment from or - use the CLI to deploy. Learn more + Enter a valid commit reference to create a new deployment. Learn more - {#if installations && hasRepository} - - - - - - {$repository?.organization}/{$repository?.name} - + {#if hasRepository} + {#await load()} + + + + + + + + + + - - {#await loadBranches()} - {:then branches} {@const options = branches @@ -120,24 +121,48 @@ ?.sort((a, b) => { return a.label > b.label ? 1 : -1; }) ?? []} - - + + + + + + {$repository?.organization}/{$repository?.name} + + + + + Last updated {timeFromNow($repository?.pushedAt)} + + + + { branch = event.detail.value; }} - interactiveOutput - name="branch" {options} /> + {#if branch} + + {/if} {/await} - {/if} - {#if !hasRepository} + {:else} - + diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentMetrics.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentMetrics.svelte index 1d6ff03bd..099dcee3d 100644 --- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentMetrics.svelte +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentMetrics.svelte @@ -55,21 +55,25 @@ }); async function fetchUsage() { - metrics.forEach((metric) => { - metric.value = null; - }); - metrics = metrics; - try { - const usage = await sdk.forProject.sites.getUsage($page.params.site, range); - metrics = metrics.map((metric) => { - metric.value = usage[metric.id] ?? '-'; - return metric; + // Add timeout to make it look nicer + setTimeout(async () => { + metrics.forEach((metric) => { + metric.value = null; }); metrics = metrics; - console.log(usage); - } catch (error) { - console.log(error); - } + + try { + const usage = await sdk.forProject.sites.getUsage($page.params.site, range); + metrics = metrics.map((metric) => { + metric.value = usage[metric.id] ?? '-'; + return metric; + }); + metrics = metrics; + console.log(usage); + } catch (error) { + console.log(error); + } + }, 800); } $: console.log(metrics); @@ -95,9 +99,9 @@ on:change={fetchUsage} />
- + {#each metrics as metric} {/each} - + diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/quickFilters.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/quickFilters.svelte index f9efb05bd..0252024c3 100644 --- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/quickFilters.svelte +++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/quickFilters.svelte @@ -193,7 +193,7 @@ - + {#each filter.options as option (option.value + option.checked)} Are you sure you want to delete {selectedDomain.domain}? You will no longer be - able to execute your function by visiting this domain. + able to view your site by visiting this domain.

{/if}