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 738ee0dc3..d0196f0d5 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 @@ -42,7 +42,7 @@ - + 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 b925a8850..d247c17e9 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 @@ -2,22 +2,10 @@ import { sdk } from '$lib/stores/sdk'; import { Dependencies } from '$lib/constants'; import type { PageLoad } from './$types'; -export const load: PageLoad = async ({ params, depends, parent }) => { +export const load: PageLoad = async ({ params, depends }) => { depends(Dependencies.VARIABLES); - const data = await parent(); - - const [repository, globalVariables, variables] = await Promise.all([ - (async () => { - if (data.function.installationId && data.function.providerRepositoryId) { - return await sdk.forProject.vcs.getRepository( - data.function.installationId, - data.function.providerRepositoryId - ); - } else { - return null; - } - })(), + const [globalVariables, variables] = await Promise.all([ sdk.forProject.projectApi.listVariables(), sdk.forProject.functions.listVariables(params.function) ]); @@ -42,7 +30,6 @@ export const load: PageLoad = async ({ params, depends, parent }) => { return { variables, - globalVariables, - repository + globalVariables }; }; diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/updateConfiguration.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/updateConfiguration.svelte index 778212383..1320b9fd6 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/updateConfiguration.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/updateConfiguration.svelte @@ -27,7 +27,6 @@ import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; export let installations: Models.InstallationList; - export let repository: Models.ProviderRepository | null; const functionId = $page.params.function; let entrypoint: string; @@ -39,6 +38,8 @@ let selectedDir: string; let showDisconnect = false; + let repository: Models.ProviderRepository | null | false = false; + onMount(() => { entrypoint = $func?.entrypoint; commands = $func?.commands; @@ -49,8 +50,27 @@ if ($page.url.searchParams.has('github-installed')) { wizard.start(ConnectExisting); } + + loadRepository(); }); + async function loadRepository() { + try { + if ($func.installationId && $func.providerRepositoryId) { + repository = await sdk.forProject.vcs.getRepository( + $func.installationId, + $func.providerRepositoryId + ); + } + } catch (err) { + console.warn(err); + } finally { + if (repository === false) { + repository = null; + } + } + } + enum ProviderNames { github = 'GitHub', gitlab = 'GitLab', @@ -153,83 +173,99 @@ bind:value={entrypoint} /> - - - Git settings - {#if !repository} - NOT CONNECTED - {/if} - - {#if repository} -
-
-
- -
-
-
{repository.name}
-

Last updated: {toLocaleDateTime(repository.pushedAt)}

-
-
-
- - { - selectedBranch = event.detail.value; - }} - name="branch" - options={branchesList?.branches?.map((branch) => { - return { - value: branch.name, - label: branch.name - }; - }) ?? []} /> - - - -
-
- - + {#if repository === false} + + + Git settings + +
+
+
+ Loading repository...
- {:else} -
-
-
- - - - -
+ + {:else} + + + Git settings + {#if !repository} + NOT CONNECTED + {/if} + + {#if repository} +
+
+
+ +
+
+
{repository.name}
+

Last updated: {toLocaleDateTime(repository.pushedAt)}

+
+
+
+ + { + selectedBranch = event.detail.value; + }} + name="branch" + options={branchesList?.branches?.map((branch) => { + return { + value: branch.name, + label: branch.name + }; + }) ?? []} /> + + + +
+
+ +
-
-
- {/if} - + {:else} +
+
+
+ + + + +
+
+ +
+
+ {/if} + + {/if} Build settings diff --git a/src/routes/console/project-[project]/settings/updateInstallations.svelte b/src/routes/console/project-[project]/settings/updateInstallations.svelte index da965253c..e19da66d7 100644 --- a/src/routes/console/project-[project]/settings/updateInstallations.svelte +++ b/src/routes/console/project-[project]/settings/updateInstallations.svelte @@ -37,12 +37,6 @@ let showInstallationDropdown: boolean[] = []; let selectedInstallation: Models.Installation; - enum ProviderNames { - github = 'GitHub', - gitlab = 'GitLab', - bitBucket = 'BitBucket' - } - function getInstallationLink(installation: Models.Installation) { switch (installation.provider) { case 'github': @@ -153,7 +147,7 @@ on:click={() => { showInstallationDropdown[i] = false; }}> - Configure {ProviderNames[installation.provider]} + Configure