diff --git a/package-lock.json b/package-lock.json index 459ed0e64..a40029152 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "dependencies": { "@analytics/google-analytics": "^1.0.5", - "@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.52", + "@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.63", "@aw-labs/icons": "0.0.0-77", "@aw-labs/ui": "0.0.0-77", "@popperjs/core": "^2.11.6", @@ -146,9 +146,9 @@ }, "node_modules/@aw-labs/appwrite-console": { "name": "matej-appwrite-console", - "version": "7.1.52", - "resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.52.tgz", - "integrity": "sha512-RuGQH8CjQVjyta9+lxidJxswRKXWYPdoJZp8SyIrXIOs4smYz39UCPpeRuW1XV9si3W2ge2Mm2Zrx/y3PunH1Q==", + "version": "7.1.63", + "resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.63.tgz", + "integrity": "sha512-qdQ+mYQzr2bqpIiUc70AG/BbC8YDmpxp/Bx+VuNsOE75/aSD2dRKfMbqcLtcNY9HtnMbX4x1Bo6jmTdE00MDxw==", "dependencies": { "cross-fetch": "3.1.5", "isomorphic-form-data": "2.0.0" @@ -7741,9 +7741,9 @@ "integrity": "sha512-1Yw7u/COtxx06BfwlI+kVhsa/upKYzmCNrT4c8QDeCY2KMYlnijkUjtHiPU08HxyTIVB5j6d75O0YWVIHwQS8g==" }, "@aw-labs/appwrite-console": { - "version": "npm:matej-appwrite-console@7.1.52", - "resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.52.tgz", - "integrity": "sha512-RuGQH8CjQVjyta9+lxidJxswRKXWYPdoJZp8SyIrXIOs4smYz39UCPpeRuW1XV9si3W2ge2Mm2Zrx/y3PunH1Q==", + "version": "npm:matej-appwrite-console@7.1.63", + "resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.63.tgz", + "integrity": "sha512-qdQ+mYQzr2bqpIiUc70AG/BbC8YDmpxp/Bx+VuNsOE75/aSD2dRKfMbqcLtcNY9HtnMbX4x1Bo6jmTdE00MDxw==", "requires": { "cross-fetch": "3.1.5", "isomorphic-form-data": "2.0.0" diff --git a/package.json b/package.json index c8fa8ad35..165874b91 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "node": ">=16" }, "scripts": { - "dev": "vite dev", + "dev": "vite dev --host 0.0.0.0", "build": "vite build", "preview": "vite preview", "sync": "svelte-kit sync", @@ -21,7 +21,7 @@ "dependencies": { "@analytics/google-analytics": "^1.0.5", "analytics": "^0.8.1", - "@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.52", + "@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.63", "@aw-labs/icons": "0.0.0-77", "@aw-labs/ui": "0.0.0-77", "@popperjs/core": "^2.11.6", diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte index 3daf677bb..121dcbd55 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte @@ -24,6 +24,7 @@ import InputSwitch from '$lib/elements/forms/inputSwitch.svelte'; import Variables from '$lib/components/environmentVariables/variables.svelte'; import GitConnection from './gitConnection.svelte'; + import InputSelect from '$lib/elements/forms/inputSelect.svelte'; export let data: PageData; @@ -39,6 +40,7 @@ let entrypoint: string = null; let buildCommand: string = null; let installCommand: string = null; + let branch: string = null; let showGitConnection = false; @@ -55,6 +57,7 @@ entrypoint ??= $func.entrypoint; buildCommand ??= $func.buildCommand; installCommand ??= $func.installCommand; + branch ??= $func.branch; $eventSet = new Set($func.events); }); @@ -73,7 +76,8 @@ $func.buildCommand, $func.installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch ); invalidate(Dependencies.FUNCTION); addNotification({ @@ -104,7 +108,8 @@ $func.buildCommand, $func.installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch ); invalidate(Dependencies.FUNCTION); addNotification({ @@ -135,7 +140,8 @@ $func.buildCommand, $func.installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch ); invalidate(Dependencies.FUNCTION); addNotification({ @@ -166,7 +172,8 @@ $func.buildCommand, $func.installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch ); invalidate(Dependencies.FUNCTION); addNotification({ @@ -197,7 +204,8 @@ $func.buildCommand, $func.installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch ); invalidate(Dependencies.FUNCTION); @@ -229,7 +237,8 @@ $func.buildCommand, $func.installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch ); invalidate(Dependencies.FUNCTION); @@ -261,7 +270,41 @@ buildCommand, installCommand, $func.vcsInstallationId, - $func.repositoryId + $func.repositoryId, + $func.branch + ); + + invalidate(Dependencies.FUNCTION); + addNotification({ + type: 'success', + message: 'Deployment settings has been updated' + }); + trackEvent('submit_function_update_deployment_settings'); + } catch (error) { + addNotification({ + type: 'error', + message: error.message + }); + } + } + + async function updateBranch() { + try { + await sdkForProject.functions.update( + functionId, + $func.name, + $func.execute, + $func.events, + $func.schedule, + $func.timeout, + $func.enabled, + $func.logging, + $func.entrypoint, + $func.buildCommand, + $func.installCommand, + $func.vcsInstallationId, + $func.repositoryId, + branch ); invalidate(Dependencies.FUNCTION); @@ -293,6 +336,7 @@ $func.buildCommand, $func.installCommand, '', + '', '' ); await invalidate(Dependencies.FUNCTION); @@ -399,7 +443,18 @@

SOME TEXT

diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.ts b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.ts index 97b097d0e..3df32a780 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.ts +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.ts @@ -3,11 +3,17 @@ import { Dependencies } from '$lib/constants'; import type { PageLoad } from './$types'; export const load: PageLoad = async ({ params, parent, depends }) => { - await parent(); + const parentData = await parent(); depends(Dependencies.VARIABLES); return { variables: await sdkForProject.functions.listVariables(params.function), - installations: await sdkForProject.vcs.listInstallations() + installations: await sdkForProject.vcs.listInstallations(), + branches: parentData.function.vcsInstallationId + ? await sdkForProject.vcs.listRepositoryBranches( + parentData.function.vcsInstallationId, + parentData.function.repositoryId + ) + : null }; }; diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/gitConnection.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/gitConnection.svelte index ca6d2ac03..1a8c4f122 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/gitConnection.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/gitConnection.svelte @@ -5,13 +5,17 @@ import { Empty, Modal } from '$lib/components'; import { Dependencies } from '$lib/constants'; import { Button } from '$lib/elements/forms'; + import InputSelect from '$lib/elements/forms/inputSelect.svelte'; import { sdkForProject } from '$lib/stores/sdk'; import type { Models } from '@aw-labs/appwrite-console'; export let installations: Models.InstallationList; export let show = false; const functionId = $page.params.function; let selectedInstallation: Models.Installation = null; + let selectedRepository: Models.Repository = null; + let selectedBranchName: string = null; let repositories: Models.RepositoryList = null; + let branches: Models.BranchList = null; let error: string; async function selectInstallation(installation: Models.Installation) { try { @@ -26,10 +30,22 @@ searchQuery || undefined ); } + $: if (selectedInstallation) { searchRepositories(inputValue); } - async function connectRepository(repository: Models.Repository) { + + async function selectRepository(repository: Models.Repository) { + selectedRepository = repository; + console.log(selectedRepository); + + branches = await sdkForProject.vcs.listRepositoryBranches( + selectedInstallation.$id, + repository.id + ); + } + + async function connectRepository() { try { await sdkForProject.functions.update( functionId, @@ -44,7 +60,8 @@ $page.data.function.buildCommand, $page.data.function.installCommand, selectedInstallation.$id, - `${repository.id}` + selectedRepository.id, + selectedBranchName ); show = false; await invalidate(Dependencies.FUNCTION); @@ -55,6 +72,7 @@ error = e.message; } } + let inputValue = ''; @@ -107,7 +125,7 @@ {/if} - {:else} + {:else if !selectedRepository}

2. Select repository: @@ -139,8 +157,8 @@ class="table-col" data-title="Enabled" style="--p-col-width:40"> - + {/each} @@ -160,6 +178,27 @@ {/if}

+ {:else} +

+ 3. Select branch: + + {#if branches === null} +

Loading...

+ {:else} + { + return { + label: branch.name, + value: branch.name + }; + })} + bind:value={selectedBranchName} + id="branch" + label="Branch" /> + + + {/if} +

{/if} diff --git a/src/routes/console/project-[project]/settings/git-installations/+page.svelte b/src/routes/console/project-[project]/settings/git-installations/+page.svelte index 96e1fe1c8..d4c8f0f45 100644 --- a/src/routes/console/project-[project]/settings/git-installations/+page.svelte +++ b/src/routes/console/project-[project]/settings/git-installations/+page.svelte @@ -23,7 +23,7 @@ name: 'GitHub', icon: 'github', redirect: () => { - sdkForProject.vcs.createGitHubInstallation(); + sdkForProject.vcs.createGitHubInstallation(window.location.href); } } ];