Use standard folder input instead of showDirectoryPicker for uploads.
Deploy Ladill Transfer / deploy (push) Successful in 32s
Deploy Ladill Transfer / deploy (push) Successful in 32s
Avoids the broader browser file-access permission dialog; the custom Ladill confirm modal still runs after folder selection. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -660,52 +660,9 @@ Alpine.data('filesManager', (config = {}) => ({
|
|||||||
|
|
||||||
triggerFolderUpload() {
|
triggerFolderUpload() {
|
||||||
this.createMenuOpen = false;
|
this.createMenuOpen = false;
|
||||||
if (typeof window.showDirectoryPicker === 'function') {
|
|
||||||
this.pickFolderWithApi();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$refs.folderUploadInput?.click();
|
this.$refs.folderUploadInput?.click();
|
||||||
},
|
},
|
||||||
|
|
||||||
async pickFolderWithApi() {
|
|
||||||
try {
|
|
||||||
const handle = await window.showDirectoryPicker();
|
|
||||||
const files = await this.collectDirectoryFiles(handle);
|
|
||||||
if (files.length === 0) {
|
|
||||||
this.showToast('That folder is empty.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.openUploadConfirm(files, handle.name, true);
|
|
||||||
} catch (error) {
|
|
||||||
if (error?.name !== 'AbortError') {
|
|
||||||
this.showToast('Could not read that folder.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async collectDirectoryFiles(dirHandle, path = '') {
|
|
||||||
const files = [];
|
|
||||||
|
|
||||||
for await (const entry of dirHandle.values()) {
|
|
||||||
const entryPath = path ? `${path}/${entry.name}` : entry.name;
|
|
||||||
|
|
||||||
if (entry.kind === 'file') {
|
|
||||||
const file = await entry.getFile();
|
|
||||||
Object.defineProperty(file, 'webkitRelativePath', {
|
|
||||||
value: entryPath,
|
|
||||||
configurable: true,
|
|
||||||
});
|
|
||||||
files.push(file);
|
|
||||||
} else if (entry.kind === 'directory') {
|
|
||||||
files.push(...await this.collectDirectoryFiles(entry, entryPath));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return files;
|
|
||||||
},
|
|
||||||
|
|
||||||
openFolderModal() {
|
openFolderModal() {
|
||||||
this.createMenuOpen = false;
|
this.createMenuOpen = false;
|
||||||
this.folderModalOpen = true;
|
this.folderModalOpen = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user