diff --git a/package.json b/package.json index b34df3e5a..158b144cf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "2.0.5", + "version": "2.0.6", "license": "AGPL-3.0", "scripts": { "dev": "docker compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0", diff --git a/prisma/migrations/20220212142309_unique_secret_by_application/migration.sql b/prisma/migrations/20220212142309_unique_secret_by_application/migration.sql new file mode 100644 index 000000000..da4aa8e7c --- /dev/null +++ b/prisma/migrations/20220212142309_unique_secret_by_application/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - A unique constraint covering the columns `[name,applicationId]` on the table `Secret` will be added. If there are existing duplicate values, this will fail. + +*/ +-- DropIndex +DROP INDEX "Secret_name_key"; + +-- CreateIndex +CREATE UNIQUE INDEX "Secret_name_applicationId_key" ON "Secret"("name", "applicationId"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b12e29fc5..b064d09ab 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -105,13 +105,15 @@ model ApplicationSettings { model Secret { id String @id @default(cuid()) - name String @unique + name String value String isBuildSecret Boolean @default(false) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt application Application @relation(fields: [applicationId], references: [id]) applicationId String + + @@unique([name, applicationId]) } model BuildLog { diff --git a/src/lib/database/users.ts b/src/lib/database/users.ts index 7b15ff4d2..20b1a4aab 100644 --- a/src/lib/database/users.ts +++ b/src/lib/database/users.ts @@ -28,12 +28,12 @@ export async function login({ email, password }) { console.log('Network created'); }) .catch(() => { - console.log('Network already exists'); + console.log('Network already exists.'); }); startCoolifyProxy('/var/run/docker.sock') .then(() => { - console.log('Coolify Proxy Started'); + console.log('Coolify Proxy started.'); }) .catch((err) => { console.log(err); diff --git a/src/routes/applications/[id]/secrets/_Secret.svelte b/src/routes/applications/[id]/secrets/_Secret.svelte index fc24a1c63..90a1c2ffa 100644 --- a/src/routes/applications/[id]/secrets/_Secret.svelte +++ b/src/routes/applications/[id]/secrets/_Secret.svelte @@ -6,14 +6,19 @@ import { page } from '$app/stores'; import { del, post } from '$lib/api'; import { errorNotification } from '$lib/form'; + import { createEventDispatcher } from 'svelte'; + + const dispatch = createEventDispatcher(); - if (name) value = 'ENCRYPTED'; const { id } = $page.params; - async function removeSecret() { try { await del(`/applications/${id}/secrets.json`, { name }); - return window.location.reload(); + dispatch('refresh'); + if (isNewSecret) { + name = ''; + value = ''; + } } catch ({ error }) { return errorNotification(error); } @@ -21,7 +26,11 @@ async function saveSecret() { try { await post(`/applications/${id}/secrets.json`, { name, value, isBuildSecret }); - return window.location.reload(); + dispatch('refresh'); + if (isNewSecret) { + name = ''; + value = ''; + } } catch ({ error }) { return errorNotification(error); } @@ -33,101 +42,85 @@ } -
-
-
- - -
-
- - -
- -
-
Is build variable?
- -
-
    -
  • -
    - Use isBuildSecret - - - - -
    -
  • -
-
-
- {#if isNewSecret} -
- -
- {:else} -
- -
- {/if} + + + + + + + +
+ Use isBuildSecret + + + +
-
+ + + {#if isNewSecret} +
+ +
+ {:else} +
+ +
+ {/if} + diff --git a/src/routes/applications/[id]/secrets/index.json.ts b/src/routes/applications/[id]/secrets/index.json.ts index 0487531f6..5308427be 100644 --- a/src/routes/applications/[id]/secrets/index.json.ts +++ b/src/routes/applications/[id]/secrets/index.json.ts @@ -33,7 +33,7 @@ export const post: RequestHandler = async (event) => { const found = await db.isSecretExists({ id, name }); if (found) { throw { - error: `Secret ${name} already exists` + error: `Secret ${name} already exists.` }; } else { await db.createSecret({ id, name, value, isBuildSecret }); diff --git a/src/routes/applications/[id]/secrets/index.svelte b/src/routes/applications/[id]/secrets/index.svelte index e751ce513..a596b0040 100644 --- a/src/routes/applications/[id]/secrets/index.svelte +++ b/src/routes/applications/[id]/secrets/index.svelte @@ -24,6 +24,15 @@ export let application; import Secret from './_Secret.svelte'; import { getDomain } from '$lib/components/common'; + import { page } from '$app/stores'; + import { get } from '$lib/api'; + + const { id } = $page.params; + + async function refreshSecrets() { + const data = await get(`/applications/${id}/secrets.json`); + secrets = [...data.secrets]; + }
@@ -31,11 +40,47 @@ Secrets for {getDomain(application.fqdn)}
-
-
- {#each secrets as secret} - - {/each} - -
+
+ + + + + + + + + + {#each secrets as secret} + {#key secret.id} + + + + {/key} + {/each} + + + + +
NameValueNeed during buildtime? +
diff --git a/src/tailwind.css b/src/tailwind.css index a49b0b24a..fec74b8cd 100644 --- a/src/tailwind.css +++ b/src/tailwind.css @@ -35,7 +35,7 @@ .main { } input { - @apply w-96 select-all rounded border border-transparent bg-transparent bg-coolgray-200 p-2 text-xs tracking-tight text-white placeholder-stone-600 outline-none transition duration-150 hover:bg-coolgray-500 focus:bg-coolgray-500 disabled:bg-transparent md:text-sm; + @apply h-12 w-96 select-all rounded border border-transparent bg-transparent bg-coolgray-200 p-2 text-xs tracking-tight text-white placeholder-stone-600 outline-none transition duration-150 hover:bg-coolgray-500 focus:bg-coolgray-500 disabled:bg-transparent md:text-sm; } textarea { @apply w-96 select-all rounded border border-transparent bg-transparent bg-coolgray-200 p-2 text-xs tracking-tight text-white placeholder-stone-600 outline-none transition duration-150 hover:bg-coolgray-500 focus:bg-coolgray-500 disabled:bg-transparent md:text-sm; @@ -50,7 +50,7 @@ label { } button { - @apply rounded bg-coolgray-200 p-1 px-4 py-2 text-xs font-bold outline-none transition-all duration-100 hover:bg-coolgray-500 disabled:cursor-not-allowed disabled:bg-coolblack disabled:text-stone-600 md:text-sm; + @apply rounded bg-coolgray-200 p-1 px-2 py-1 text-xs font-bold outline-none transition-all duration-100 hover:bg-coolgray-500 disabled:cursor-not-allowed disabled:bg-coolblack disabled:text-stone-600; } a {