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

@@ -0,0 +1,124 @@
<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, useForm } from "@inertiajs/vue3";
const props = defineProps<{
application: Record<string, any>;
environment: Record<string, any>;
services: Record<string, any>[];
}>();
const form = useForm({
service_id: props.services[0]?.id ?? null,
name: "",
domain: "",
path_prefix: "/",
tls_enabled: true,
});
</script>
<template>
<Head title="Add Gateway Route" />
<AppLayout
:breadcrumbs="[
{
title: 'Applications',
href: route('applications.index', { organisation: $page.props.organisation.id }),
},
{
title: application.name,
href: route('applications.show', {
organisation: $page.props.organisation.id,
application: application.id,
}),
},
{
title: environment.name,
href: route('environments.show', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
},
{
title: 'Gateway routes',
href: route('gateway.routes.index', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
},
{ title: 'Add' },
]"
>
<form
class="flex h-full max-w-2xl flex-1 flex-col gap-5 p-4"
@submit.prevent="
form.post(
route('gateway.routes.store', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
)
"
>
<div>
<h2 class="text-3xl font-bold tracking-tight">Add Gateway Route</h2>
<p class="mt-1 text-sm text-muted-foreground">
Create a Caddy route slice for a domain and path prefix.
</p>
</div>
<div class="grid gap-2">
<Label for="service_id">Gateway service</Label>
<select
id="service_id"
v-model="form.service_id"
class="h-9 rounded-md border border-input bg-transparent px-3 text-sm"
required
>
<option v-for="service in services" :key="service.id" :value="service.id">
{{ service.name }}
</option>
</select>
<InputError :message="form.errors.service_id" />
</div>
<div class="grid gap-2">
<Label for="name">Route slice name</Label>
<Input id="name" v-model="form.name" placeholder="billing_web" required />
<InputError :message="form.errors.name" />
</div>
<div class="grid gap-4 md:grid-cols-2">
<div class="grid gap-2">
<Label for="domain">Domain</Label>
<Input id="domain" v-model="form.domain" placeholder="app.example.com" required />
<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="/" required />
<InputError :message="form.errors.path_prefix" />
</div>
</div>
<label class="flex items-center gap-2 text-sm">
<input v-model="form.tls_enabled" type="checkbox" class="size-4" />
TLS enabled
</label>
<div class="flex justify-end">
<Button type="submit" :disabled="form.processing || services.length === 0">
Create route
</Button>
</div>
</form>
</AppLayout>
</template>

View File

@@ -0,0 +1,124 @@
<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>;
routeAttachment: Record<string, any>;
}>();
const form = useForm({
domain: props.routeAttachment.service_slice?.config?.domain ?? "",
path_prefix: props.routeAttachment.service_slice?.config?.path_prefix ?? "/",
tls_enabled: props.routeAttachment.service_slice?.config?.tls_enabled ?? true,
certificate_status: props.routeAttachment.service_slice?.config?.certificate_status ?? "",
});
const destroyRoute = (): void => {
if (!window.confirm(`Remove gateway route ${form.domain}?`)) {
return;
}
router.delete(
route("gateway.routes.destroy", {
organisation: route().params.organisation,
application: props.application.id,
environment: props.environment.id,
route: props.routeAttachment.id,
}),
);
};
</script>
<template>
<Head :title="`Edit ${form.domain}`" />
<AppLayout
:breadcrumbs="[
{
title: 'Applications',
href: route('applications.index', { organisation: $page.props.organisation.id }),
},
{
title: application.name,
href: route('applications.show', {
organisation: $page.props.organisation.id,
application: application.id,
}),
},
{
title: environment.name,
href: route('environments.show', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
},
{
title: 'Gateway routes',
href: route('gateway.routes.index', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
},
{ title: 'Edit' },
]"
>
<form
class="flex h-full max-w-2xl flex-1 flex-col gap-5 p-4"
@submit.prevent="
form.put(
route('gateway.routes.update', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
route: routeAttachment.id,
}),
)
"
>
<div>
<h2 class="text-3xl font-bold tracking-tight">Edit Gateway Route</h2>
<p class="mt-1 text-sm text-muted-foreground">
{{ routeAttachment.service?.name }} ·
{{ routeAttachment.service_slice?.name ?? "route slice" }}
</p>
</div>
<div class="grid gap-4 md:grid-cols-2">
<div class="grid gap-2">
<Label for="domain">Domain</Label>
<Input id="domain" v-model="form.domain" placeholder="app.example.com" required />
<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="/" required />
<InputError :message="form.errors.path_prefix" />
</div>
</div>
<label class="flex items-center gap-2 text-sm">
<input v-model="form.tls_enabled" type="checkbox" class="size-4" />
TLS enabled
</label>
<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 class="flex flex-wrap justify-end gap-2">
<Button type="button" variant="ghost" @click="destroyRoute">Remove</Button>
<Button type="submit" :disabled="form.processing">Save route</Button>
</div>
</form>
</AppLayout>
</template>

View File

@@ -0,0 +1,175 @@
<script setup lang="ts">
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import AppLayout from "@/layouts/AppLayout.vue";
import { Head, Link, router } from "@inertiajs/vue3";
import { PencilIcon, PlusIcon, Trash2Icon } from "lucide-vue-next";
const props = defineProps<{
application: Record<string, any>;
environment: Record<string, any>;
routes: Record<string, any>[];
}>();
const destroyRoute = (routeAttachment: Record<string, any>): void => {
const domain = routeAttachment.service_slice?.config?.domain ?? routeAttachment.service_slice?.name;
if (!window.confirm(`Remove gateway route ${domain}?`)) {
return;
}
router.delete(
route("gateway.routes.destroy", {
organisation: route().params.organisation,
application: props.application.id,
environment: props.environment.id,
route: routeAttachment.id,
}),
{ preserveScroll: true },
);
};
</script>
<template>
<Head :title="`${environment.name} gateway routes`" />
<AppLayout
:breadcrumbs="[
{
title: 'Applications',
href: route('applications.index', { organisation: $page.props.organisation.id }),
},
{
title: application.name,
href: route('applications.show', {
organisation: $page.props.organisation.id,
application: application.id,
}),
},
{
title: environment.name,
href: route('environments.show', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
}),
},
{ title: 'Gateway routes' },
]"
>
<div class="flex h-full flex-1 flex-col gap-4 p-4">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h2 class="text-3xl font-bold tracking-tight">Gateway Routes</h2>
<p class="mt-1 text-sm text-muted-foreground">
Domains, path prefixes, TLS state, and Caddy route slices.
</p>
</div>
<Button
:as="Link"
:href="
route('gateway.routes.create', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
})
"
>
<PlusIcon class="size-4" />
Add route
</Button>
</div>
<div class="grid gap-4">
<Card v-for="routeAttachment in routes" :key="routeAttachment.id">
<CardHeader>
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<CardTitle>
{{ routeAttachment.service_slice?.config?.domain ?? "Unassigned domain" }}
</CardTitle>
<CardDescription>
{{ routeAttachment.service?.name }} ·
{{ routeAttachment.service_slice?.name ?? "route slice" }}
</CardDescription>
</div>
<div class="flex flex-wrap gap-2">
<Badge variant="outline">
{{ routeAttachment.service_slice?.config?.path_prefix ?? "/" }}
</Badge>
<Badge
:variant="
routeAttachment.service_slice?.config?.tls_enabled === false
? 'secondary'
: 'success'
"
>
TLS
{{
routeAttachment.service_slice?.config?.tls_enabled === false
? "disabled"
: "enabled"
}}
</Badge>
<Badge variant="outline">
{{
routeAttachment.service_slice?.config?.certificate_status ??
"pending"
}}
</Badge>
</div>
</div>
</CardHeader>
<CardContent class="flex flex-wrap gap-2">
<Button
:as="Link"
size="xs"
variant="secondary"
:href="
route('gateway.routes.edit', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
route: routeAttachment.id,
})
"
>
<PencilIcon class="size-4" />
Edit
</Button>
<Button size="xs" variant="ghost" @click="destroyRoute(routeAttachment)">
<Trash2Icon class="size-4" />
Remove
</Button>
</CardContent>
</Card>
<Card v-if="routes.length === 0" class="border-dashed">
<CardHeader>
<CardTitle>No gateway routes</CardTitle>
<CardDescription>
Add a route to connect a domain and path prefix to a Caddy gateway.
</CardDescription>
</CardHeader>
<CardContent>
<Button
:as="Link"
variant="secondary"
:href="
route('gateway.routes.create', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
})
"
>
<PlusIcon class="size-4" />
Add route
</Button>
</CardContent>
</Card>
</div>
</div>
</AppLayout>
</template>