diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index d94646764..210e1471f 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -187,6 +187,7 @@ export enum Submit { FunctionUpdateLogging = 'submit_function_update_logging', FunctionUpdateTimeout = 'submit_function_update_timeout', FunctionUpdateEvents = 'submit_function_update_events', + FunctionConnectRepo = 'submit_function_disconnect_repo', FunctionDisconnectRepo = 'submit_function_disconnect_repo', FunctionRedeploy = 'submit_function_redeploy', DeploymentCreate = 'submit_deployment_create', diff --git a/src/lib/wizards/functions/components/repositories.svelte b/src/lib/wizards/functions/components/repositories.svelte index 809881601..99c760e94 100644 --- a/src/lib/wizards/functions/components/repositories.svelte +++ b/src/lib/wizards/functions/components/repositories.svelte @@ -16,7 +16,7 @@ export let hasInstallations = false; export let action: 'button' | 'select' = 'select'; let offset = 0; - const limit = 1; + const limit = 5; $: { hasInstallations = $installations?.total > 0; diff --git a/src/lib/wizards/functions/connectExisting.svelte b/src/lib/wizards/functions/connectExisting.svelte index 5ab52f5e1..839bd8dd6 100644 --- a/src/lib/wizards/functions/connectExisting.svelte +++ b/src/lib/wizards/functions/connectExisting.svelte @@ -9,29 +9,42 @@ import { wizard } from '$lib/stores/wizard'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { addNotification } from '$lib/stores/notifications'; + import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; async function createGitHubInstallation() { - await sdk.forProject.functions.update( - $func.$id, - $func.name, - $func.runtime, - $func.entrypoint || undefined, - $func.execute || undefined, - $func.events || undefined, - $func.schedule || undefined, - $func.timeout || undefined, - $func.enabled || undefined, - $func.logging || undefined, - $func.commands || undefined, - $installation.$id, - $repository.id, - $choices.branch, - $choices.silentMode, - $choices.rootDir - ); - await invalidate(Dependencies.FUNCTION); - resetState(); - wizard.hide(); + try { + await sdk.forProject.functions.update( + $func.$id, + $func.name, + $func.runtime, + $func.entrypoint || undefined, + $func.execute || undefined, + $func.events || undefined, + $func.schedule || undefined, + $func.timeout || undefined, + $func.enabled || undefined, + $func.logging || undefined, + $func.commands || undefined, + $installation.$id, + $repository.id, + $choices.branch, + $choices.silentMode, + $choices.rootDir + ); + trackEvent(Submit.FunctionConnectRepo, { + customId: !!$func.$id + }); + await invalidate(Dependencies.FUNCTION); + resetState(); + wizard.hide(); + } catch (error) { + addNotification({ + message: error.message, + type: 'error' + }); + trackError(error, Submit.FunctionConnectRepo); + } } function resetState() { diff --git a/src/lib/wizards/functions/createGit.svelte b/src/lib/wizards/functions/createGit.svelte index 4d5a85f38..ccbe256e2 100644 --- a/src/lib/wizards/functions/createGit.svelte +++ b/src/lib/wizards/functions/createGit.svelte @@ -7,7 +7,7 @@ import { goto } from '$app/navigation'; import { choices, createFunction, installation, repository } from './store'; import { addNotification } from '$lib/stores/notifications'; - import { Submit, trackEvent } from '$lib/actions/analytics'; + import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { base } from '$app/paths'; import { page } from '$app/stores'; import ExecuteAccess from './steps/executeAccess.svelte'; @@ -15,34 +15,44 @@ import FunctionConfiguration from './steps/functionConfiguration.svelte'; async function create() { - const response = await sdk.forProject.functions.create( - $createFunction.$id || ID.unique(), - $createFunction.name, - $createFunction.runtime, - $createFunction.entrypoint, - $createFunction.execute || undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - $createFunction.commands || undefined, - $installation.$id, - $repository.id, - $choices.branch, - $choices.silentMode || undefined, - $choices.rootDir || undefined - ); - goto(`${base}/console/project-${$page.params.project}/functions/function-${response.$id}`); - addNotification({ - message: `${$createFunction.name} has been created`, - type: 'success' - }); - trackEvent(Submit.FunctionCreate, { - customId: !!$createFunction.$id - }); - resetState(); - wizard.hide(); + try { + const response = await sdk.forProject.functions.create( + $createFunction.$id || ID.unique(), + $createFunction.name, + $createFunction.runtime, + $createFunction.entrypoint, + $createFunction.execute || undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + $createFunction.commands || undefined, + $installation.$id, + $repository.id, + $choices.branch, + $choices.silentMode || undefined, + $choices.rootDir || undefined + ); + goto( + `${base}/console/project-${$page.params.project}/functions/function-${response.$id}` + ); + addNotification({ + message: `${$createFunction.name} has been created`, + type: 'success' + }); + trackEvent(Submit.FunctionCreate, { + customId: !!$createFunction.$id + }); + resetState(); + wizard.hide(); + } catch (error) { + addNotification({ + message: error.message, + type: 'error' + }); + trackError(error, Submit.FunctionCreate); + } } function resetState() { diff --git a/src/lib/wizards/functions/createManual.svelte b/src/lib/wizards/functions/createManual.svelte index 7d6af860d..b5326616e 100644 --- a/src/lib/wizards/functions/createManual.svelte +++ b/src/lib/wizards/functions/createManual.svelte @@ -13,7 +13,7 @@ repository } from './store'; import { addNotification } from '$lib/stores/notifications'; - import { Submit, trackEvent } from '$lib/actions/analytics'; + import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { base } from '$app/paths'; import { page } from '$app/stores'; import Details from './steps/details.svelte'; @@ -57,6 +57,7 @@ message: error.message, type: 'error' }); + trackError(error, Submit.FunctionCreate); } } diff --git a/src/lib/wizards/functions/createTemplate.svelte b/src/lib/wizards/functions/createTemplate.svelte index 8dd63ea70..b22637ef0 100644 --- a/src/lib/wizards/functions/createTemplate.svelte +++ b/src/lib/wizards/functions/createTemplate.svelte @@ -7,7 +7,7 @@ import { goto } from '$app/navigation'; import { choices, installation, repository, template, templateConfig } from './store'; import { addNotification } from '$lib/stores/notifications'; - import { Submit, trackEvent } from '$lib/actions/analytics'; + import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { base } from '$app/paths'; import { page } from '$app/stores'; import GitConfiguration from './steps/gitConfiguration.svelte'; @@ -18,49 +18,59 @@ import { scopes } from '$lib/constants'; async function create() { - const runtimeDetail = $template.runtimes.find((r) => r.name === $templateConfig.runtime); + try { + const runtimeDetail = $template.runtimes.find( + (r) => r.name === $templateConfig.runtime + ); - const key = await sdk.forConsole.projects.createKey( - $page.params.project, - 'Generated for Template', - scopes.map((scope) => scope.scope) - ); - $templateConfig.variables['APPWRITE_API_KEY'] = key.secret; + const key = await sdk.forConsole.projects.createKey( + $page.params.project, + 'Generated for Template', + scopes.map((scope) => scope.scope) + ); + $templateConfig.variables['APPWRITE_API_KEY'] = key.secret; - const response = await sdk.forProject.functions.create( - $templateConfig.$id || ID.unique(), - $templateConfig.name, - $templateConfig.runtime, - runtimeDetail.entrypoint, - $template.permissions || undefined, - $template.events || undefined, - $template.cron || undefined, - $template.timeout || undefined, - undefined, - undefined, - runtimeDetail.commands || undefined, - $installation.$id, - $repository.id, - $choices.branch, - $choices.silentMode || undefined, - $choices.rootDir || undefined, - $template.providerRepositoryId, - $template.providerOwner, - runtimeDetail.providerRootDirectory, - $template.providerBranch - ); - goto(`${base}/console/project-${$page.params.project}/functions/function-${response.$id}`); - addNotification({ - message: `${response.name} has been created`, - type: 'success' - }); - trackEvent(Submit.FunctionCreate, { - customId: !!response.$id - }); - resetState(); - wizard.hide(); + const response = await sdk.forProject.functions.create( + $templateConfig.$id || ID.unique(), + $templateConfig.name, + $templateConfig.runtime, + runtimeDetail.entrypoint, + $template.permissions || undefined, + $template.events || undefined, + $template.cron || undefined, + $template.timeout || undefined, + undefined, + undefined, + runtimeDetail.commands || undefined, + $installation.$id, + $repository.id, + $choices.branch, + $choices.silentMode || undefined, + $choices.rootDir || undefined, + $template.providerRepositoryId, + $template.providerOwner, + runtimeDetail.providerRootDirectory, + $template.providerBranch + ); + goto( + `${base}/console/project-${$page.params.project}/functions/function-${response.$id}` + ); + addNotification({ + message: `${response.name} has been created`, + type: 'success' + }); + trackEvent(Submit.FunctionCreate, { + customId: !!response.$id + }); + resetState(); + } catch (error) { + addNotification({ + message: error.message, + type: 'error' + }); + trackError(error, Submit.FunctionCreate); + } } - function resetState() { wizard.hide(); templateConfig.set(null); diff --git a/src/lib/wizards/functions/steps/templateVariables.svelte b/src/lib/wizards/functions/steps/templateVariables.svelte index bb5a34e68..793ee39f7 100644 --- a/src/lib/wizards/functions/steps/templateVariables.svelte +++ b/src/lib/wizards/functions/steps/templateVariables.svelte @@ -50,7 +50,7 @@ placeholder={variable.placeholder ?? 'Enter value'} required={variable.required} autocomplete={false} - bind:value={$templateConfig.appwriteApiKey} /> + bind:value={$templateConfig.variables[variable.name]} /> {@html variable.description} @@ -109,7 +109,7 @@ placeholder={variable.placeholder ?? 'Enter value'} required={variable.required} autocomplete={false} - bind:value={$templateConfig.appwriteApiKey} /> + bind:value={$templateConfig.variables[variable.name]} /> {@html variable.description} 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 0e6e0c743..58080cc57 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -168,11 +168,24 @@ {:else} - + +
+ Create your first deployment to get started. +

+ Learn more about deployments in our Documentation. +

+
+
+ + +
+
{/if}
@@ -202,19 +215,7 @@ warning={status === 'pending'} success={status === 'completed' || status === 'ready'} info={status === 'processing' || status === 'building'}> - {#if deployment.$id === $func.deployment} - - - {:else} - {status} - {/if} + {status} @@ -306,13 +307,12 @@ text event="empty_documentation" ariaLabel={`create {target}`}>Documentation -
{/if} {:else} - +
Create your first deployment to get started.

diff --git a/src/routes/console/project-[project]/functions/function-[function]/deploymentSource.svelte b/src/routes/console/project-[project]/functions/function-[function]/deploymentSource.svelte index caefbfc78..043235604 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/deploymentSource.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/deploymentSource.svelte @@ -8,8 +8,8 @@ {#if deployment.type === 'vcs'} - + }}>