An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
wip revert
Andras Bacsai3565dd9c56e0
diff --git a/app/Http/Livewire/Project/Application/Revert.php b/app/Http/Livewire/Project/Application/Revert.phpnew file mode 100644index 0000000000..f1917ef850--- /dev/null+++ b/app/Http/Livewire/Project/Application/Revert.php@@ -0,0 +1,43 @@+<?php++namespace App\Http\Livewire\Project\Application;++use App\Models\Application;+use Livewire\Component;+use Illuminate\Support\Str;++class Revert extends Component+{+ public Application $application;+ public $images = [];+ public string $current;+ public function loadImages()+ {+ try {+ $image = $this->application->uuid;+ $output = instantRemoteProcess([+ "docker inspect --format='{{.Config.Image}}' {$this->application->uuid}",+ ], $this->application->destination->server, throwError: false);+ $current_tag = Str::of($output)->trim()->explode(":");+ $this->current = data_get($current_tag, 1);++ $output = instantRemoteProcess([+ "docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}'",+ ], $this->application->destination->server);+ $this->images = Str::of($output)->trim()->explode("\n")->filter(function ($item) use ($image) {+ return Str::of($item)->contains($image);+ })->map(function ($item) {+ $item = Str::of($item)->explode('#');+ if ($item[1] === $this->current) {+ $item[1] = $item[1] . " (current)";+ }+ return [+ 'tag' => $item[1],+ 'createdAt' => $item[2],+ ];+ })->toArray();+ } catch (\Throwable $e) {+ return generalErrorHandler($e, $this);+ }+ }+}diff --git a/app/Models/Application.php b/app/Models/Application.phpindex df4b47c9da..57ef285014 100644--- a/app/Models/Application.php+++ b/app/Models/Application.php@@ -73,7 +73,6 @@ class Application extends BaseModelreturn "{$this->source->html_url}/{$this->git_repository}/commits/{$this->git_branch}";}}-);}public function baseDirectory(): Attributediff --git a/resources/views/components/proxy/loading.blade.php b/resources/views/components/loading.blade.phpsimilarity index 100%rename from resources/views/components/proxy/loading.blade.phprename to resources/views/components/loading.blade.phpdiff --git a/resources/views/livewire/project/application/revert.blade.php b/resources/views/livewire/project/application/revert.blade.phpnew file mode 100644index 0000000000..2ca8e5e291--- /dev/null+++ b/resources/views/livewire/project/application/revert.blade.php@@ -0,0 +1,27 @@+<div x-init="$wire.loadImages">+ <div wire:loading wire:target='loadImages'>+ <x-loading />+ </div>+ <div wire:loading.remove>+ <div class="flex flex-wrap">+ @forelse ($images as $image)+ <div class="w-1/2 p-2">+ <div class="rounded-lg shadow-lg bg-coolgray-200 ">+ <div class="p-2">+ <div class="text-sm font-bold">{{ data_get($image, 'tag') }}</div>+ <div class="text-xs">{{ data_get($image, 'createdAt') }}</div>+ </div>+ <div class="flex justify-end p-2">+ <x-inputs.button+ wire:click="revertImage('{{ data_get($image, 'name') }}', '{{ data_get($image, 'tag') }}')">+ Revert+ </x-inputs.button>+ </div>+ </div>+ </div>+ @empty+ <div>No images found</div>+ @endforelse+ </div>+ </div>+</div>diff --git a/resources/views/livewire/server/proxy.blade.php b/resources/views/livewire/server/proxy.blade.phpindex 3532c5e495..69a245c18f 100644--- a/resources/views/livewire/server/proxy.blade.php+++ b/resources/views/livewire/server/proxy.blade.php@@ -30,7 +30,7 @@</div><div x-init="$wire.checkProxySettingsInSync"><div wire:loading wire:target="checkProxySettingsInSync">- <x-proxy.loading />+ <x-loading /></div>@isset($proxy_settings)<h3>Configuration</h3>diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.phpindex 499bb8e09d..e4e5a0c529 100644--- a/resources/views/project/application/configuration.blade.php+++ b/resources/views/project/application/configuration.blade.php@@ -42,7 +42,7 @@<livewire:project.application.storages.all :application="$application" /></div><div x-cloak x-show="activeTab === 'revert'">- <h3>TODO 🚧</h3>+ <livewire:project.application.revert :application="$application" /></div>{{-- <div x-cloak x-show="activeTab === 'previews'"><livewire:project.application.previews :application="$application" />