wip previews
This commit is contained in:
parent
9bbf25b9f4
commit
ec233162e9
15
app/Data/ApplicationPreview.php
Normal file
15
app/Data/ApplicationPreview.php
Normal file
@ -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,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,4 @@ use Livewire\Component;
|
|||||||
class Previews extends Component
|
class Previews extends Component
|
||||||
{
|
{
|
||||||
public Application $application;
|
public Application $application;
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.project.application.previews');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Spatie\Activitylog\Models\Activity;
|
use Spatie\Activitylog\Models\Activity;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
|
||||||
|
|
||||||
class Application extends BaseModel
|
class Application extends BaseModel
|
||||||
{
|
{
|
||||||
@ -20,8 +22,6 @@ class Application extends BaseModel
|
|||||||
$application->persistentStorages()->delete();
|
$application->persistentStorages()->delete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'project_id',
|
'project_id',
|
||||||
@ -40,6 +40,16 @@ class Application extends BaseModel
|
|||||||
'publish_directory',
|
'publish_directory',
|
||||||
'private_key_id'
|
'private_key_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $casts = [
|
||||||
|
'previews' => SchemalessAttributes::class,
|
||||||
|
];
|
||||||
|
public function scopeWithExtraAttributes(): Builder
|
||||||
|
{
|
||||||
|
return $this->previews->modelScope();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function publishDirectory(): Attribute
|
public function publishDirectory(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
|
@ -28,7 +28,6 @@ class Server extends BaseModel
|
|||||||
'extra_attributes' => SchemalessAttributes::class,
|
'extra_attributes' => SchemalessAttributes::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function standaloneDockers()
|
public function standaloneDockers()
|
||||||
{
|
{
|
||||||
return $this->hasMany(StandaloneDocker::class);
|
return $this->hasMany(StandaloneDocker::class);
|
||||||
|
@ -41,6 +41,8 @@ return new class extends Migration
|
|||||||
$table->string('base_directory')->default('/');
|
$table->string('base_directory')->default('/');
|
||||||
$table->string('publish_directory')->nullable();
|
$table->string('publish_directory')->nullable();
|
||||||
|
|
||||||
|
$table->schemalessAttributes('previews');
|
||||||
|
|
||||||
$table->string('health_check_path')->default('/');
|
$table->string('health_check_path')->default('/');
|
||||||
$table->string('health_check_port')->nullable();
|
$table->string('health_check_port')->nullable();
|
||||||
$table->string('health_check_host')->default('localhost');
|
$table->string('health_check_host')->default('localhost');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Data\ApplicationPreview;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationSetting;
|
use App\Models\ApplicationSetting;
|
||||||
use App\Models\Environment;
|
use App\Models\Environment;
|
||||||
@ -36,6 +37,16 @@ class ApplicationSeeder extends Seeder
|
|||||||
'destination_type' => StandaloneDocker::class,
|
'destination_type' => StandaloneDocker::class,
|
||||||
'source_id' => $github_public_source->id,
|
'source_id' => $github_public_source->id,
|
||||||
'source_type' => GithubApp::class,
|
'source_type' => GithubApp::class,
|
||||||
|
'previews' => [
|
||||||
|
ApplicationPreview::from([
|
||||||
|
'pullRequestId' => 1,
|
||||||
|
'branch' => 'nodejs-fastify'
|
||||||
|
]),
|
||||||
|
ApplicationPreview::from([
|
||||||
|
'pullRequestId' => 2,
|
||||||
|
'branch' => 'nodejs-fastify'
|
||||||
|
])
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<h2>Previews</h2>
|
<h2>Previews</h2>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
@foreach ($application->previews as $preview)
|
||||||
|
<div class="box">{{ $preview['pullRequestId'] }} | {{ $preview['branch'] }}</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
<a :class="activeTab === 'storages' && 'text-purple-500'"
|
<a :class="activeTab === 'storages' && 'text-purple-500'"
|
||||||
@click.prevent="activeTab = 'storages'; window.location.hash = 'storages'" href="#">Storages
|
@click.prevent="activeTab = 'storages'; window.location.hash = 'storages'" href="#">Storages
|
||||||
</a>
|
</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
|
@click.prevent="activeTab = 'previews'; window.location.hash = 'previews'" href="#">Previews
|
||||||
</a>
|
</a> --}}
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full pl-8">
|
<div class="w-full pl-8">
|
||||||
<div x-cloak x-show="activeTab === 'general'">
|
<div x-cloak x-show="activeTab === 'general'">
|
||||||
@ -38,9 +38,9 @@
|
|||||||
<div x-cloak x-show="activeTab === 'storages'">
|
<div x-cloak x-show="activeTab === 'storages'">
|
||||||
<livewire:project.application.storages.all :application="$application" />
|
<livewire:project.application.storages.all :application="$application" />
|
||||||
</div>
|
</div>
|
||||||
<div x-cloak x-show="activeTab === 'previews'">
|
{{-- <div x-cloak x-show="activeTab === 'previews'">
|
||||||
<livewire:project.application.previews :application="$application" />
|
<livewire:project.application.previews :application="$application" />
|
||||||
</div>
|
</div> --}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user