Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Add service_type field to Create.php and EditCompose.php

Andras Bacsai1802d5d5da9e
diff --git a/app/Livewire/Project/Resource/Create.php b/app/Livewire/Project/Resource/Create.php
index 3223605348..01ee3efd89 100644
--- a/app/Livewire/Project/Resource/Create.php
+++ b/app/Livewire/Project/Resource/Create.php
@@ -64,6 +64,7 @@ class Create extends Component
'name' => "$oneClickServiceName-" . str()->random(10),
'docker_compose_raw' => base64_decode($oneClickService),
'environment_id' => $environment->id,
+ 'service_type' => $oneClickServiceName,
'server_id' => (int) $server_id,
'destination_id' => $destination->id,
'destination_type' => $destination->getMorphClass(),
diff --git a/app/Livewire/Project/Service/EditCompose.php b/app/Livewire/Project/Service/EditCompose.php
index 84cc45cf20..0f9c449f91 100644
--- a/app/Livewire/Project/Service/EditCompose.php
+++ b/app/Livewire/Project/Service/EditCompose.php
@@ -13,11 +13,13 @@ class EditCompose extends Component
'service.docker_compose_raw' => 'required',
'service.docker_compose' => 'required',
];
- public function mount() {
+ public function mount()
+ {
$this->service = Service::find($this->serviceId);
}
- public function saveEditedCompose() {
+ public function saveEditedCompose()
+ {
$this->dispatch('info', "Saving new docker compose...");
$this->dispatch('saveCompose', $this->service->docker_compose_raw);
}
diff --git a/database/migrations/2024_04_16_083919_add_service_type_on_creation.php b/database/migrations/2024_04_16_083919_add_service_type_on_creation.php
new file mode 100644
index 0000000000..ce91bddbb5
--- /dev/null
+++ b/database/migrations/2024_04_16_083919_add_service_type_on_creation.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('services', function (Blueprint $table) {
+ $table->string('service_type')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('services', function (Blueprint $table) {
+ $table->dropColumn('service_type');
+ });
+ }
+};
diff --git a/resources/views/livewire/project/service/edit-compose.blade.php b/resources/views/livewire/project/service/edit-compose.blade.php
index d3e88f3ae2..83931e863f 100644
--- a/resources/views/livewire/project/service/edit-compose.blade.php
+++ b/resources/views/livewire/project/service/edit-compose.blade.php
@@ -12,16 +12,16 @@
</x-forms.textarea>
</div>
<div class="flex justify-end w-full gap-2 pt-4">
-
<div class="flex items-end gap-2">
<div x-cloak x-show="raw">
- <x-forms.button class="w-64" @click.prevent="raw = !raw">Show Deployable Compose</x-forms.button>
+ <x-forms.button class="w-64" @click.prevent="raw = !raw">Show Deployable Compose</x-forms.button>
</div>
<div x-cloak x-show="raw === false">
- <x-forms.button class="w-64" @click.prevent="raw = !raw">Show Source
+ <x-forms.button class="w-64" @click.prevent="raw = !raw">Show Source
Compose</x-forms.button>
</div>
</div>
+ <div class="flex-1"></div>
<x-forms.button class="w-64" wire:click.prevent='saveEditedCompose'>
Save
</x-forms.button>