diff --git a/src/lib/components/git/IconGitea.svelte b/src/lib/components/git/IconGitea.svelte new file mode 100644 index 0000000000..261f3efcd4 --- /dev/null +++ b/src/lib/components/git/IconGitea.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/lib/components/git/connectGit.svelte b/src/lib/components/git/connectGit.svelte index 3190a6b8c7..1de610712a 100644 --- a/src/lib/components/git/connectGit.svelte +++ b/src/lib/components/git/connectGit.svelte @@ -1,14 +1,19 @@ @@ -35,13 +40,24 @@ title="No installation was added to the project yet" description="Add an installation to connect repositories"> - + + + {#if isGiteaEnabled} + + {/if} + diff --git a/src/lib/stores/git.ts b/src/lib/stores/git.ts index 51f8df20f7..8181f20cce 100644 --- a/src/lib/stores/git.ts +++ b/src/lib/stores/git.ts @@ -1,14 +1,14 @@ import { page } from '$app/state'; import { getApiEndpoint } from './sdk'; -export function connectGitHub(callbackState: Record = null) { +function connectVcsProvider(provider: string, callbackState: Record = null) { const redirect = new URL(page.url); if (callbackState) { Object.keys(callbackState).forEach((key) => { redirect.searchParams.append(key, callbackState[key]); }); } - const target = new URL(`${getApiEndpoint(page.params.region)}/vcs/github/authorize`); + const target = new URL(`${getApiEndpoint(page.params.region)}/vcs/${provider}/authorize`); target.searchParams.set('project', page.params.project); target.searchParams.set('success', redirect.toString()); target.searchParams.set('failure', redirect.toString()); @@ -16,6 +16,14 @@ export function connectGitHub(callbackState: Record = null) { return target; } +export function connectGitHub(callbackState: Record = null) { + return connectVcsProvider('github', callbackState); +} + +export function connectGitea(callbackState: Record = null) { + return connectVcsProvider('gitea', callbackState); +} + export function deploymentStatusConverter(status: string) { // Status component possible values - status: 'waiting' | 'ready' | 'processing' | 'pending' | 'failed' | 'complete'; switch (status) {