Files
keystone/resources/js/pages/gateway-routes/Create.vue
Harry Bayliss 5b977c1f41
Some checks failed
CI / Lint (push) Failing after 22s
CI / Tests (push) Failing after 33s
wowowowowo
2026-05-28 15:15:41 +01:00

125 lines
4.4 KiB
Vue

<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>