wowowowowo
Some checks failed
CI / Lint (push) Failing after 22s
CI / Tests (push) Failing after 33s

This commit is contained in:
2026-05-28 15:15:41 +01:00
parent 8f603122e2
commit 5b977c1f41
129 changed files with 9943 additions and 722 deletions

View File

@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import InputError from "@/components/InputError.vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -7,24 +7,13 @@ import AppLayout from "@/layouts/AppLayout.vue";
import { Head, useForm } from "@inertiajs/vue3";
import { computed, watch } from "vue";
const props = defineProps({
application: {
type: Object,
required: true,
},
environment: {
type: Object,
required: true,
},
services: {
type: Array,
required: true,
},
roles: {
type: Array,
required: true,
},
});
const props = defineProps<{
application: Record<string, any>;
environment: Record<string, any>;
services: Record<string, any>[];
roles: string[];
compatibility: Record<string, string[]>;
}>();
const form = useForm({
service_id: props.services[0]?.id ?? null,
@@ -32,18 +21,16 @@ const form = useForm({
name: "",
env_prefix: "",
is_primary: true,
domain: "",
path_prefix: "/",
tls_enabled: true,
});
const compatibleServices = computed(() => {
const roleTypes = {
database: ["postgres"],
cache: ["valkey"],
queue: ["valkey"],
gateway: ["caddy"],
};
return props.services.filter((service) =>
(roleTypes[form.role] ?? props.services.map((item) => item.type)).includes(service.type),
(props.compatibility[form.role] ?? props.services.map((item) => item.type)).includes(
service.type,
),
);
});
@@ -66,6 +53,34 @@ const generatedSliceType = computed(() => {
return "service link";
});
const envPrefix = computed(() => form.env_prefix || form.role.toUpperCase());
const variablePreview = computed(() => {
if (form.role === "database") {
return [
`${envPrefix.value}_HOST`,
`${envPrefix.value}_PORT`,
`${envPrefix.value}_DATABASE`,
`${envPrefix.value}_USERNAME`,
`${envPrefix.value}_PASSWORD`,
];
}
if (["cache", "queue"].includes(form.role)) {
return [
`${envPrefix.value}_HOST`,
`${envPrefix.value}_PORT`,
`${envPrefix.value}_DATABASE`,
`${envPrefix.value}_PASSWORD`,
];
}
if (form.role === "gateway") {
return ["APP_URL", "KEYSTONE_ROUTE_HOST", "KEYSTONE_ROUTE_PORT", "KEYSTONE_ROUTE_TLS"];
}
return [`${envPrefix.value}_HOST`, `${envPrefix.value}_PORT`];
});
watch(
compatibleServices,
(services) => {
@@ -142,6 +157,19 @@ watch(
</div>
</div>
<div class="rounded-md border bg-muted/30 p-3 text-sm">
<div class="font-medium">Environment variables preview</div>
<div class="mt-2 flex flex-wrap gap-2">
<code
v-for="variable in variablePreview"
:key="variable"
class="rounded bg-background px-2 py-1 text-xs"
>
{{ variable }}
</code>
</div>
</div>
<div class="grid gap-2">
<Label for="role">Role</Label>
<select
@@ -180,9 +208,31 @@ watch(
</div>
</div>
<div v-if="form.role === 'gateway'" class="grid gap-4 rounded-md border p-3 md:grid-cols-3">
<div class="grid gap-2">
<Label for="domain">Domain</Label>
<Input id="domain" v-model="form.domain" type="text" placeholder="app.example.com" />
<InputError :message="form.errors.domain" />
</div>
<div class="grid gap-2">
<Label for="path_prefix">Path prefix</Label>
<Input id="path_prefix" v-model="form.path_prefix" type="text" placeholder="/" />
<InputError :message="form.errors.path_prefix" />
</div>
<label class="flex items-center gap-2 pt-7 text-sm">
<input v-model="form.tls_enabled" type="checkbox" class="size-4" />
TLS enabled
</label>
</div>
<label class="flex items-center gap-2 text-sm">
<input v-model="form.is_primary" type="checkbox" class="size-4" />
Primary attachment
<span>
Primary attachment
<span class="block text-muted-foreground">
Primary attachments provide the default unprefixed variables for this role.
</span>
</span>
</label>
<div class="flex items-center justify-end">

View File

@@ -0,0 +1,137 @@
<script setup lang="ts">
import InputError from "@/components/InputError.vue";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import AppLayout from "@/layouts/AppLayout.vue";
import { Head, router, useForm } from "@inertiajs/vue3";
const props = defineProps<{
application: Record<string, any>;
environment: Record<string, any>;
attachment: Record<string, any>;
roles: string[];
}>();
const form = useForm({
role: props.attachment.role,
env_prefix: props.attachment.env_prefix ?? "",
is_primary: Boolean(props.attachment.is_primary),
domain: props.attachment.service_slice?.config?.domain ?? "",
path_prefix: props.attachment.service_slice?.config?.path_prefix ?? "/",
tls_enabled: props.attachment.service_slice?.config?.tls_enabled ?? true,
certificate_status: props.attachment.service_slice?.config?.certificate_status ?? "",
});
const detach = (): void => {
if (!window.confirm("Detach this managed service?")) {
return;
}
router.delete(
route("environment-attachments.destroy", {
organisation: props.application.organisation_id,
application: props.application.id,
environment: props.environment.id,
attachment: props.attachment.id,
}),
);
};
</script>
<template>
<Head title="Edit Attachment" />
<AppLayout
:breadcrumbs="[
{
title: environment.name,
href: route('environments.show', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
},
{ title: 'Edit Attachment' },
]"
>
<form
class="flex h-full max-w-2xl flex-1 flex-col gap-5 p-4"
@submit.prevent="
form.put(
route('environment-attachments.update', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
attachment: attachment.id,
}),
)
"
>
<div>
<h2 class="text-3xl font-bold tracking-tight">Edit Attachment</h2>
<p class="mt-1 text-sm text-muted-foreground">
{{ attachment.service?.name }} ·
{{ attachment.service_slice?.name ?? "service level" }}
</p>
</div>
<div class="grid gap-2">
<Label for="role">Role</Label>
<select
id="role"
v-model="form.role"
class="h-9 rounded-md border border-input bg-transparent px-3 text-sm"
>
<option v-for="role in roles" :key="role" :value="role">
{{ role.replace("_", " ") }}
</option>
</select>
<InputError :message="form.errors.role" />
</div>
<div class="grid gap-2">
<Label for="env_prefix">Env prefix</Label>
<Input id="env_prefix" v-model="form.env_prefix" placeholder="READONLY" />
<InputError :message="form.errors.env_prefix" />
</div>
<label class="flex items-center gap-2 text-sm">
<input v-model="form.is_primary" type="checkbox" class="size-4" />
Primary attachment
</label>
<div v-if="form.role === 'gateway'" class="grid gap-4 rounded-md border p-3">
<div class="grid gap-2">
<Label for="domain">Domain</Label>
<Input id="domain" v-model="form.domain" placeholder="app.example.com" />
<InputError :message="form.errors.domain" />
</div>
<div class="grid gap-2">
<Label for="path_prefix">Path prefix</Label>
<Input id="path_prefix" v-model="form.path_prefix" placeholder="/" />
<InputError :message="form.errors.path_prefix" />
</div>
<label class="flex items-center gap-2 text-sm">
<input v-model="form.tls_enabled" type="checkbox" class="size-4" />
TLS enabled
</label>
<InputError :message="form.errors.tls_enabled" />
<div class="grid gap-2">
<Label for="certificate_status">Certificate status</Label>
<Input
id="certificate_status"
v-model="form.certificate_status"
placeholder="pending"
/>
<InputError :message="form.errors.certificate_status" />
</div>
</div>
<div class="flex flex-wrap justify-between gap-2">
<Button type="button" variant="destructive" @click="detach">Detach</Button>
<Button type="submit" :disabled="form.processing">Save attachment</Button>
</div>
</form>
</AppLayout>
</template>