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 @@ public function deploy(bool $force = false)
deployment_uuid: $this->deployment_uuid,
force_rebuild: $force,
);
return redirect()->route('project.application.deployments', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid,
'environment_name' => $this->parameters['environment_name'],
]);
}

View File

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

View File

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

View File

@ -59,9 +59,10 @@ public function deploy(int $pull_request_id, string|null $pull_request_html_url)
force_rebuild: true,
pull_request_id: $pull_request_id,
);
return redirect()->route('project.application.deployments', [
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deployment_uuid,
'environment_name' => $this->parameters['environment_name'],
]);
} catch (\Throwable $th) {

View File

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

View File

@ -1,7 +1,15 @@
<div>
<div class="pt-2 text-sm">Build status: {{ data_get($activity, 'properties.status') }}</div>
@if (data_get($activity, 'properties.status') === 'in_progress')
<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')
<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
<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">

View File

@ -1,3 +1,8 @@
<div>
<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>

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>
<div>
<h3>Actions</h3>
@ -10,9 +10,6 @@
@endif
</div>
<h3>Deployments</h3>
<div wire:loading wire:target='load_deployments'>
<x-loading />
</div>
@foreach ($deployments as $deployment)
<a @class([
'bg-coolgray-200 p-2 border-l border-dashed transition-colors hover:no-underline',
@ -52,7 +49,7 @@ class="hover:no-underline">
@endif
<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>
</div>
</div>

View File

@ -12,8 +12,5 @@
</ul>
</div>
<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" />
</x-layout>

View File

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