fix: do not allow service storage mount point modifications

This commit is contained in:
Andras Bacsai 2024-05-27 15:11:00 +02:00
parent 92828b22fa
commit ad5c1639e8
3 changed files with 19 additions and 8 deletions

View File

@ -12,6 +12,8 @@ class Show extends Component
public bool $isReadOnly = false;
public ?string $modalId = null;
public bool $isFirst = true;
public bool $isService = false;
public ?string $startedAt = null;
protected $rules = [
'storage.name' => 'required|string',

View File

@ -3,10 +3,11 @@
@foreach ($resource->persistentStorages as $storage)
@if ($resource->type() === 'service')
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
:isFirst="$loop->first" isReadOnly='true' />
:isFirst="$loop->first" isReadOnly='true' isService='true' />
@else
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
isReadOnly="{{ data_get($storage, 'is_readonly') }}" />
isReadOnly="{{ data_get($storage, 'is_readonly') }}"
startedAt="{{ data_get($resource, 'started_at') }}" />
@endif
@endforeach
</div>

View File

@ -4,23 +4,31 @@
@if ($isFirst)
<x-forms.input id="storage.name" label="Volume Name" required
helper="Warning: Changing the volume name after the initial start could cause problems. Only use it when you know what are you doing." />
<x-forms.input id="storage.host_path" helper="Directory on the host system." label="Source Path"
helper="Warning: Changing the source path after the initial start could cause problems. Only use it when you know what are you doing." />
<x-forms.input id="storage.mount_path" label="Destination Path" helper="Directory inside the container." required readonly />
@if ($isService || $startedAt)
<x-forms.input id="storage.host_path" readonly helper="Directory on the host system."
label="Source Path"
helper="Warning: Changing the source path after the initial start could cause problems. Only use it when you know what are you doing." />
@else
<x-forms.input id="storage.host_path" helper="Directory on the host system." label="Source Path"
helper="Warning: Changing the source path after the initial start could cause problems. Only use it when you know what are you doing." />
@endif
<x-forms.input id="storage.mount_path" label="Destination Path" helper="Directory inside the container."
required readonly />
<x-forms.button type="submit">
Update
</x-forms.button>
@else
<x-forms.input id="storage.name" required readonly
helper="Warning: Changing the volume name after the initial start could cause problems. Only use it when you know what are you doing." />
<x-forms.input id="storage.host_path" helper="Directory on the host system." readonly />
<x-forms.input id="storage.mount_path" helper="Directory inside the container." required readonly />
<x-forms.input id="storage.host_path" helper="Directory on the host system." readonly />
<x-forms.input id="storage.mount_path" helper="Directory inside the container." required readonly />
@endif
@else
@if ($isFirst)
<x-forms.input id="storage.name" label="Volume Name" required />
<x-forms.input id="storage.host_path" helper="Directory on the host system." label="Source Path" />
<x-forms.input id="storage.mount_path" label="Destination Path" helper="Directory inside the container." required />
<x-forms.input id="storage.mount_path" label="Destination Path" helper="Directory inside the container."
required />
@else
<x-forms.input id="storage.name" required />
<x-forms.input id="storage.host_path" helper="Directory on the host system." />