fixes here and there

This commit is contained in:
ayntk-ai
2024-09-02 19:27:21 +02:00
parent 843e3fb599
commit dfd218ec06
11 changed files with 58 additions and 79 deletions

View File

@@ -1,8 +1,6 @@
<?php <?php
namespace App\Livewire\Destination; namespace App\Livewire\Destination;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component; use Livewire\Component;
class Form extends Component class Form extends Component
@@ -27,13 +25,8 @@ class Form extends Component
$this->destination->save(); $this->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 { try {
if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') { if ($this->destination->getMorphClass() === 'App\Models\StandaloneDocker') {
if ($this->destination->attachedTo()) { if ($this->destination->attachedTo()) {
@@ -44,7 +37,7 @@ class Form extends Component
} }
$this->destination->delete(); $this->destination->delete();
return redirect()->route('dashboard'); return redirect()->route('destination.all');
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError($e, $this); return handleError($e, $this);
} }

View File

@@ -14,7 +14,9 @@ class BackupEdit extends Component
public $s3s; 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; public ?string $status = null;
@@ -58,8 +60,11 @@ class BackupEdit extends Component
} }
try { try {
if ($this->delete_associated_backups) { if ($this->delete_associated_backups_locally) {
$this->deleteAssociatedBackups(); $this->deleteAssociatedBackupsLocally();
}
if ($this->delete_associated_backups_s3) {
$this->deleteAssociatedBackupsS3();
} }
$this->backup->delete(); $this->backup->delete();
@@ -119,7 +124,7 @@ class BackupEdit extends Component
} }
} }
public function deleteAssociatedBackups() public function deleteAssociatedBackupsLocally()
{ {
$executions = $this->backup->executions; $executions = $this->backup->executions;
$backupFolder = null; $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) private function deleteEmptyBackupFolder($folderPath, $server)
{ {
$checkEmpty = instant_remote_process(["[ -z \"$(ls -A '$folderPath')\" ] && echo 'empty' || echo 'not empty'"], $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() 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', [ return view('livewire.project.database.backup-edit', [
'checkboxes' => [ '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.']
] ]
]); ]);
} }

View File

@@ -3,8 +3,6 @@
namespace App\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Environment; use App\Models\Environment;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component; use Livewire\Component;
class DeleteEnvironment extends Component class DeleteEnvironment extends Component
@@ -23,12 +21,8 @@ class DeleteEnvironment extends Component
$this->environmentName = Environment::findOrFail($this->environment_id)->name; $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([ $this->validate([
'environment_id' => 'required|int', 'environment_id' => 'required|int',
]); ]);

View File

@@ -3,8 +3,6 @@
namespace App\Livewire\Project; namespace App\Livewire\Project;
use App\Models\Project; use App\Models\Project;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component; use Livewire\Component;
class DeleteProject extends Component class DeleteProject extends Component
@@ -23,12 +21,8 @@ class DeleteProject extends Component
$this->projectName = Project::findOrFail($this->project_id)->name; $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([ $this->validate([
'project_id' => 'required|int', 'project_id' => 'required|int',
]); ]);

View File

@@ -64,7 +64,9 @@
const paramsMatch = this.submitAction.match(/\((.*?)\)/); const paramsMatch = this.submitAction.match(/\((.*?)\)/);
const params = paramsMatch ? paramsMatch[1].split(',').map(param => param.trim()) : []; const params = paramsMatch ? paramsMatch[1].split(',').map(param => param.trim()) : [];
if (this.confirmWithPassword) {
params.push(this.password); params.push(this.password);
}
params.push(this.selectedActions); params.push(this.selectedActions);
$wire[methodName](...params) $wire[methodName](...params)
@@ -162,14 +164,7 @@
<div class="px-2">Select the actions you want to perform:</div> <div class="px-2">Select the actions you want to perform:</div>
</div> </div>
@foreach($checkboxes as $index => $checkbox) @foreach($checkboxes as $index => $checkbox)
<x-forms.checkbox <x-forms.checkbox :id="$checkbox['id']" :wire:model="$checkbox['id']" :label="$checkbox['label']" x-on:change="toggleAction('{{ $checkbox['id'] }}')" :checked="$this->{$checkbox['id']}" x-bind:checked="selectedActions.includes('{{ $checkbox['id'] }}')"></x-forms.checkbox>
:id="$checkbox['id']"
:wire:model="$checkbox['id']"
:label="$checkbox['label']"
x-on:change="toggleAction('{{ $checkbox['id'] }}')"
:checked="$this->{$checkbox['id']}"
x-bind:checked="selectedActions.includes('{{ $checkbox['id'] }}')"
></x-forms.checkbox>
@endforeach @endforeach
</div> </div>
@endif @endif
@@ -269,23 +264,13 @@
</template> </template>
<template x-if="step === 2"> <template x-if="step === 2">
<x-forms.button <x-forms.button @click="confirmWithPassword ? step++ : submitForm()" x-bind:disabled="confirmWithText && userConfirmationText !== confirmationText" class="w-auto" isError>
@click="confirmWithPassword ? step++ : submitForm()" <span x-text="step2ButtonText"></span>
x-bind:disabled="confirmWithText && userConfirmationText !== confirmationText"
class="w-auto"
isError
>
<span x-text="confirmWithPassword ? step2ButtonText : step3ButtonText"></span>
</x-forms.button> </x-forms.button>
</template> </template>
<template x-if="step === 3 && confirmWithPassword"> <template x-if="step === 3 && confirmWithPassword">
<x-forms.button <x-forms.button @click="submitForm()" class="w-auto" isError x-bind:disabled="!password">
@click="submitForm()"
class="w-auto"
isError
x-bind:disabled="!password"
>
<span x-text="step3ButtonText"></span> <span x-text="step3ButtonText"></span>
</x-forms.button> </x-forms.button>
</template> </template>

View File

@@ -123,15 +123,14 @@
<x-loading /> <x-loading />
@endif @endif
<x-modal-confirmation <x-modal-confirmation
title="Confirm Queues Cleanup" title="Confirm Cleanup Queues?"
buttonTitle="Cleanup Queues" buttonTitle="Cleanup Queues"
isErrorButton isErrorButton
submitAction="cleanup_queue" submitAction="cleanup_queue"
:actions="['Cleanup all running Deployment Queues']" :actions="['All running Deployment Queues will be cleaned up.']"
buttonTitle="Cleanup Queues"
:confirmWithText="false" :confirmWithText="false"
:confirmWithPassword="false" :confirmWithPassword="false"
step3ButtonText="Cleanup Deployment Queues" step2ButtonText="Permanently Cleanup Deployment Queues"
/> />
</div> </div>
<div> <div>

View File

@@ -15,9 +15,8 @@
confirmationText="{{ $destination->name }}" confirmationText="{{ $destination->name }}"
confirmationLabel="Please confirm the execution of the actions by entering the Destination Name below" confirmationLabel="Please confirm the execution of the actions by entering the Destination Name below"
shortConfirmationLabel="Destination Name" shortConfirmationLabel="Destination Name"
buttonTitle="Delete Destination" :confirmWithPassword="false"
step3ButtonText="Permanently Delete Destination" step2ButtonText="Permanently Delete Destination"
:confirmWithPassword="true"
/> />
@endif @endif
</div> </div>

View File

@@ -10,14 +10,14 @@
@if ($backup->database_id !== 0) @if ($backup->database_id !== 0)
<x-modal-confirmation <x-modal-confirmation
title="Confirm Backup Schedule Deletion?" title="Confirm Backup Schedule Deletion?"
buttonTitle="Delete" buttonTitle="Delete Backups and Schedule"
isErrorButton isErrorButton
submitAction="delete"
:checkboxes="$checkboxes" :checkboxes="$checkboxes"
:actions="['The selected backup schedule will be deleted.', 'Scheduled backups for this database will be stopped (if this is the only backup schedule for this database).']" :actions="['The selected backup schedule will be deleted.', 'Scheduled backups for this database will be stopped (if this is the only backup schedule for this database).']"
confirmationText="{{ $backup->database->name }}" confirmationText="{{ $backup->database->name }}"
confirmationLabel="Please confirm the execution of the actions by entering the Database Name of the scheduled backups below" confirmationLabel="Please confirm the execution of the actions by entering the Database Name of the scheduled backups below"
shortConfirmationLabel="Database Name" shortConfirmationLabel="Database Name"
submitAction="delete"
/> />
@endif @endif
</div> </div>

View File

@@ -38,7 +38,6 @@
title="Confirm Backup Deletion?" title="Confirm Backup Deletion?"
buttonTitle="Delete" buttonTitle="Delete"
isErrorButton isErrorButton
type="button"
submitAction="deleteBackup({{ data_get($execution, 'id') }})" submitAction="deleteBackup({{ data_get($execution, 'id') }})"
{{-- :checkboxes="$checkboxes" --}} {{-- :checkboxes="$checkboxes" --}}
:actions="[ :actions="[

View File

@@ -6,7 +6,7 @@
:actions="['This will delete the selected environment.']" :actions="['This will delete the selected environment.']"
confirmationLabel="Please confirm the execution of the actions by entering the Environment Name below" confirmationLabel="Please confirm the execution of the actions by entering the Environment Name below"
shortConfirmationLabel="Environment Name" shortConfirmationLabel="Environment Name"
buttonTitle="Delete Environment"
confirmationText="{{ $environmentName }}" confirmationText="{{ $environmentName }}"
step3ButtonText="Permanently Delete Environment" :confirmWithPassword="false"
step2ButtonText="Permanently Delete Environment"
/> />

View File

@@ -3,10 +3,10 @@
buttonTitle="Delete Project" buttonTitle="Delete Project"
isErrorButton isErrorButton
submitAction="delete" submitAction="delete"
:actions="['This will delete the selected project.']" :actions="['This will delete the selected project', 'All Environments inside the project will be deleted as well.']"
confirmationLabel="Please confirm the execution of the actions by entering the Project Name below" confirmationLabel="Please confirm the execution of the actions by entering the Project Name below"
shortConfirmationLabel="Project Name" shortConfirmationLabel="Project Name"
buttonTitle="Delete Project"
confirmationText="{{ $projectName }}" confirmationText="{{ $projectName }}"
step3ButtonText="Permanently Delete Project" :confirmWithPassword="false"
step2ButtonText="Permanently Delete Project"
/> />