Fix application delete
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Livewire\Project\Shared;
|
namespace App\Livewire\Project\Shared;
|
||||||
|
|
||||||
use App\Jobs\DeleteResourceJob;
|
use App\Jobs\DeleteResourceJob;
|
||||||
|
use App\Models\Service;
|
||||||
|
use App\Models\ServiceDatabase;
|
||||||
|
use App\Models\ServiceApplication;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Visus\Cuid2\Cuid2;
|
use Visus\Cuid2\Cuid2;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
@@ -11,36 +14,48 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
class Danger extends Component
|
class Danger extends Component
|
||||||
{
|
{
|
||||||
public $resource;
|
public $resource;
|
||||||
|
public $service;
|
||||||
|
public $resourceName;
|
||||||
public $projectUuid;
|
public $projectUuid;
|
||||||
|
|
||||||
public $environmentName;
|
public $environmentName;
|
||||||
|
|
||||||
public bool $delete_configurations = true;
|
public bool $delete_configurations = true;
|
||||||
|
|
||||||
public bool $delete_volumes = true;
|
public bool $delete_volumes = true;
|
||||||
|
|
||||||
public bool $docker_cleanup = true;
|
public bool $docker_cleanup = true;
|
||||||
|
|
||||||
public bool $delete_connected_networks = true;
|
public bool $delete_connected_networks = true;
|
||||||
|
|
||||||
public ?string $modalId = null;
|
public ?string $modalId = null;
|
||||||
|
public string $resourceDomain = '';
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->modalId = new Cuid2;
|
|
||||||
$parameters = get_route_parameters();
|
$parameters = get_route_parameters();
|
||||||
|
$this->modalId = new Cuid2;
|
||||||
$this->projectUuid = data_get($parameters, 'project_uuid');
|
$this->projectUuid = data_get($parameters, 'project_uuid');
|
||||||
$this->environmentName = data_get($parameters, 'environment_name');
|
$this->environmentName = data_get($parameters, 'environment_name');
|
||||||
|
|
||||||
|
// Determine the resource name based on the available properties
|
||||||
|
if ($this->resource) {
|
||||||
|
$this->resourceName = $this->resource->name ?? 'Resource';
|
||||||
|
} elseif ($this->service) {
|
||||||
|
$this->resourceName = $this->service->name ?? 'Service'; //this does not get the name of the service
|
||||||
|
} else {
|
||||||
|
$this->resourceName = 'Unknown Resource'; //service is here?
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($selectedActions, $password)
|
ray($this->resourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($password)
|
||||||
{
|
{
|
||||||
if (!Hash::check($password, Auth::user()->password)) {
|
if (!Hash::check($password, Auth::user()->password)) {
|
||||||
$this->addError('password', 'The provided password is incorrect.');
|
$this->addError('password', 'The provided password is incorrect.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->resource) {
|
||||||
|
$this->addError('resource', 'Resource not found.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// $this->authorize('delete', $this->resource);
|
// $this->authorize('delete', $this->resource);
|
||||||
$this->resource->delete();
|
$this->resource->delete();
|
||||||
@@ -60,4 +75,9 @@ class Danger extends Component
|
|||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.project.shared.danger');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
'checkboxActions' => [],
|
'checkboxActions' => [],
|
||||||
'actions' => [],
|
'actions' => [],
|
||||||
'confirmWithText' => true,
|
'confirmWithText' => true,
|
||||||
'confirmText' => 'DELETE',
|
'confirmText' => 'Confirm Deletion',
|
||||||
'confirmWithPassword' => true,
|
'confirmWithPassword' => true,
|
||||||
'step1ButtonText' => 'Continue Deletion',
|
'step1ButtonText' => 'Continue Deletion',
|
||||||
'step2ButtonText' => 'Delete Permanently',
|
'step2ButtonText' => 'Delete Permanently',
|
||||||
@@ -49,9 +49,9 @@
|
|||||||
step3ButtonText: @js($step3ButtonText),
|
step3ButtonText: @js($step3ButtonText),
|
||||||
executeAction() {
|
executeAction() {
|
||||||
if (this.confirmWithPassword) {
|
if (this.confirmWithPassword) {
|
||||||
$wire.call(this.action, this.selectedActions, this.password);
|
$wire.call(this.action, this.password);
|
||||||
} else {
|
} else {
|
||||||
$wire.call(this.action, this.selectedActions);
|
$wire.call(this.action);
|
||||||
}
|
}
|
||||||
this.modalOpen = false;
|
this.modalOpen = false;
|
||||||
this.resetModal();
|
this.resetModal();
|
||||||
|
|||||||
Reference in New Issue
Block a user