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; + }) ?? []}
{ - return { - value: branch.name, - label: branch.name - }; - }) ?? []} /> + {options} /> - + 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 818c56a6e..d5e4fccb9 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 @@ -31,6 +31,7 @@ export const load: PageLoad = async ({ params, depends }) => { return { variables, - globalVariables + globalVariables, + installations: sdk.forProject.vcs.listInstallations() }; }; diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/disconnectRepo.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/disconnectRepo.svelte index 653aab8ca..674fa7459 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/disconnectRepo.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/disconnectRepo.svelte @@ -7,10 +7,14 @@ import { Button } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; + import { createEventDispatcher } from 'svelte'; import { func } from '../store'; export let show = false; const functionId = $page.params.function; + let error = ''; + + const dispatch = createEventDispatcher(); const handleSubmit = async () => { try { @@ -33,23 +37,31 @@ '' ); await invalidate(Dependencies.FUNCTION); + dispatch('success'); addNotification({ type: 'success', message: `Repository has been disconnected from your function` }); trackEvent(Submit.FunctionDisconnectRepo); show = false; - } catch (error) { - addNotification({ - type: 'error', - message: error.message - }); - trackError(error, Submit.FunctionDisconnectRepo); + } catch (e) { + error = e.message; + trackError(e, Submit.FunctionDisconnectRepo); } }; + + $: if (!show) { + error = ''; + } - + Disconnect Git repository

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 @@ + +