From d7fd1fc65bb7dfb64ca688d615deb096b2635d8c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sat, 27 Aug 2022 11:39:04 +0000 Subject: [PATCH] fix: next/nuxt deployment type --- .../routes/api/v1/applications/handlers.ts | 6 ++-- .../src/routes/applications/[id]/index.svelte | 32 +++++++++++++++---- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index cb0bf38fe..1dda22dc5 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -34,7 +34,7 @@ export async function getImages(request: FastifyRequest) { const { buildPack, deploymentType } = request.body let publishDirectory = undefined; let port = undefined - const { baseImage, baseBuildImage, baseBuildImages, baseImages, } = setDefaultBaseImage( + const { baseImage, baseBuildImage, baseBuildImages, baseImages } = setDefaultBaseImage( buildPack, deploymentType ); if (buildPack === 'nextjs') { @@ -56,8 +56,7 @@ export async function getImages(request: FastifyRequest) { } } - - return { baseBuildImage, baseBuildImages, publishDirectory, port } + return { baseImage, baseImages, baseBuildImage, baseBuildImages, publishDirectory, port } } catch ({ status, message }) { return errorHandler({ status, message }) } @@ -232,7 +231,6 @@ export async function saveApplication(request: FastifyRequest, baseBuildImage, deploymentType } = request.body - if (port) port = Number(port); if (exposePort) { exposePort = Number(exposePort); diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index 9ef2e5612..b54f27747 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -114,10 +114,30 @@ buildPack: application.buildPack, deploymentType: application.deploymentType }); - application = { - ...application, - ...data - }; + const baseImageCorrect = data.baseImages.filter( + (image: any) => image.value === application.baseImage + ); + if (baseImageCorrect.length === 0) { + application.baseImage = data.baseImage; + } + application.baseImages = data.baseImages; + + const baseBuildImageCorrect = data.baseBuildImages.filter( + (image: any) => image.value === application.baseBuildImage + ); + if (baseBuildImageCorrect.length === 0) { + application.baseBuildImage = data.baseBuildImage; + } + application.baseBuildImages = data.baseBuildImages; + if (application.deploymentType === 'static' && application.port !== '80') { + application.port = data.port; + } + if (application.deploymentType === 'node' && application.port === '80') { + application.port = data.port; + } + if (!application.publishDirectory) { + application.publishDirectory = data.publishDirectory; + } } async function changeSettings(name: any) { if (name === 'debug') { @@ -631,9 +651,7 @@ bind:value={application.port} placeholder="{$t('forms.default')}: 'python' ? '8000' : '3000'" /> - + {/if}