Files
keystone/resources/js/pages/source-providers/Edit.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

100 lines
3.3 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, router, useForm } from "@inertiajs/vue3";
const props = defineProps<{
sourceProvider: Record<string, any>;
sourceProviderTypes: string[];
}>();
const form = useForm({
name: props.sourceProvider.name,
type: props.sourceProvider.type,
url: props.sourceProvider.url ?? "",
});
const destroySourceProvider = (): void => {
if (!window.confirm(`Delete ${props.sourceProvider.name}?`)) {
return;
}
router.delete(
route("source-providers.destroy", {
organisation: props.sourceProvider.organisation_id,
source_provider: props.sourceProvider.id,
}),
);
};
</script>
<template>
<Head :title="`Edit ${sourceProvider.name}`" />
<AppLayout
:breadcrumbs="[
{
title: 'Organisation',
href: route('organisations.show', { organisation: $page.props.organisation.id }),
},
{ title: 'Edit Source Provider' },
]"
>
<form
class="flex h-full max-w-2xl flex-1 flex-col gap-5 p-4"
@submit.prevent="
form.put(
route('source-providers.update', {
organisation: $page.props.organisation.id,
source_provider: sourceProvider.id,
}),
)
"
>
<div>
<h2 class="text-3xl font-bold tracking-tight">Edit Source Provider</h2>
</div>
<div class="grid gap-2">
<Label for="name">Name</Label>
<Input id="name" v-model="form.name" required />
<InputError :message="form.errors.name" />
</div>
<div class="grid gap-2">
<Label for="type">Type</Label>
<select
id="type"
v-model="form.type"
class="h-9 rounded-md border border-input bg-transparent px-3 text-sm"
>
<option
v-for="sourceProviderType in sourceProviderTypes"
:key="sourceProviderType"
:value="sourceProviderType"
>
{{ sourceProviderType.replace("_", " ") }}
</option>
</select>
<InputError :message="form.errors.type" />
</div>
<div class="grid gap-2">
<Label for="url">Base URL</Label>
<Input id="url" v-model="form.url" placeholder="https://gitea.example.com" />
<InputError :message="form.errors.url" />
</div>
<div class="flex flex-wrap justify-between gap-2">
<Button type="button" variant="destructive" @click="destroySourceProvider">
Delete source provider
</Button>
<Button type="submit" :disabled="form.processing">Save source provider</Button>
</div>
</form>
</AppLayout>
</template>