mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
feat(docker): add a folder picker to both path fields
Both paths in the adoption form had to be typed. Each gets a Browse button using the same path-input-group markup Link Existing uses, so the two look and behave alike. What they can browse differs, and that is the point. The host workspace path reuses the existing host picker. The container workdir cannot: an adopted container has nothing mounted at a matching host path, so a host listing would be a different filesystem — and getting this field wrong is the source of the opaque OCI chdir error at launch, which makes it the field that most needs to be clickable. Adds a read-only POST /api/docker-cases/browse: one `ls` through docker exec, no writes, no lifecycle, path shell-escaped like every other value. `ls -Ap` marks directories with a trailing slash and keeps names with spaces intact. PathPicker takes an optional fetchListing source rather than being forked: the container variant only swaps where the rows come from, and reuses the rendering, navigation, Up and Choose/Select unchanged.
This commit is contained in:
@@ -2895,6 +2895,62 @@ Object.assign(CodemanApp.prototype, {
|
||||
});
|
||||
},
|
||||
|
||||
/** HOST workspace directory — the same picker Link Existing uses. */
|
||||
openDockerWorkspacePathPicker() {
|
||||
const pathInput = document.getElementById('dockerWorkspacePath');
|
||||
PathPicker.open({
|
||||
title: 'Select Host Workspace Folder',
|
||||
initialPath: pathInput.value.trim(),
|
||||
directoriesOnly: true,
|
||||
onSelect: (path) => {
|
||||
pathInput.value = path;
|
||||
const nameInput = document.getElementById('dockerCaseName');
|
||||
if (nameInput && !nameInput.value.trim()) {
|
||||
const folder = path.split('/').filter(Boolean).pop() || '';
|
||||
if (/^[a-zA-Z0-9_-]+$/.test(folder)) nameInput.value = folder;
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Container workdir. Browses INSIDE the container, because for an adopted
|
||||
* container nothing is mounted at a matching host path — the host picker would
|
||||
* be listing a different filesystem, and typing this field blind is exactly
|
||||
* what makes the launch fail with an OCI chdir error.
|
||||
*/
|
||||
openDockerWorkdirPicker() {
|
||||
const pathInput = document.getElementById('dockerAdoptWorkdir');
|
||||
const container = document.getElementById('dockerContainerName')?.value.trim();
|
||||
const hostId = document.getElementById('dockerHostId')?.value.trim() || 'local';
|
||||
if (!container) {
|
||||
this.showToast('Enter the container name first', 'error');
|
||||
return;
|
||||
}
|
||||
PathPicker.open({
|
||||
title: `Select Folder Inside ${container}`,
|
||||
initialPath: pathInput.value.trim() || '/',
|
||||
directoriesOnly: true,
|
||||
fetchListing: async (path) => {
|
||||
const data = await this._apiJson('/api/docker-cases/browse', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ hostId, container, path: path || '/' }),
|
||||
});
|
||||
if (!data) return { success: false, error: `Could not read ${container}. Is it running?` };
|
||||
if (data.error) return { success: false, error: data.error };
|
||||
// Shape it like the host endpoint: one root, so Up/Location behave.
|
||||
return {
|
||||
success: true,
|
||||
data: { ...data, root: '/', roots: [{ label: container, path: '/' }], truncated: false },
|
||||
};
|
||||
},
|
||||
onSelect: (path) => {
|
||||
pathInput.value = path;
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async linkRemoteCase() {
|
||||
const name = document.getElementById('remoteCaseName').value.trim();
|
||||
const remotePath = document.getElementById('remoteCasePath').value.trim();
|
||||
|
||||
Reference in New Issue
Block a user