fix: update PR/MRs with new previewSeparator
This commit is contained in:
parent
3d5ea8629c
commit
28ec164bc2
@ -715,7 +715,7 @@ export async function stopTraefikProxy(
|
||||
}
|
||||
|
||||
export async function listSettings(): Promise<any> {
|
||||
return await prisma.setting.findFirst({});
|
||||
return await prisma.setting.findUnique({ where: { id: '0' } });
|
||||
}
|
||||
|
||||
export function generateToken() {
|
||||
|
@ -2,7 +2,7 @@ import { promises as dns } from 'dns';
|
||||
import { X509Certificate } from 'node:crypto';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { asyncExecShell, checkDomainsIsValidInDNS, decrypt, encrypt, errorHandler, isDev, isDNSValid, isDomainConfigured, listSettings, prisma, sentryDSN, version } from '../../../../lib/common';
|
||||
import { asyncExecShell, checkDomainsIsValidInDNS, decrypt, encrypt, errorHandler, getDomain, isDev, isDNSValid, isDomainConfigured, listSettings, prisma, sentryDSN, version } from '../../../../lib/common';
|
||||
import { AddDefaultRegistry, CheckDNS, CheckDomain, DeleteDomain, OnlyIdInBody, SaveSettings, SaveSSHKey, SetDefaultRegistry } from './types';
|
||||
|
||||
|
||||
@ -68,10 +68,26 @@ export async function saveSettings(request: FastifyRequest<SaveSettings>, reply:
|
||||
DNSServers,
|
||||
proxyDefaultRedirect
|
||||
} = request.body
|
||||
const { id } = await listSettings();
|
||||
const { id, previewSeparator: SetPreviewSeparator } = await listSettings();
|
||||
if (numberOfDockerImagesKeptLocally) {
|
||||
numberOfDockerImagesKeptLocally = Number(numberOfDockerImagesKeptLocally)
|
||||
}
|
||||
if (previewSeparator == '') {
|
||||
previewSeparator = '.'
|
||||
}
|
||||
if (SetPreviewSeparator != previewSeparator) {
|
||||
const applications = await prisma.application.findMany({ where: { previewApplication: { some: { id: { not: undefined } } } }, include: { previewApplication: true } })
|
||||
for (const application of applications) {
|
||||
for (const preview of application.previewApplication) {
|
||||
const { protocol } = new URL(preview.customDomain)
|
||||
const { pullmergeRequestId } = preview
|
||||
const { fqdn } = application
|
||||
const newPreviewDomain = `${protocol}//${pullmergeRequestId}${previewSeparator}${getDomain(fqdn)}`
|
||||
await prisma.previewApplication.update({ where: { id: preview.id }, data: { customDomain: newPreviewDomain } })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.setting.update({
|
||||
where: { id },
|
||||
data: { previewSeparator, numberOfDockerImagesKeptLocally, doNotTrack, isRegistrationEnabled, dualCerts, isAutoUpdateEnabled, isDNSCheckEnabled, DNSServers, isAPIDebuggingEnabled }
|
||||
|
@ -166,12 +166,15 @@
|
||||
}
|
||||
if (proxyDefaultRedirect !== settings.proxyDefaultRedirect) {
|
||||
await post(`/settings`, { proxyDefaultRedirect });
|
||||
settings.proxyDefaultRedirect = proxyDefaultRedirect;
|
||||
}
|
||||
if (numberOfDockerImagesKeptLocally !== settings.numberOfDockerImagesKeptLocally) {
|
||||
await post(`/settings`, { numberOfDockerImagesKeptLocally });
|
||||
settings.numberOfDockerImagesKeptLocally = numberOfDockerImagesKeptLocally;
|
||||
}
|
||||
if (previewSeparator !== settings.previewSeparator) {
|
||||
await post(`/settings`, { previewSeparator });
|
||||
settings.previewSeparator = previewSeparator;
|
||||
}
|
||||
if (minPort !== settings.minPort || maxPort !== settings.maxPort) {
|
||||
await post(`/settings`, { minPort, maxPort });
|
||||
@ -422,7 +425,7 @@
|
||||
</div>
|
||||
<div class="grid grid-cols-2 items-center">
|
||||
<div>
|
||||
Preview Domain Seprator
|
||||
Preview Domain Separator
|
||||
<Explainer
|
||||
position="dropdown-bottom"
|
||||
explanation="The separator used in the PR/MR previews.<br><br>For example if you set it to: <span class='text-yellow-400 font-bold'>-</span><br> the preview domain will be like this: <br><br><span class='text-yellow-400 font-bold'>PRMRNumber-yourdomain.com</span><br><br>The default is: <span class='text-yellow-400 font-bold'>.</span><br>so the preview domain will be like this: <br><br><span class='text-yellow-400 font-bold'>PRMRNumber.yourdomain.com</span>"
|
||||
@ -430,6 +433,7 @@
|
||||
</div>
|
||||
<input
|
||||
class="w-full"
|
||||
required
|
||||
bind:value={previewSeparator}
|
||||
readonly={!$appSession.isAdmin}
|
||||
disabled={!$appSession.isAdmin}
|
||||
|
Loading…
x
Reference in New Issue
Block a user