u
This commit is contained in:
@@ -67,6 +67,7 @@ const initialState = {
|
||||
searchQuery: '',
|
||||
vfsWidth: 480,
|
||||
newFileDialogOpen: false,
|
||||
newFileDefaultFolder: '',
|
||||
};
|
||||
|
||||
let vfsAutomat;
|
||||
@@ -105,8 +106,8 @@ const actions = {
|
||||
vfsAutomat.setState({ searchQuery });
|
||||
},
|
||||
|
||||
setNewFileDialogOpen(newFileDialogOpen) {
|
||||
vfsAutomat.setState({ newFileDialogOpen });
|
||||
setNewFileDialogOpen(newFileDialogOpen, newFileDefaultFolder = '') {
|
||||
vfsAutomat.setState({ newFileDialogOpen, newFileDefaultFolder });
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -283,6 +284,54 @@ const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete a file or directory from VFS.
|
||||
* @param {string} path
|
||||
*/
|
||||
async deletePath(path) {
|
||||
return actions.deleteFile(path);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new directory in VFS.
|
||||
* @param {string} path
|
||||
*/
|
||||
async mkdir(path) {
|
||||
const clean = String(path || '').trim().replace(/^[/\\]+/, '');
|
||||
if (!clean) throw new Error('Pfad darf nicht leer sein');
|
||||
try {
|
||||
const res = await vfsApi.mkdir(clean);
|
||||
await actions.loadFiles(true);
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.error('[vfsAutomat] mkdir failed:', err);
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Rename or move a file or directory in VFS.
|
||||
* @param {string} oldPath
|
||||
* @param {string} newPath
|
||||
*/
|
||||
async renameFile(oldPath, newPath) {
|
||||
const cleanOld = String(oldPath || '').trim().replace(/^[/\\]+/, '');
|
||||
const cleanNew = String(newPath || '').trim().replace(/^[/\\]+/, '');
|
||||
if (!cleanOld || !cleanNew) throw new Error('Alter und neuer Pfad dürfen nicht leer sein');
|
||||
try {
|
||||
const res = await vfsApi.rename(cleanOld, cleanNew);
|
||||
const isCurrentSelected = vfsAutomat.state.selectedFileName === cleanOld;
|
||||
await actions.loadFiles(true);
|
||||
if (isCurrentSelected) {
|
||||
await actions.selectFile(cleanNew);
|
||||
}
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.error('[vfsAutomat] renameFile failed:', err);
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Upload one or more files to VFS.
|
||||
* @param {File[]|FileList|File} files
|
||||
|
||||
Reference in New Issue
Block a user