From 60a53bb812506f8c4357564a2501667d298d8d1b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 18 Jul 2022 07:45:29 +0000 Subject: [PATCH] fix: location url for services and apps --- apps/ui/src/lib/store.ts | 16 +++++++++++++- .../routes/applications/[id]/__layout.svelte | 21 ++++++++----------- .../src/routes/applications/[id]/index.svelte | 4 ++-- .../services/[id]/_Services/_Services.svelte | 3 ++- .../src/routes/services/[id]/__layout.svelte | 18 ++++++---------- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/apps/ui/src/lib/store.ts b/apps/ui/src/lib/store.ts index 668477fa8..245e8d6eb 100644 --- a/apps/ui/src/lib/store.ts +++ b/apps/ui/src/lib/store.ts @@ -44,7 +44,7 @@ export const status: Writable = writable({ initialLoading: true, loading: false, isRunning: false - }, + }, database: { initialLoading: true, loading: false, @@ -57,3 +57,17 @@ export const features = readable({ beta: window.localStorage.getItem('beta') === 'true', latestVersion: window.localStorage.getItem('latestVersion') }); + +export const location: Writable = writable(null) +export const setLocation = (resource: any) => { + console.log(GITPOD_WORKSPACE_URL) + if (GITPOD_WORKSPACE_URL && resource.exposePort) { + const { href } = new URL(GITPOD_WORKSPACE_URL); + const newURL = href + .replace('https://', `https://${resource.exposePort}-`) + .replace(/\/$/, ''); + location.set(newURL) + } else { + location.set(resource.fqdn) + } +} \ No newline at end of file diff --git a/apps/ui/src/routes/applications/[id]/__layout.svelte b/apps/ui/src/routes/applications/[id]/__layout.svelte index d016346dc..02a1bd330 100644 --- a/apps/ui/src/routes/applications/[id]/__layout.svelte +++ b/apps/ui/src/routes/applications/[id]/__layout.svelte @@ -62,12 +62,13 @@ import { toast } from '@zerodevx/svelte-toast'; import { onDestroy, onMount } from 'svelte'; import { t } from '$lib/translations'; - import { appSession, disabledButton, status } from '$lib/store'; + import { appSession, disabledButton, status, location, setLocation } from '$lib/store'; import { errorNotification, handlerNotFoundLoad } from '$lib/common'; import Loading from '$lib/components/Loading.svelte'; let loading = false; let statusInterval: any; + $disabledButton = !$appSession.isAdmin || !application.fqdn || @@ -75,14 +76,7 @@ !application.repository || !application.destinationDocker || !application.buildPack; - let location = application.fqdn || null; - if (GITPOD_WORKSPACE_URL && application.exposePort) { - const { href } = new URL(GITPOD_WORKSPACE_URL); - const newURL = href - .replace('https://', `https://${application.exposePort}-`) - .replace(/\/$/, ''); - location = newURL; - } + const { id } = $page.params; async function handleDeploySubmit() { @@ -134,9 +128,12 @@ } onDestroy(() => { $status.application.initialLoading = true; + $location = null; clearInterval(statusInterval); }); onMount(async () => { + setLocation(application); + $status.application.isRunning = false; $status.application.isExited = false; $status.application.loading = false; @@ -155,9 +152,9 @@ {#if loading} {:else} - {#if location} + {#if $location} {/if} - +