feat: Gitpod integration
This commit is contained in:
@@ -1,14 +1,28 @@
|
||||
import { browser, dev } from '$app/env';
|
||||
import { dev } from '$app/env';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
export function getAPIUrl() {
|
||||
if (GITPOD_WORKSPACE_URL) {
|
||||
const {href} = new URL(GITPOD_WORKSPACE_URL)
|
||||
const newURL = href.replace('https://','https://3001-').replace(/\/$/,'')
|
||||
const { href } = new URL(GITPOD_WORKSPACE_URL)
|
||||
const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '')
|
||||
return newURL
|
||||
}
|
||||
return dev ? 'http://localhost:3001' : 'http://localhost:3000';
|
||||
}
|
||||
export function getWebhookUrl(type: string) {
|
||||
console.log(GITPOD_WORKSPACE_URL)
|
||||
if (GITPOD_WORKSPACE_URL) {
|
||||
const { href } = new URL(GITPOD_WORKSPACE_URL)
|
||||
const newURL = href.replace('https://', 'https://3001-').replace(/\/$/, '')
|
||||
if (type === 'github') {
|
||||
return `${newURL}/webhooks/github/events`
|
||||
}
|
||||
if (type === 'gitlab') {
|
||||
return `${newURL}/webhooks/gitlab/events`
|
||||
}
|
||||
}
|
||||
return `https://webhook.site/0e5beb2c-4e9b-40e2-a89e-32295e570c21/events`;
|
||||
}
|
||||
async function send({
|
||||
method,
|
||||
path,
|
||||
|
@@ -8,7 +8,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { dev } from '$app/env';
|
||||
import { goto } from '$app/navigation';
|
||||
import { del, get, post } from '$lib/api';
|
||||
import { del, get, getAPIUrl, getWebhookUrl, post } from '$lib/api';
|
||||
import { t } from '$lib/translations';
|
||||
import { errorNotification } from '$lib/common';
|
||||
import { appSession } from '$lib/store';
|
||||
@@ -18,7 +18,7 @@
|
||||
const from = $page.url.searchParams.get('from');
|
||||
|
||||
let url = settings?.fqdn ? settings.fqdn : window.location.origin;
|
||||
if (dev) url = `http://localhost:3001`;
|
||||
if (dev) url = getAPIUrl();
|
||||
|
||||
const updateDeployKeyIdUrl = `/applications/${id}/configuration/deploykey`;
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
}
|
||||
async function setWebhook(url: any, webhookToken: any) {
|
||||
const host = dev
|
||||
? 'https://webhook.site/0e5beb2c-4e9b-40e2-a89e-32295e570c21'
|
||||
? getWebhookUrl('gitlab')
|
||||
: `${window.location.origin}/webhooks/gitlab/events`;
|
||||
try {
|
||||
await post(
|
||||
|
@@ -2,7 +2,7 @@
|
||||
export let source: any;
|
||||
export let settings: any;
|
||||
import { page } from '$app/stores';
|
||||
import { post } from '$lib/api';
|
||||
import { getAPIUrl, getWebhookUrl, post } from '$lib/api';
|
||||
import Explainer from '$lib/components/Explainer.svelte';
|
||||
import { toast } from '@zerodevx/svelte-toast';
|
||||
import { t } from '$lib/translations';
|
||||
@@ -67,7 +67,7 @@
|
||||
const { organization, htmlUrl } = source;
|
||||
const { fqdn } = settings;
|
||||
const host = dev
|
||||
? 'http://localhost:3001'
|
||||
? getAPIUrl()
|
||||
: fqdn
|
||||
? fqdn
|
||||
: `http://${window.location.host}` || '';
|
||||
@@ -81,7 +81,7 @@
|
||||
url: host,
|
||||
hook_attributes: {
|
||||
url: dev
|
||||
? 'https://webhook.site/0e5beb2c-4e9b-40e2-a89e-32295e570c21/events'
|
||||
? getWebhookUrl('github')
|
||||
: `${host}/webhooks/github/events`
|
||||
},
|
||||
redirect_url: `${host}/webhooks/github`,
|
||||
|
@@ -4,7 +4,7 @@
|
||||
import Explainer from '$lib/components/Explainer.svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { onMount } from 'svelte';
|
||||
import { post } from '$lib/api';
|
||||
import { getAPIUrl, post } from '$lib/api';
|
||||
import { dev } from '$app/env';
|
||||
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
|
||||
import { toast } from '@zerodevx/svelte-toast';
|
||||
@@ -17,7 +17,7 @@
|
||||
let url = settings.fqdn ? settings.fqdn : window.location.origin;
|
||||
|
||||
if (dev) {
|
||||
url = `http://localhost:3001`;
|
||||
url = getAPIUrl();
|
||||
}
|
||||
let loading = false;
|
||||
|
||||
|
Reference in New Issue
Block a user