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.

wip previews

Andras Bacsaiec233162e935
diff --git a/app/Data/ApplicationPreview.php b/app/Data/ApplicationPreview.php
new file mode 100644
index 0000000000..8af3e3ec98
--- /dev/null
+++ b/app/Data/ApplicationPreview.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Data;
+
+use Spatie\LaravelData\Data;
+
+class ApplicationPreview extends Data
+{
+ public function __construct(
+ public int $pullRequestId,
+ public string $branch,
+ public ?string $commit,
+ ) {
+ }
+}
diff --git a/app/Http/Livewire/Project/Application/Previews.php b/app/Http/Livewire/Project/Application/Previews.php
index 5e732b19ee..4f21134cb0 100644
--- a/app/Http/Livewire/Project/Application/Previews.php
+++ b/app/Http/Livewire/Project/Application/Previews.php
@@ -8,8 +8,4 @@ use Livewire\Component;
class Previews extends Component
{
public Application $application;
- public function render()
- {
- return view('livewire.project.application.previews');
- }
}
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 2da683512d..58e92ddc3d 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -2,9 +2,11 @@
namespace App\Models;
+use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Spatie\Activitylog\Models\Activity;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
class Application extends BaseModel
{
@@ -20,8 +22,6 @@ class Application extends BaseModel
$application->persistentStorages()->delete();
});
}
-
-
protected $fillable = [
'name',
'project_id',
@@ -40,6 +40,16 @@ class Application extends BaseModel
'publish_directory',
'private_key_id'
];
+
+ public $casts = [
+ 'previews' => SchemalessAttributes::class,
+ ];
+ public function scopeWithExtraAttributes(): Builder
+ {
+ return $this->previews->modelScope();
+ }
+
+
public function publishDirectory(): Attribute
{
return Attribute::make(
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 235c534941..d2afff3f58 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -28,7 +28,6 @@ class Server extends BaseModel
'extra_attributes' => SchemalessAttributes::class,
];
-
public function standaloneDockers()
{
return $this->hasMany(StandaloneDocker::class);
diff --git a/database/migrations/2023_03_27_081716_create_applications_table.php b/database/migrations/2023_03_27_081716_create_applications_table.php
index e3b0d8fb06..500befe2c4 100644
--- a/database/migrations/2023_03_27_081716_create_applications_table.php
+++ b/database/migrations/2023_03_27_081716_create_applications_table.php
@@ -41,6 +41,8 @@ return new class extends Migration
$table->string('base_directory')->default('/');
$table->string('publish_directory')->nullable();
+ $table->schemalessAttributes('previews');
+
$table->string('health_check_path')->default('/');
$table->string('health_check_port')->nullable();
$table->string('health_check_host')->default('localhost');
diff --git a/database/seeders/ApplicationSeeder.php b/database/seeders/ApplicationSeeder.php
index fe95c6cc25..1bc48b76ec 100644
--- a/database/seeders/ApplicationSeeder.php
+++ b/database/seeders/ApplicationSeeder.php
@@ -2,6 +2,7 @@
namespace Database\Seeders;
+use App\Data\ApplicationPreview;
use App\Models\Application;
use App\Models\ApplicationSetting;
use App\Models\Environment;
@@ -36,6 +37,16 @@ class ApplicationSeeder extends Seeder
'destination_type' => StandaloneDocker::class,
'source_id' => $github_public_source->id,
'source_type' => GithubApp::class,
+ 'previews' => [
+ ApplicationPreview::from([
+ 'pullRequestId' => 1,
+ 'branch' => 'nodejs-fastify'
+ ]),
+ ApplicationPreview::from([
+ 'pullRequestId' => 2,
+ 'branch' => 'nodejs-fastify'
+ ])
+ ]
]);
}
}
diff --git a/resources/views/livewire/project/application/previews.blade.php b/resources/views/livewire/project/application/previews.blade.php
index 7b5056ce66..8401cd5545 100644
--- a/resources/views/livewire/project/application/previews.blade.php
+++ b/resources/views/livewire/project/application/previews.blade.php
@@ -1,3 +1,8 @@
<div>
<h2>Previews</h2>
+ <div class="flex gap-2">
+ @foreach ($application->previews as $preview)
+ <div class="box">{{ $preview['pullRequestId'] }} | {{ $preview['branch'] }}</div>
+ @endforeach
+ </div>
</div>
diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.php
index 1d94a56957..8922f4c8c1 100644
--- a/resources/views/project/application/configuration.blade.php
+++ b/resources/views/project/application/configuration.blade.php
@@ -18,9 +18,9 @@
<a :class="activeTab === 'storages' && 'text-purple-500'"
@click.prevent="activeTab = 'storages'; window.location.hash = 'storages'" href="#">Storages
</a>
- <a :class="activeTab === 'previews' && 'text-purple-500'"
+ {{-- <a :class="activeTab === 'previews' && 'text-purple-500'"
@click.prevent="activeTab = 'previews'; window.location.hash = 'previews'" href="#">Previews
- </a>
+ </a> --}}
</div>
<div class="w-full pl-8">
<div x-cloak x-show="activeTab === 'general'">
@@ -38,9 +38,9 @@
<div x-cloak x-show="activeTab === 'storages'">
<livewire:project.application.storages.all :application="$application" />
</div>
- <div x-cloak x-show="activeTab === 'previews'">
+ {{-- <div x-cloak x-show="activeTab === 'previews'">
<livewire:project.application.previews :application="$application" />
- </div>
+ </div> --}}
</div>
</div>
</x-layout>