From dfd218ec064790d214bc57d3d9b3840f35b6a379 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 2 Sep 2024 19:27:21 +0200 Subject: [PATCH] fixes here and there --- app/Livewire/Destination/Form.php | 11 +--- app/Livewire/Project/Database/BackupEdit.php | 28 ++++++++-- app/Livewire/Project/DeleteEnvironment.php | 8 +-- app/Livewire/Project/DeleteProject.php | 8 +-- .../components/modal-confirmation.blade.php | 55 +++++++------------ resources/views/livewire/dashboard.blade.php | 7 +-- .../views/livewire/destination/form.blade.php | 5 +- .../project/database/backup-edit.blade.php | 4 +- .../database/backup-executions.blade.php | 1 - .../project/delete-environment.blade.php | 4 +- .../livewire/project/delete-project.blade.php | 6 +- 11 files changed, 58 insertions(+), 79 deletions(-) diff --git a/app/Livewire/Destination/Form.php b/app/Livewire/Destination/Form.php index f58538dc1..5b3115dea 100644 --- a/app/Livewire/Destination/Form.php +++ b/app/Livewire/Destination/Form.php @@ -1,8 +1,6 @@ destination->save(); } - public function delete($password) + public function delete() { - if (!Hash::check($password, Auth::user()->password)) { - $this->addError('password', 'The provided password is incorrect.'); - return; - } - try { if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') { if ($this->destination->attachedTo()) { @@ -44,7 +37,7 @@ class Form extends Component } $this->destination->delete(); - return redirect()->route('dashboard'); + return redirect()->route('destination.all'); } catch (\Throwable $e) { return handleError($e, $this); } diff --git a/app/Livewire/Project/Database/BackupEdit.php b/app/Livewire/Project/Database/BackupEdit.php index 9ef6cb9ed..9efb2d9fc 100644 --- a/app/Livewire/Project/Database/BackupEdit.php +++ b/app/Livewire/Project/Database/BackupEdit.php @@ -14,7 +14,9 @@ class BackupEdit extends Component public $s3s; - public bool $delete_associated_backups = false; + public bool $delete_associated_backups_locally = false; + public bool $delete_associated_backups_s3 = false; + public bool $delete_associated_backups_sftp = false; public ?string $status = null; @@ -58,8 +60,11 @@ class BackupEdit extends Component } try { - if ($this->delete_associated_backups) { - $this->deleteAssociatedBackups(); + if ($this->delete_associated_backups_locally) { + $this->deleteAssociatedBackupsLocally(); + } + if ($this->delete_associated_backups_s3) { + $this->deleteAssociatedBackupsS3(); } $this->backup->delete(); @@ -119,7 +124,7 @@ class BackupEdit extends Component } } - public function deleteAssociatedBackups() + public function deleteAssociatedBackupsLocally() { $executions = $this->backup->executions; $backupFolder = null; @@ -144,6 +149,16 @@ class BackupEdit extends Component } } + public function deleteAssociatedBackupsS3() + { + //Add function to delete backups from S3 + } + + public function deleteAssociatedBackupsSftp() + { + //Add function to delete backups from SFTP + } + private function deleteEmptyBackupFolder($folderPath, $server) { $checkEmpty = instant_remote_process(["[ -z \"$(ls -A '$folderPath')\" ] && echo 'empty' || echo 'not empty'"], $server); @@ -162,10 +177,11 @@ class BackupEdit extends Component public function render() { - //Add delete backup form S3 storage and delete backup for SFTP... when it is implemented return view('livewire.project.database.backup-edit', [ 'checkboxes' => [ - ['id' => 'delete_associated_backups', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from local storage.'] + ['id' => 'delete_associated_backups_locally', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from local storage.'], + // ['id' => 'delete_associated_backups_s3', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from the selected S3 Storage.'] + // ['id' => 'delete_associated_backups_sftp', 'label' => 'All backups associated with this backup job from this database will be permanently deleted from the selected SFTP Storage.'] ] ]); } diff --git a/app/Livewire/Project/DeleteEnvironment.php b/app/Livewire/Project/DeleteEnvironment.php index 7c60c6404..e01741770 100644 --- a/app/Livewire/Project/DeleteEnvironment.php +++ b/app/Livewire/Project/DeleteEnvironment.php @@ -3,8 +3,6 @@ namespace App\Livewire\Project; use App\Models\Environment; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Hash; use Livewire\Component; class DeleteEnvironment extends Component @@ -23,12 +21,8 @@ class DeleteEnvironment extends Component $this->environmentName = Environment::findOrFail($this->environment_id)->name; } - public function delete($password) + public function delete() { - if (!Hash::check($password, Auth::user()->password)) { - $this->addError('password', 'The provided password is incorrect.'); - return; - } $this->validate([ 'environment_id' => 'required|int', ]); diff --git a/app/Livewire/Project/DeleteProject.php b/app/Livewire/Project/DeleteProject.php index 75060f8f3..360fad10a 100644 --- a/app/Livewire/Project/DeleteProject.php +++ b/app/Livewire/Project/DeleteProject.php @@ -3,8 +3,6 @@ namespace App\Livewire\Project; use App\Models\Project; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Hash; use Livewire\Component; class DeleteProject extends Component @@ -23,12 +21,8 @@ class DeleteProject extends Component $this->projectName = Project::findOrFail($this->project_id)->name; } - public function delete($password) + public function delete() { - if (!Hash::check($password, Auth::user()->password)) { - $this->addError('password', 'The provided password is incorrect.'); - return; - } $this->validate([ 'project_id' => 'required|int', ]); diff --git a/resources/views/components/modal-confirmation.blade.php b/resources/views/components/modal-confirmation.blade.php index 9e3abac31..a726406cd 100644 --- a/resources/views/components/modal-confirmation.blade.php +++ b/resources/views/components/modal-confirmation.blade.php @@ -64,7 +64,9 @@ const paramsMatch = this.submitAction.match(/\((.*?)\)/); const params = paramsMatch ? paramsMatch[1].split(',').map(param => param.trim()) : []; - params.push(this.password); + if (this.confirmWithPassword) { + params.push(this.password); + } params.push(this.selectedActions); $wire[methodName](...params) @@ -162,14 +164,7 @@
{{ $message }}
+{{ $message }}
@enderror @@ -263,29 +258,19 @@ -