Refactor to remove slices and environments, replace with instances.

This commit is contained in:
2025-09-15 12:19:13 +01:00
parent a91780d1d5
commit 65d3142d03
24 changed files with 454 additions and 290 deletions

View File

@@ -3,7 +3,7 @@ import { Badge } from '@/components/ui/badge';
import { Card, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import AppLayout from '@/layouts/AppLayout.vue';
import { Head, Link } from '@inertiajs/vue3';
import { Layers2Icon } from 'lucide-vue-next';
import { ServerIcon } from 'lucide-vue-next';
const props = defineProps({
application: {
@@ -38,43 +38,35 @@ const props = defineProps({
<div>
<div class="mb-3 flex items-center justify-between">
<h3 class="text-2xl font-semibold tracking-tight">Environments</h3>
<h3 class="text-2xl font-semibold tracking-tight">Server Instances</h3>
<div>
<!-- <Button
:as="Link"
:href="
route('environments.create', {
organisation: $page.props.organisation.id,
server: application.id,
})
"
size="xs"
>
<PlusIcon class="size-4" />
Add
</Button> -->
<!-- Add instance button would go here -->
</div>
</div>
<div class="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
<Card v-for="environment in application.environments" :key="environment.id" class="relative">
<Link class="absolute inset-0" :href="route('environments.show', {
organisation: $page.props.organisation.id,
application: application.id,
environment: environment.id,
})"></Link>
<Card v-for="instance in application.instances" :key="instance.id" class="relative">
<Link
class="absolute inset-0"
:href="
route('servers.show', {
organisation: $page.props.organisation.id,
server: instance.server.id,
})
"
></Link>
<CardHeader>
<div class="flex items-center gap-2">
<CardTitle>{{ environment.name }}</CardTitle>
<Badge :variant="environment.status === 'active' ? 'success' : 'secondary'">{{ environment.status.replace('-', ' ') }}</Badge>
<ServerIcon class="size-4" />
<CardTitle>{{ instance.server.name }}</CardTitle>
<Badge :variant="instance.status === 'active' ? 'success' : 'secondary'">{{
instance.status.replace('-', ' ')
}}</Badge>
</div>
<CardDescription>
<span class="capitalize">{{ environment.type }}</span> {{ environment.version }}
</CardDescription>
<CardDescription> Branch: {{ instance.branch }} </CardDescription>
</CardHeader>
</Card>
</div>
</div>
{{ application }}
</div>
</AppLayout>
</template>

View File

@@ -1,109 +0,0 @@
<script setup>
import ServerSelector from '@/components/ServerSelector.vue';
import { Card } from '@/components/ui/card';
import ServiceCategory from '@/enums/ServiceCategory';
import AppLayout from '@/layouts/AppLayout.vue';
import { Head, router, usePage } from '@inertiajs/vue3';
import { PlusIcon } from 'lucide-vue-next';
defineProps({
environment: {
type: Object,
required: true,
},
servers: {
type: Array,
required: false,
}
});
function selectServer(server, serviceCategory = null) {
if (serviceCategory) {
if (server.services?.find((s) => s.category === serviceCategory)) {
// service is installed
return;
} else {
router.visit(route('servers.show', {
organisation: usePage().props.organisation.id,
server: server.id,
}));
}
}
}
</script>
<template>
<Head :title="environment.name" />
<AppLayout
:breadcrumbs="[
{
title: 'Applications',
href: route('applications.index', { organisation: $page.props.organisation.id }),
},
{
title: environment.application.name,
href: route('applications.show', {
organisation: $page.props.organisation.id,
application: environment.application.id,
}),
},
{
title: 'Environments',
href: route('applications.show', {
organisation: $page.props.organisation.id,
application: environment.application.id,
}),
},
{
title: environment.name,
href: route('environments.show', {
organisation: $page.props.organisation.id,
application: environment.application.id,
environment: environment.id,
}),
},
]"
>
<div class="flex h-full flex-1 flex-col gap-4 rounded-xl p-4">
<Card class="pattern-graph-paper grid grid-cols-3 gap-6 p-6">
<div class="space-y-2">
<ServerSelector :servers="servers" :service-category="ServiceCategory.GATEWAY" @select="selectServer($event, ServiceCategory.GATEWAY)">
<template #trigger>
<Card class="group flex select-none items-center gap-2 bg-card/30 p-4 text-sm backdrop-blur-sm">
<PlusIcon class="size-4 opacity-50" />
<span class="opacity-50 transition group-hover:opacity-100">Install a gateway</span>
</Card>
</template>
</ServerSelector>
<!-- <ServiceCard :icon="DoorOpenIcon" :service-type="ServiceType.CADDY" :service-category="ServiceCategory.GATEWAY" :status="ServiceStatus.NOT_INSTALLED" /> -->
</div>
<div class="space-y-2">
<Card class="group flex select-none items-center gap-2 bg-card/30 p-4 text-sm backdrop-blur-sm">
<PlusIcon class="size-4 opacity-50" />
<span class="opacity-50 transition group-hover:opacity-100">Install your application on a server</span>
</Card>
<!-- <ServiceCard
:icon="AppWindowIcon"
:service-type="ServiceType.FRANKENPHP"
:service-category="ServiceCategory.APPLICATION"
:status="ServiceStatus.NOT_INSTALLED"
/> -->
</div>
<div class="space-y-2">
<!-- <ServiceCard :icon="DatabaseIcon" :service-type="ServiceType.POSTGRES" :service-category="ServiceCategory.DATABASE" :status="ServiceStatus.NOT_INSTALLED" /> -->
<!-- <ServiceCard :icon="DatabaseZap" :service-type="ServiceType.REDIS" :service-category="ServiceCategory.CACHE" :status="ServiceStatus.NOT_INSTALLED" /> -->
<Card class="group flex select-none items-center gap-2 bg-card/30 p-4 text-sm backdrop-blur-sm">
<PlusIcon class="size-4 opacity-50" />
<span class="opacity-50 transition group-hover:opacity-100">Add a database</span>
</Card>
<Card class="group flex select-none items-center gap-2 bg-card/30 p-4 text-sm backdrop-blur-sm">
<PlusIcon class="size-4 opacity-50" />
<span class="opacity-50 transition group-hover:opacity-100">Add cache</span>
</Card>
</div>
</Card>
{{ environment }}
</div>
</AppLayout>
</template>

View File

@@ -21,11 +21,14 @@ const tabValue = ref(new URL(window.location.href).hash?.replace('#', '') || 'da
watch(tabValue, () => {
window.history.pushState({}, '', `#${tabValue.value}`);
});
watch(() => window.location.hash, (newHash) => {
if (newHash) {
tabValue.value = newHash.replace('#', '');
}
});
watch(
() => window.location.hash,
(newHash) => {
if (newHash) {
tabValue.value = newHash.replace('#', '');
}
},
);
</script>
<template>
@@ -51,7 +54,7 @@ watch(() => window.location.hash, (newHash) => {
})
"
class="absolute inset-0"
/>
/>
<CardContent class="flex items-center gap-4 p-4">
<AppWindowIcon class="size-6 text-muted-foreground" />
<div>
@@ -93,7 +96,7 @@ watch(() => window.location.hash, (newHash) => {
<template #fallback> Loading... </template>
<h3 class="mt-4 text-2xl font-bold tracking-tight">Server Providers</h3>
<p class="mb-4 text-sm text-muted-foreground">Manage your server providers.</p>
<div class="border-muted-background divide-y-muted-background divide-y rounded-md border max-w-80">
<div class="border-muted-background divide-y-muted-background max-w-80 divide-y rounded-md border">
<div v-for="provider in providers" class="flex items-center gap-2 px-2 py-1">
{{ provider.name }}
<span class="ml-auto text-xs uppercase text-muted-foreground">{{ provider.type }}</span>