Remove source path from volume creation, show only when set

- Remove host_path input from volume creation modal (users should use
  Directory Mount for bind mounts instead)
- Conditionally display Source Path field only when host_path has a value
- Add "Remove" button with confirmation modal to clear existing source paths
- Add clearHostPath() method to handle source path removal

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai 2025-12-11 21:42:15 +01:00
parent 083d745d70
commit 593e0dbb5d
3 changed files with 35 additions and 31 deletions

View file

@ -88,4 +88,13 @@ class Show extends Component
$this->storage->delete();
$this->dispatch('refreshStorages');
}
public function clearHostPath()
{
$this->authorize('update', $this->resource);
$this->hostPath = null;
$this->storage->host_path = null;
$this->storage->save();
$this->dispatch('success', 'Source path removed. Use Directory Mount for host directory bindings.');
}
}

View file

@ -118,25 +118,9 @@
<div class="flex flex-col">
<div>Docker Volumes mounted to the container.</div>
</div>
@if ($isSwarm)
<div class="text-warning">Swarm Mode detected: You need to set a shared
volume
(EFS/NFS/etc) on all the worker nodes if you would like to use a
persistent
volumes.</div>
@endif
<div class="flex flex-col gap-2">
<x-forms.input canGate="update" :canResource="$resource" placeholder="pv-name"
id="name" label="Name" required helper="Volume name." />
@if ($isSwarm)
<x-forms.input canGate="update" :canResource="$resource"
placeholder="/root" id="host_path" label="Source Path" required
helper="Directory on the host system." />
@else
<x-forms.input canGate="update" :canResource="$resource"
placeholder="/root" id="host_path" label="Source Path"
helper="Directory on the host system." />
@endif
<x-forms.input canGate="update" :canResource="$resource"
placeholder="/tmp/root" id="mount_path" label="Destination Path"
required helper="Directory inside the container." />

View file

@ -17,24 +17,20 @@
<x-forms.input id="name" label="Volume 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." />
@endif
@if ($isService || $startedAt)
@if ($hostPath)
<x-forms.input id="hostPath" 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." />
<x-forms.input id="mountPath" label="Destination Path"
helper="Directory inside the container." required readonly />
@else
<x-forms.input id="hostPath" 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." />
<x-forms.input id="mountPath" label="Destination Path"
helper="Directory inside the container." required readonly />
@endif
<x-forms.input id="mountPath" label="Destination Path"
helper="Directory inside the container." required readonly />
</div>
@else
<div class="flex gap-2 items-end w-full">
<x-forms.input id="name" required readonly />
<x-forms.input id="hostPath" readonly />
@if ($hostPath)
<x-forms.input id="hostPath" readonly />
@endif
<x-forms.input id="mountPath" required readonly />
</div>
@endif
@ -43,14 +39,18 @@
@if ($isFirst)
<div class="flex gap-2 items-end w-full">
<x-forms.input id="name" label="Volume Name" required />
<x-forms.input id="hostPath" helper="Directory on the host system." label="Source Path" />
@if ($hostPath)
<x-forms.input id="hostPath" helper="Directory on the host system." label="Source Path" />
@endif
<x-forms.input id="mountPath" label="Destination Path"
helper="Directory inside the container." required />
</div>
@else
<div class="flex gap-2 items-end w-full">
<x-forms.input id="name" required />
<x-forms.input id="hostPath" />
@if ($hostPath)
<x-forms.input id="hostPath" />
@endif
<x-forms.input id="mountPath" required />
</div>
@endif
@ -58,6 +58,13 @@
<x-forms.button type="submit">
Update
</x-forms.button>
@if ($hostPath)
<x-modal-confirmation title="Remove Source Path?" isErrorButton buttonTitle="Remove"
submitAction="clearHostPath" :actions="[
'Are you sure you want to remove the source path?',
'If you need to mount a host directory, use Directory Mount instead of Volume Mount.',
]" />
@endif
<x-modal-confirmation title="Confirm persistent storage deletion?" isErrorButton buttonTitle="Delete"
submitAction="delete" :actions="[
'The selected persistent storage/volume will be permanently deleted.',
@ -70,15 +77,19 @@
@if ($isFirst)
<div class="flex gap-2 items-end w-full">
<x-forms.input id="name" label="Volume Name" required disabled />
<x-forms.input id="hostPath" helper="Directory on the host system." label="Source Path"
disabled />
@if ($hostPath)
<x-forms.input id="hostPath" helper="Directory on the host system." label="Source Path"
disabled />
@endif
<x-forms.input id="mountPath" label="Destination Path"
helper="Directory inside the container." required disabled />
</div>
@else
<div class="flex gap-2 items-end w-full">
<x-forms.input id="name" required disabled />
<x-forms.input id="hostPath" disabled />
@if ($hostPath)
<x-forms.input id="hostPath" disabled />
@endif
<x-forms.input id="mountPath" required disabled />
</div>
@endif