This commit is contained in:
Andras Bacsai 2023-05-31 14:42:37 +02:00
parent 5b3a3edcd0
commit 25870dadd8
10 changed files with 31 additions and 15 deletions

View File

@ -49,9 +49,10 @@ class Deploy extends Component
deployment_uuid: $this->deployment_uuid, deployment_uuid: $this->deployment_uuid,
force_rebuild: $force, force_rebuild: $force,
); );
return redirect()->route('project.application.deployments', [ return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ]);
} }

View File

@ -16,6 +16,7 @@ class DeploymentLogs extends Component
public $deployment_uuid; public $deployment_uuid;
public function polling() public function polling()
{ {
$this->emit('deploymentFinished');
if (is_null($this->activity) && isset($this->deployment_uuid)) { if (is_null($this->activity) && isset($this->deployment_uuid)) {
$this->activity = Activity::query() $this->activity = Activity::query()
->where('properties->type', '=', ActivityTypes::DEPLOYMENT->value) ->where('properties->type', '=', ActivityTypes::DEPLOYMENT->value)

View File

@ -12,6 +12,11 @@ class DeploymentNavbar extends Component
public Application $application; public Application $application;
public $activity; public $activity;
public string $deployment_uuid; public string $deployment_uuid;
protected $listeners = ['deploymentFinished'];
public function deploymentFinished()
{
$this->activity->refresh();
}
public function cancel() public function cancel()
{ {
try { try {

View File

@ -59,9 +59,10 @@ class Previews extends Component
force_rebuild: true, force_rebuild: true,
pull_request_id: $pull_request_id, pull_request_id: $pull_request_id,
); );
return redirect()->route('project.application.deployments', [ return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ]);
} catch (\Throwable $th) { } catch (\Throwable $th) {

View File

@ -29,9 +29,10 @@ class Rollback extends Component
force_rebuild: false, force_rebuild: false,
); );
return redirect()->route('project.application.deployments', [ return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'], 'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'], 'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $deployment_uuid,
'environment_name' => $this->parameters['environment_name'], 'environment_name' => $this->parameters['environment_name'],
]); ]);
} }

View File

@ -1,7 +1,15 @@
<div> <div>
<div class="pt-2 text-sm">Build status: {{ data_get($activity, 'properties.status') }}</div> <livewire:project.application.deployment-navbar :activity="$activity" :application="$application" :deployment_uuid="$deployment_uuid" />
<h3 class="pb-0">Logs</h3>
@if (data_get($activity, 'properties.status') === 'in_progress') @if (data_get($activity, 'properties.status') === 'in_progress')
<livewire:project.application.deployment-navbar :activity="$activity" :application="$application" :deployment_uuid="$deployment_uuid" /> <div class="pt-2 text-sm">Deployment is
<span class="text-warning">{{ Str::headline(data_get($activity, 'properties.status')) }}</span>. Logs will
be updated
automatically.
</div>
@else
<div class="pt-2 text-sm">Deployment is <span
class="text-warning">{{ Str::headline(data_get($activity, 'properties.status')) }}</span>.</div>
@endif @endif
<div <div
class="scrollbar flex flex-col-reverse w-full overflow-y-auto border border-solid rounded border-coolgray-300 max-h-[32rem] p-4 mt-4 text-xs text-white"> class="scrollbar flex flex-col-reverse w-full overflow-y-auto border border-solid rounded border-coolgray-300 max-h-[32rem] p-4 mt-4 text-xs text-white">

View File

@ -1,3 +1,8 @@
<div> <div>
<x-forms.button wire:click.prevent="cancel">Cancel deployment</x-forms.button> <h3>Actions</h3>
@if (data_get($activity, 'properties.status') === 'in_progress')
<x-forms.button wire:click.prevent="cancel">Cancel deployment</x-forms.button>
@else
<x-forms.button disabled>Cancel deployment</x-forms.button>
@endif
</div> </div>

View File

@ -1,4 +1,4 @@
<div class="flex flex-col gap-2 pt-2 " wire:init='load_deployments' <div class="flex flex-col gap-2" wire:init='load_deployments'
@if ($skip == 0) wire:poll.5000ms='reload_deployments' @endif> @if ($skip == 0) wire:poll.5000ms='reload_deployments' @endif>
<div> <div>
<h3>Actions</h3> <h3>Actions</h3>
@ -10,9 +10,6 @@
@endif @endif
</div> </div>
<h3>Deployments</h3> <h3>Deployments</h3>
<div wire:loading wire:target='load_deployments'>
<x-loading />
</div>
@foreach ($deployments as $deployment) @foreach ($deployments as $deployment)
<a @class([ <a @class([
'bg-coolgray-200 p-2 border-l border-dashed transition-colors hover:no-underline', 'bg-coolgray-200 p-2 border-l border-dashed transition-colors hover:no-underline',
@ -52,7 +49,7 @@
@endif @endif
<div class="flex flex-col" x-data="elapsedTime('{{ $deployment->deployment_uuid }}', '{{ $deployment->status }}', '{{ $deployment->created_at }}', '{{ $deployment->updated_at }}')"> <div class="flex flex-col" x-data="elapsedTime('{{ $deployment->deployment_uuid }}', '{{ $deployment->status }}', '{{ $deployment->created_at }}', '{{ $deployment->updated_at }}')">
<div>Finished <span x-text="measure_since_started()">0s</span> in <span class="font-bold text-white" <div>Finished <span x-text="measure_since_started()">0s</span> in <span class="font-bold"
x-text="measure_finished_time()">0s</span></div> x-text="measure_finished_time()">0s</span></div>
</div> </div>
</div> </div>

View File

@ -12,8 +12,5 @@
</ul> </ul>
</div> </div>
<x-applications.navbar :application="$application" /> <x-applications.navbar :application="$application" />
{{-- @if (data_get($activity, 'properties.status') === 'in_progress' && (data_get($deployment, 'metadata.status') !== 'error' || data_get($deployment, 'metadata.status') !== 'finished'))
<livewire:project.application.deployment-cancel :activity="$activity" :application="$application" :deployment_uuid="$deployment_uuid" />
@endif --}}
<livewire:project.application.deployment-logs :activity="$activity" :application="$application" :deployment_uuid="$deployment_uuid" /> <livewire:project.application.deployment-logs :activity="$activity" :application="$application" :deployment_uuid="$deployment_uuid" />
</x-layout> </x-layout>

View File

@ -1,7 +1,7 @@
<x-layout> <x-layout>
<h1 class="pb-0">Deployments</h1> <h1 class="pb-0">Deployments</h1>
<div class="pb-10 text-sm breadcrumbs"> <div class="pb-10 text-sm breadcrumbs">
<ul> <ul>`
<li><a <li><a
href="{{ route('project.show', ['project_uuid' => request()->route('project_uuid')]) }}">{{ $application->environment->project->name }}</a> href="{{ route('project.show', ['project_uuid' => request()->route('project_uuid')]) }}">{{ $application->environment->project->name }}</a>
</li> </li>