From 50e96baea14bc2880c9abad838dc4a1ae2066279 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 12 Apr 2024 10:28:40 +0200 Subject: [PATCH] Refactor Livewire project new select blade template --- app/Livewire/Project/Application/General.php | 9 ++++ app/Livewire/Project/Application/Heading.php | 1 + app/Livewire/Project/Service/EditCompose.php | 2 +- .../views/components/forms/button.blade.php | 9 ++-- .../project/application/general.blade.php | 46 ++++++++++++------- 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index a8032f6f8..c2bbed5ff 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -25,6 +25,7 @@ class General extends Component public $customLabels; public bool $labelsChanged = false; public bool $isConfigurationChanged = false; + public bool $initLoadingCompose = false; public ?string $initialDockerComposeLocation = null; public ?string $initialDockerComposePrLocation = null; @@ -136,6 +137,10 @@ class General extends Component $this->application->save(); } $this->initialDockerComposeLocation = $this->application->docker_compose_location; + if ($this->application->build_pack === 'dockercompose' && !$this->application->docker_compose_raw) { + $this->initLoadingCompose = true; + $this->dispatch('info', 'Loading docker compose file...'); + } } public function instantSave() { @@ -154,11 +159,15 @@ class General extends Component } ['parsedServices' => $this->parsedServices, 'initialDockerComposeLocation' => $this->initialDockerComposeLocation, 'initialDockerComposePrLocation' => $this->initialDockerComposePrLocation] = $this->application->loadComposeFile($isInit); $this->dispatch('success', 'Docker compose file loaded.'); + $this->dispatch('compose_loaded'); } catch (\Throwable $e) { $this->application->docker_compose_location = $this->initialDockerComposeLocation; $this->application->docker_compose_pr_location = $this->initialDockerComposePrLocation; $this->application->save(); return handleError($e, $this); + } finally { + $this->initLoadingCompose = false; + } } public function generateDomain(string $serviceName) diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 089eb5e9f..2e1f8a7c7 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -22,6 +22,7 @@ class Heading extends Component $teamId = auth()->user()->currentTeam()->id; return [ "echo-private:team.{$teamId},ApplicationStatusChanged" => 'check_status', + "compose_loaded" => '$refresh', ]; } public function mount() diff --git a/app/Livewire/Project/Service/EditCompose.php b/app/Livewire/Project/Service/EditCompose.php index cc385315e..84cc45cf2 100644 --- a/app/Livewire/Project/Service/EditCompose.php +++ b/app/Livewire/Project/Service/EditCompose.php @@ -18,7 +18,7 @@ class EditCompose extends Component } public function saveEditedCompose() { - $this->dispatch('warning', "Saving new docker compose..."); + $this->dispatch('info', "Saving new docker compose..."); $this->dispatch('saveCompose', $this->service->docker_compose_raw); } public function render() diff --git a/resources/views/components/forms/button.blade.php b/resources/views/components/forms/button.blade.php index 3eafc26c6..a109e84ac 100644 --- a/resources/views/components/forms/button.blade.php +++ b/resources/views/components/forms/button.blade.php @@ -5,11 +5,14 @@ @endisset @isset($confirmAction) x-on:{{ explode('(', $confirmAction)[0] }}.window="$wire.{{ explode('(', $confirmAction)[0] }}" - @endisset - > + @endisset> {{ $slot }} @if ($attributes->whereStartsWith('wire:click')->first()) - + + @elseif($attributes->whereStartsWith('wire:target')->first()) + @endif diff --git a/resources/views/livewire/project/application/general.blade.php b/resources/views/livewire/project/application/general.blade.php index 00c204f46..b31c14882 100644 --- a/resources/views/livewire/project/application/general.blade.php +++ b/resources/views/livewire/project/application/general.blade.php @@ -1,4 +1,4 @@ -
+

General

@@ -17,14 +17,15 @@
General configuration for your application.
- - + +
@if (!$application->dockerfile && $application->build_pack !== 'dockerimage')
- + @@ -152,23 +153,24 @@ @endif @endif @if ($application->build_pack === 'dockercompose') -
+
- -
The following commands are for advanced use cases. Only modify them if you know what are you doing.
- - @@ -220,7 +222,8 @@ id="application.custom_docker_run_options" label="Custom Docker Options" /> @endif @if ($application->build_pack === 'dockercompose') - Reload Compose File + Reload Compose File @if ($application->settings->is_raw_compose_deployment_enabled) Pre/Post Deployment Commands
- -
- -
+ @script + + @endscript