An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: Secrets build/runtime coudl be changed after save
Andras Bacsaib023d65fcfbb
diff --git a/src/routes/applications/[id]/secrets/_BatchSecrets.svelte b/src/routes/applications/[id]/secrets/_BatchSecrets.svelteindex 38af130c9c..8d0a65aeec 100644--- a/src/routes/applications/[id]/secrets/_BatchSecrets.svelte+++ b/src/routes/applications/[id]/secrets/_BatchSecrets.svelte@@ -30,7 +30,7 @@await Promise.all(batchSecretsPairs.map(({ name, value, isNew }) =>- limit(() => saveSecret({ name, value, applicationId: id, isNew, dispatch }))+ limit(() => saveSecret({ name, value, applicationId: id, isNew }))));batchSecrets = '';@@ -39,8 +39,8 @@</script><h2 class="title my-6 font-bold">Paste .env file</h2>-<form on:submit={getValues} class="mb-12 w-full">- <textarea value={batchSecrets} on:change={setBatchValue} class="mb-2 min-h-[200px] w-full" />+<form on:submit|preventDefault={getValues} class="mb-12 w-full">+ <textarea bind:value={batchSecrets} class="mb-2 min-h-[200px] w-full" /><buttonclass="bg-green-600 hover:bg-green-500 disabled:text-white disabled:opacity-40"type="submit">Batch add secrets</buttondiff --git a/src/routes/applications/[id]/secrets/_Secret.svelte b/src/routes/applications/[id]/secrets/_Secret.svelteindex 5c26fcc9e0..48f750e61c 100644--- a/src/routes/applications/[id]/secrets/_Secret.svelte+++ b/src/routes/applications/[id]/secrets/_Secret.svelte@@ -12,6 +12,7 @@import { del } from '$lib/api';import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';import { errorNotification } from '$lib/form';+ import { toast } from '@zerodevx/svelte-toast';import { createEventDispatcher } from 'svelte';import { saveSecret } from './utils';@@ -32,21 +33,39 @@}async function createSecret(isNew) {- saveSecret({+ await saveSecret({isNew,name,value,isBuildSecret,isPRMRSecret,isNewSecret,- applicationId: id,- dispatch+ applicationId: id});+ if (isNewSecret) {+ name = '';+ value = '';+ isBuildSecret = false;+ }+ dispatch('refresh');+ toast.push('Secret saved');}- function setSecretValue() {- if (isNewSecret) {+ async function setSecretValue() {+ if (!isPRMRSecret) {isBuildSecret = !isBuildSecret;+ if (!isNewSecret) {+ await saveSecret({+ isNew: isNewSecret,+ name,+ value,+ isBuildSecret,+ isPRMRSecret,+ isNewSecret,+ applicationId: id+ });+ toast.push('Secret saved');+ }}}</script>@@ -81,9 +100,9 @@class="relative inline-flex h-6 w-11 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out"class:bg-green-600={isBuildSecret}class:bg-stone-700={!isBuildSecret}- class:opacity-50={!isNewSecret}- class:cursor-not-allowed={!isNewSecret}- class:cursor-pointer={isNewSecret}+ class:opacity-50={isPRMRSecret}+ class:cursor-not-allowed={isPRMRSecret}+ class:cursor-pointer={!isPRMRSecret}><span class="sr-only">Use isBuildSecret</span><spandiff --git a/src/routes/applications/[id]/secrets/index.svelte b/src/routes/applications/[id]/secrets/index.svelteindex a4c6a528ce..5ca2bbfcb3 100644--- a/src/routes/applications/[id]/secrets/index.svelte+++ b/src/routes/applications/[id]/secrets/index.svelte@@ -22,18 +22,48 @@<script lang="ts">export let secrets;export let application;+ import pLimit from 'p-limit';import Secret from './_Secret.svelte';- import { getDomain } from '$lib/components/common';import { page } from '$app/stores';import { get } from '$lib/api';- import BatchSecrets from './_BatchSecrets.svelte';+ import { saveSecret } from './utils';+ import { toast } from '@zerodevx/svelte-toast';+ const limit = pLimit(1);const { id } = $page.params;+ let batchSecrets = '';async function refreshSecrets() {const data = await get(`/applications/${id}/secrets.json`);secrets = [...data.secrets];}+ async function getValues(e) {+ e.preventDefault();+ const eachValuePair = batchSecrets.split('\n');+ const batchSecretsPairs = eachValuePair+ .filter((secret) => !secret.startsWith('#') && secret)+ .map((secret) => {+ const [name, value] = secret.split('=');+ const cleanValue = value?.replaceAll('"', '') || '';+ return {+ name,+ value: cleanValue,+ isNew: !secrets.find((secret) => name === secret.name)+ };+ });++ await Promise.all(+ batchSecretsPairs.map(({ name, value, isNew }) =>+ limit(() => saveSecret({ name, value, applicationId: id, isNew }))+ )+ );+ batchSecrets = '';+ await refreshSecrets();+ toast.push('Secrets saved');+ }+ function asd() {+ console.log(secrets);+ }</script><div class="flex items-center space-x-2 p-5 px-6 font-bold">@@ -134,6 +164,13 @@</tr></tbody></table>-- <BatchSecrets {secrets} {id} {refreshSecrets} />+ <button on:click={asd}>Save</button>+ <h2 class="title my-6 font-bold">Paste .env file</h2>+ <form on:submit|preventDefault={getValues} class="mb-12 w-full">+ <textarea bind:value={batchSecrets} class="mb-2 min-h-[200px] w-full" />+ <button+ class="bg-green-600 hover:bg-green-500 disabled:text-white disabled:opacity-40"+ type="submit">Batch add secrets</button+ >+ </form></div>diff --git a/src/routes/applications/[id]/secrets/utils.ts b/src/routes/applications/[id]/secrets/utils.tsindex a7d24a39ee..d86acbe2c0 100644--- a/src/routes/applications/[id]/secrets/utils.ts+++ b/src/routes/applications/[id]/secrets/utils.ts@@ -10,7 +10,6 @@ type Props = {isPRMRSecret?: boolean;isNewSecret?: boolean;applicationId: string;- dispatch: (name: string) => void;};export async function saveSecret({@@ -20,8 +19,7 @@ export async function saveSecret({isBuildSecret,isPRMRSecret,isNewSecret,- applicationId,- dispatch+ applicationId}: Props): Promise<void> {if (!name) return errorNotification('Name is required.');if (!value) return errorNotification('Value is required.');@@ -33,13 +31,11 @@ export async function saveSecret({isPRMRSecret,isNew: isNew || false});- dispatch('refresh');if (isNewSecret) {name = '';value = '';isBuildSecret = false;}- toast.push('Secret saved.');} catch ({ error }) {return errorNotification(error);}