diff --git a/app/Data/ApplicationPreview.php b/app/Data/ApplicationPreview.php new file mode 100644 index 000000000..8af3e3ec9 --- /dev/null +++ b/app/Data/ApplicationPreview.php @@ -0,0 +1,15 @@ +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 235c53494..d2afff3f5 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 e3b0d8fb0..500befe2c 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 fe95c6cc2..1bc48b76e 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 7b5056ce6..8401cd554 100644 --- a/resources/views/livewire/project/application/previews.blade.php +++ b/resources/views/livewire/project/application/previews.blade.php @@ -1,3 +1,8 @@

Previews

+
+ @foreach ($application->previews as $preview) +
{{ $preview['pullRequestId'] }} | {{ $preview['branch'] }}
+ @endforeach +
diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.php index 1d94a5695..8922f4c8c 100644 --- a/resources/views/project/application/configuration.blade.php +++ b/resources/views/project/application/configuration.blade.php @@ -18,9 +18,9 @@ Storages - Previews - + --}}
@@ -38,9 +38,9 @@
-
+ {{--
-
+
--}}