2023-05-05 10:08:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Shared\Storages;
|
2023-05-05 10:08:38 +00:00
|
|
|
|
2024-10-22 10:29:48 +00:00
|
|
|
use App\Models\InstanceSettings;
|
2023-09-22 09:23:49 +00:00
|
|
|
use App\Models\LocalPersistentVolume;
|
2025-08-26 08:27:31 +00:00
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2024-09-04 20:33:47 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2024-09-23 17:51:31 +00:00
|
|
|
use Illuminate\Support\Facades\Hash;
|
2023-05-05 10:08:38 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Show extends Component
|
|
|
|
|
{
|
2025-08-26 08:27:31 +00:00
|
|
|
use AuthorizesRequests;
|
|
|
|
|
|
2023-09-22 09:23:49 +00:00
|
|
|
public LocalPersistentVolume $storage;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2025-08-26 08:27:31 +00:00
|
|
|
public $resource;
|
|
|
|
|
|
2023-09-22 09:23:49 +00:00
|
|
|
public bool $isReadOnly = false;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-10-03 06:48:07 +00:00
|
|
|
public bool $isFirst = true;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-27 13:11:00 +00:00
|
|
|
public bool $isService = false;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-05-27 13:11:00 +00:00
|
|
|
public ?string $startedAt = null;
|
2023-09-22 09:23:49 +00:00
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
protected $rules = [
|
|
|
|
|
'storage.name' => 'required|string',
|
|
|
|
|
'storage.mount_path' => 'required|string',
|
|
|
|
|
'storage.host_path' => 'string|nullable',
|
|
|
|
|
];
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-06-16 10:35:40 +00:00
|
|
|
protected $validationAttributes = [
|
|
|
|
|
'name' => 'name',
|
|
|
|
|
'mount_path' => 'mount',
|
|
|
|
|
'host_path' => 'host',
|
|
|
|
|
];
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2025-10-03 14:39:57 +00:00
|
|
|
public function mount()
|
|
|
|
|
{
|
|
|
|
|
$this->isReadOnly = $this->storage->isReadOnlyVolume();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
public function submit()
|
|
|
|
|
{
|
2025-08-26 08:27:31 +00:00
|
|
|
$this->authorize('update', $this->resource);
|
|
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
$this->validate();
|
|
|
|
|
$this->storage->save();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('success', 'Storage updated successfully');
|
2023-05-05 10:08:38 +00:00
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2024-09-04 20:33:47 +00:00
|
|
|
public function delete($password)
|
2023-05-05 10:08:38 +00:00
|
|
|
{
|
2025-08-26 08:27:31 +00:00
|
|
|
$this->authorize('update', $this->resource);
|
|
|
|
|
|
2024-10-24 14:20:01 +00:00
|
|
|
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) {
|
2024-10-22 10:29:48 +00:00
|
|
|
if (! Hash::check($password, Auth::user()->password)) {
|
|
|
|
|
$this->addError('password', 'The provided password is incorrect.');
|
2024-09-23 17:51:31 +00:00
|
|
|
|
2024-10-22 10:29:48 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2024-09-04 20:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
$this->storage->delete();
|
2024-08-05 18:00:57 +00:00
|
|
|
$this->dispatch('refreshStorages');
|
2023-05-05 10:08:38 +00:00
|
|
|
}
|
|
|
|
|
}
|