wowowowowo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<script setup>
|
||||
<script setup lang="ts">
|
||||
import InputError from "@/components/InputError.vue";
|
||||
import RadioButton from "@/components/RadioButton.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -18,9 +18,9 @@ import {
|
||||
} from "lucide-vue-next";
|
||||
import { watch } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
services: Object,
|
||||
});
|
||||
const props = defineProps<{
|
||||
services: Record<string, Record<string, string[]>>;
|
||||
}>();
|
||||
|
||||
const form = useForm({
|
||||
name: null,
|
||||
@@ -29,7 +29,16 @@ const form = useForm({
|
||||
version: null,
|
||||
});
|
||||
|
||||
function getIcon(category) {
|
||||
const deployPolicyDefaults = {
|
||||
[ServiceCategory.APPLICATION]: "with_environment",
|
||||
[ServiceCategory.DATABASE]: "dependency_only",
|
||||
[ServiceCategory.CACHE]: "dependency_only",
|
||||
[ServiceCategory.GATEWAY]: "manual_or_on_route_change",
|
||||
[ServiceCategory.STORAGE]: "manual",
|
||||
[ServiceCategory.BUILDER]: "manual",
|
||||
};
|
||||
|
||||
function getIcon(category: string) {
|
||||
switch (category) {
|
||||
case ServiceCategory.DATABASE:
|
||||
return DatabaseIcon;
|
||||
@@ -46,7 +55,7 @@ function getIcon(category) {
|
||||
}
|
||||
}
|
||||
|
||||
function generateServiceName() {
|
||||
function generateServiceName(): string {
|
||||
let str = "";
|
||||
|
||||
if (form.category) {
|
||||
@@ -89,27 +98,41 @@ watch([() => form.category, () => form.type, () => form.version], () => {
|
||||
]"
|
||||
>
|
||||
<div class="flex h-full flex-1 flex-col gap-4 rounded-xl p-4">
|
||||
<div class="grid gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div
|
||||
class="grid gap-2 md:grid-cols-2 lg:grid-cols-3"
|
||||
role="radiogroup"
|
||||
aria-label="Service category"
|
||||
>
|
||||
<RadioButton
|
||||
v-for="(category, categoryKey) in ServiceCategory"
|
||||
:key="category"
|
||||
v-model="form.category"
|
||||
:value="category"
|
||||
name="category"
|
||||
class="flex gap-3 py-3"
|
||||
:described-by="`service-category-${category}-description`"
|
||||
>
|
||||
<component :is="getIcon(category)" class="size-5" />
|
||||
<div>
|
||||
<h4 class="mb-1 text-lg font-semibold leading-none tracking-tighter">
|
||||
{{ category }}
|
||||
</h4>
|
||||
<p class="text-sm">{{ serviceCategoryDescriptions[categoryKey] }}</p>
|
||||
<p :id="`service-category-${category}-description`" class="text-sm">
|
||||
{{ serviceCategoryDescriptions[categoryKey] }}
|
||||
</p>
|
||||
</div>
|
||||
</RadioButton>
|
||||
</div>
|
||||
|
||||
<div v-if="form.category" class="grid gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div
|
||||
v-if="form.category"
|
||||
class="grid gap-2 md:grid-cols-2 lg:grid-cols-3"
|
||||
role="radiogroup"
|
||||
aria-label="Service type"
|
||||
>
|
||||
<RadioButton
|
||||
v-for="service in services[form.category]"
|
||||
v-for="service in services[form.category] ?? []"
|
||||
:key="service.name"
|
||||
v-model="form.type"
|
||||
:value="service.name"
|
||||
name="type"
|
||||
@@ -119,11 +142,23 @@ watch([() => form.category, () => form.type, () => form.version], () => {
|
||||
{{ service.name }}
|
||||
</h4>
|
||||
</RadioButton>
|
||||
<div
|
||||
v-if="!services[form.category]"
|
||||
class="rounded-md border border-dashed p-4 text-sm text-muted-foreground md:col-span-2 lg:col-span-3"
|
||||
>
|
||||
No service drivers are configured for {{ form.category }} services yet.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="form.type" class="grid gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div
|
||||
v-if="form.type"
|
||||
class="grid gap-2 md:grid-cols-2 lg:grid-cols-3"
|
||||
role="radiogroup"
|
||||
aria-label="Service version"
|
||||
>
|
||||
<RadioButton
|
||||
v-for="(version, versionKey) in services[form.category][form.type].versions"
|
||||
:key="versionKey"
|
||||
v-model="form.version"
|
||||
:value="versionKey"
|
||||
name="version"
|
||||
@@ -135,6 +170,10 @@ watch([() => form.category, () => form.type, () => form.version], () => {
|
||||
</RadioButton>
|
||||
</div>
|
||||
|
||||
<div v-if="form.category" class="rounded-md border bg-muted/30 p-3 text-sm">
|
||||
Default deploy policy: {{ deployPolicyDefaults[form.category]?.replace("_", " ") }}
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2">
|
||||
<Label for="name">Name</Label>
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user