|
|
|
@ -314,7 +314,7 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
|
const createNewFile = (newFilePath: string) => { |
|
|
|
|
const fileManager = state.fileManager |
|
|
|
|
|
|
|
|
|
if (helper.checkSpecialChars(newFilePath) || helper.checkSlash(newFilePath)) return toast('special characters are not allowed') |
|
|
|
|
try { |
|
|
|
|
helper.createNonClashingName(newFilePath, filesProvider, async (error, newName) => { |
|
|
|
|
if (error) { |
|
|
|
|
modal('Create File Failed', error, { |
|
|
|
@ -334,6 +334,12 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} catch (error) { |
|
|
|
|
return modal('File Creation Failed', error.message, { |
|
|
|
|
label: 'Close', |
|
|
|
|
fn: async () => {} |
|
|
|
|
}, null) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const createNewFolder = async (newFolderPath: string) => { |
|
|
|
@ -354,8 +360,10 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
|
return { ...prevState, focusElement: [{ key: newFolderPath, type: 'folder' }] } |
|
|
|
|
}) |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log('error: ', e) |
|
|
|
|
toast('Failed to create folder: ' + newFolderPath) |
|
|
|
|
return modal('File Creation Failed', e.message, { |
|
|
|
|
label: 'Close', |
|
|
|
|
fn: async () => {} |
|
|
|
|
}, null) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -393,7 +401,6 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
|
fn: () => {} |
|
|
|
|
}, null) |
|
|
|
|
} else { |
|
|
|
|
if (helper.checkSpecialChars(newPath) || helper.checkSlash(newPath)) throw new Error('special characters are not allowed') |
|
|
|
|
await fileManager.rename(oldPath, newPath) |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|