diff --git a/src/lib/wizards/functions/steps/gitConfiguration.svelte b/src/lib/wizards/functions/steps/gitConfiguration.svelte index 26ccdbe23..af47651e6 100644 --- a/src/lib/wizards/functions/steps/gitConfiguration.svelte +++ b/src/lib/wizards/functions/steps/gitConfiguration.svelte @@ -3,6 +3,7 @@ import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; import { WizardStep } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; + import { sortBranches } from '$routes/console/project-[project]/functions/function-[function]/settings/updateConfiguration.svelte'; import { choices, installation, repository } from '../store'; $choices.rootDir ??= ''; @@ -20,13 +21,7 @@ $installation.$id, $repository.id ); - const sorted = branches.sort((a, b) => { - if (a.name === 'main' || a.name === 'master') { - return -1; - } - - return a.name > b.name ? -1 : 1; - }); + const sorted = sortBranches(branches); $choices.branch = sorted[0]?.name ?? null; if (!$choices.branch) { @@ -57,6 +52,17 @@
{:then branches} + {@const options = + branches + ?.map((branch) => { + return { + value: branch.name, + label: branch.name + }; + }) + ?.sort((a, b) => { + return a.label > b.label ? 1 : -1; + }) ?? []}Are you sure you want to disconnect {$func.name}? This will affect future deployments to diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/gitConfigurationModal.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/gitConfigurationModal.svelte index ec1bdd1e2..9bfd1502f 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/gitConfigurationModal.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/gitConfigurationModal.svelte @@ -12,9 +12,10 @@ import { func, repositories } from '../store'; import { invalidate } from '$app/navigation'; import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; + import { sortBranches } from './updateConfiguration.svelte'; + import { installations } from '$lib/wizards/functions/store'; export let show: boolean; - export let installationsList: Models.InstallationList; const functionId = $page.params.function; @@ -29,7 +30,7 @@ let selectedDir: string; let silentMode = false; - let installationsOptions = installationsList.installations.map((installation) => { + let installationsOptions = $installations.installations.map((installation) => { return { value: installation.$id, label: installation.organization @@ -108,13 +109,7 @@ selectedRepoId ); - branchesList.branches = branchesList.branches.sort((a, b) => { - if (a.name === 'main' || a.name === 'master') { - return -1; - } - - return a.name > b.name ? -1 : 1; - }); + branchesList.branches = sortBranches(branchesList.branches); selectedBranch = branchesList?.branches[0].name; } @@ -126,7 +121,7 @@ $: selectedRepo = (repositoriesList ?? []).find((repo) => repo.id === selectedRepoId) ?? null; $: selectedInstallation = - (installationsList?.installations ?? []).find( + ($installations?.installations ?? []).find( (installation) => installation.$id === selectedInstallationId ) ?? null; 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 84e961f02..ed19f476e 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 @@ -1,9 +1,22 @@ + +