From b01f5f47b34c6048b810c5278ed7e42688424d53 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 19 May 2022 13:44:45 +0200 Subject: [PATCH] fix: PR deployments view --- src/routes/applications/[id]/previews/index.json.ts | 8 ++------ src/routes/applications/[id]/previews/index.svelte | 10 +++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/routes/applications/[id]/previews/index.json.ts b/src/routes/applications/[id]/previews/index.json.ts index ab10a06b8..d92690671 100644 --- a/src/routes/applications/[id]/previews/index.json.ts +++ b/src/routes/applications/[id]/previews/index.json.ts @@ -17,7 +17,7 @@ export const get: RequestHandler = async (event) => { const destinationDocker = await db.getDestinationByApplicationId({ id, teamId }); const docker = dockerInstance({ destinationDocker }); const listContainers = await docker.engine.listContainers({ - filters: { network: [destinationDocker.network] } + filters: { network: [destinationDocker.network], name: [id] } }); const containers = listContainers.filter((container) => { return ( @@ -30,11 +30,7 @@ export const get: RequestHandler = async (event) => { JSON.parse(Buffer.from(container.Labels['coolify.configuration'], 'base64').toString()) ) .filter((container) => { - return ( - container.type !== 'manual' && - container.type !== 'webhook_commit' && - container.applicationId === id - ); + return container.pullmergeRequestId && container.applicationId === id; }); return { body: { diff --git a/src/routes/applications/[id]/previews/index.svelte b/src/routes/applications/[id]/previews/index.svelte index 152aa00d2..f343c17df 100644 --- a/src/routes/applications/[id]/previews/index.svelte +++ b/src/routes/applications/[id]/previews/index.svelte @@ -31,6 +31,7 @@ import { errorNotification } from '$lib/form'; import { toast } from '@zerodevx/svelte-toast'; import { t } from '$lib/translations'; + import { goto } from '$app/navigation'; const { id } = $page.params; async function refreshSecrets() { @@ -39,11 +40,18 @@ } async function redeploy(container) { try { - await post(`/applications/${id}/deploy.json`, { + const { buildId } = await post(`/applications/${id}/deploy.json`, { pullmergeRequestId: container.pullmergeRequestId, branch: container.branch }); toast.push('Application redeployed queued.'); + if ($page.url.pathname.startsWith(`/applications/${id}/logs/build`)) { + return window.location.assign(`/applications/${id}/logs/build?buildId=${buildId}`); + } else { + return await goto(`/applications/${id}/logs/build?buildId=${buildId}`, { + replaceState: true + }); + } } catch ({ error }) { return errorNotification(error); }