feat(deployment): add pull request filtering and pagination to deployment and backup execution components

fix(ui): make them more stylish yeah
This commit is contained in:
Andras Bacsai
2025-07-13 12:36:53 +02:00
parent fbe98cfd11
commit 0b84792871
8 changed files with 493 additions and 73 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Livewire\Project\Database;
use App\Models\InstanceSettings;
use App\Models\ScheduledDatabaseBackup;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component;
@@ -14,7 +15,19 @@ class BackupExecutions extends Component
public $database;
public $executions = [];
public ?Collection $executions;
public int $executions_count = 0;
public int $skip = 0;
public int $defaultTake = 10;
public bool $showNext = false;
public bool $showPrev = false;
public int $currentPage = 1;
public $setDeletableBackup;
@@ -40,6 +53,20 @@ class BackupExecutions extends Component
}
}
public function cleanupDeleted()
{
if ($this->backup) {
$deletedCount = $this->backup->executions()->where('local_storage_deleted', true)->count();
if ($deletedCount > 0) {
$this->backup->executions()->where('local_storage_deleted', true)->delete();
$this->refreshBackupExecutions();
$this->dispatch('success', "Cleaned up {$deletedCount} backup entries deleted from local storage.");
} else {
$this->dispatch('info', 'No backup entries found that are deleted from local storage.');
}
}
}
public function deleteBackup($executionId, $password)
{
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) {
@@ -85,18 +112,74 @@ class BackupExecutions extends Component
public function refreshBackupExecutions(): void
{
if ($this->backup && $this->backup->exists) {
$this->executions = $this->backup->executions()->get()->toArray();
} else {
$this->executions = [];
$this->loadExecutions();
}
public function reloadExecutions()
{
$this->loadExecutions();
}
public function previousPage(?int $take = null)
{
if ($take) {
$this->skip = $this->skip - $take;
}
$this->skip = $this->skip - $this->defaultTake;
if ($this->skip < 0) {
$this->showPrev = false;
$this->skip = 0;
}
$this->updateCurrentPage();
$this->loadExecutions();
}
public function nextPage(?int $take = null)
{
if ($take) {
$this->skip = $this->skip + $take;
}
$this->showPrev = true;
$this->updateCurrentPage();
$this->loadExecutions();
}
private function loadExecutions()
{
if ($this->backup && $this->backup->exists) {
['executions' => $executions, 'count' => $count] = $this->backup->executionsPaginated($this->skip, $this->defaultTake);
$this->executions = $executions;
$this->executions_count = $count;
} else {
$this->executions = collect([]);
$this->executions_count = 0;
}
$this->showMore();
}
private function showMore()
{
if ($this->executions->count() !== 0) {
$this->showNext = true;
if ($this->executions->count() < $this->defaultTake) {
$this->showNext = false;
}
return;
}
}
private function updateCurrentPage()
{
$this->currentPage = intval($this->skip / $this->defaultTake) + 1;
}
public function mount(ScheduledDatabaseBackup $backup)
{
$this->backup = $backup;
$this->database = $backup->database;
$this->refreshBackupExecutions();
$this->updateCurrentPage();
$this->loadExecutions();
}
public function server()