diff --git a/app/Livewire/Upgrade.php b/app/Livewire/Upgrade.php index f13baa7a7..1b145b244 100644 --- a/app/Livewire/Upgrade.php +++ b/app/Livewire/Upgrade.php @@ -4,6 +4,7 @@ use App\Actions\Server\UpdateCoolify; use App\Models\InstanceSettings; +use App\Services\ChangelogService; use Livewire\Component; class Upgrade extends Component @@ -14,21 +15,57 @@ class Upgrade extends Component public string $latestVersion = ''; + public string $currentVersion = ''; + + public array $changelogEntries = []; + protected $listeners = ['updateAvailable' => 'checkUpdate']; + public function mount() + { + $this->currentVersion = config('constants.coolify.version'); + } + public function checkUpdate() { try { $this->latestVersion = get_latest_version_of_coolify(); + $this->currentVersion = config('constants.coolify.version'); $this->isUpgradeAvailable = data_get(InstanceSettings::get(), 'new_version_available', false); if (isDev()) { $this->isUpgradeAvailable = true; } + $this->loadChangelog(); } catch (\Throwable $e) { return handleError($e, $this); } } + public function loadChangelog() + { + try { + $service = app(ChangelogService::class); + $currentVersion = str_replace('v', '', $this->currentVersion); + + $this->changelogEntries = $service->getEntries(1) + ->filter(function ($entry) use ($currentVersion) { + $entryVersion = str_replace('v', '', $entry->tag_name); + + return version_compare($entryVersion, $currentVersion, '>'); + }) + ->take(3) + ->map(fn ($entry) => [ + 'tag_name' => $entry->tag_name, + 'title' => $entry->title, + 'content_html' => $entry->content_html, + ]) + ->values() + ->toArray(); + } catch (\Throwable $e) { + $this->changelogEntries = []; + } + } + public function upgrade() { try { diff --git a/resources/views/components/upgrade-progress.blade.php b/resources/views/components/upgrade-progress.blade.php new file mode 100644 index 000000000..13eca4f5b --- /dev/null +++ b/resources/views/components/upgrade-progress.blade.php @@ -0,0 +1,143 @@ +@props(['step' => 0]) + +
+
+ {{-- Step 1: Preparing --}} +
+
+
+ + + +
+ Preparing +
+
+
+ + {{-- Step 2: Helper --}} +
+
+
+ + + +
+ Helper +
+
+
+ + {{-- Step 3: Image --}} +
+
+
+ + + +
+ Image +
+
+
+ + {{-- Step 4: Restart --}} +
+
+
+ + + +
+ Restart +
+
+
+
diff --git a/resources/views/livewire/upgrade.blade.php b/resources/views/livewire/upgrade.blade.php index 37e43935d..101c4cf94 100644 --- a/resources/views/livewire/upgrade.blade.php +++ b/resources/views/livewire/upgrade.blade.php @@ -1,5 +1,8 @@
+ x-init="$wire.checkUpdate" x-data="upgradeModal({ + currentVersion: @js($currentVersion), + latestVersion: @js($latestVersion) + })"> @if ($isUpgradeAvailable)
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100" x-transition:leave-end="opacity-0 -translate-y-2 sm:scale-95" class="relative w-full py-6 border rounded-sm min-w-full lg:min-w-[36rem] max-w-fit bg-neutral-100 border-neutral-400 dark:bg-base px-7 dark:border-coolgray-300"> + + {{-- Header --}}
-

Upgrade confirmation

+
+

+
+ {{ $currentVersion }} {{ $latestVersion }} +
+
-
-

Are you sure you would like to upgrade your instance to {{ $latestVersion }}?

-
- -

Any deployments running during the update process will - fail. Please ensure no deployments are in progress on any server before continuing. -

-
-
-

You can review the changelogs here.

-
-

If something goes wrong and you cannot upgrade your instance, You can check the following - guide on what to do. -

-
-

Progress

-
-
+ {{-- Content --}} +
+ {{-- Progress View --}} + + + {{-- Confirmation View --}} +
+ + {{-- Footer Actions --}}
Cancel
- Continue + + Upgrade Now
@@ -89,23 +185,57 @@ class="w-24 dark:bg-coolgray-200 dark:hover:bg-coolgray-300">Cancel