add functions for silent moving of files

pull/5370/head
Joseph Izang 7 months ago
parent cc46dfab89
commit aa8f136e3c
  1. 46
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx

@ -292,6 +292,50 @@ export const FileExplorer = (props: FileExplorerProps) => {
props.dispatchHandleExpandPath(expandPath) props.dispatchHandleExpandPath(expandPath)
} }
/**
* This offers the ability to move a file to a new location
* without showing a modal dialong to the user.
* @param dest path of the destination
* @param src path of the source
* @returns {void}
*/
const moveFileSilently = async (dest: string, src: string) => {
if (dest.length === 0 || src.length === 0) return
if (await moveFileIsAllowed(src, dest) === false) return
try {
props.dispatchMoveFile(src, dest)
} catch (error) {
props.modal(
intl.formatMessage({ id: 'filePanel.movingFileFailed' }),
intl.formatMessage({ id: 'filePanel.movingFileFailedMsg' }, { src }),
intl.formatMessage({ id: 'filePanel.close' }),
async () => { }
)
}
}
/**
* This offers the ability to move a folder to a new location
* without showing a modal dialong to the user.
* @param dest path of the destination
* @param src path of the source
* @returns {void}
*/
const moveFolderSilently = async (dest: string, src: string) => {
if (dest.length === 0 || src.length === 0) return
if (await moveFolderIsAllowed(src, dest) === false) return
try {
props.dispatchMoveFolder(src, dest)
} catch (error) {
props.modal(
intl.formatMessage({ id: 'filePanel.movingFolderFailed' }),
intl.formatMessage({ id: 'filePanel.movingFolderFailedMsg' }, { src }),
intl.formatMessage({ id: 'filePanel.close' }),
async () => { }
)
}
}
const handleFileMove = async (dest: string, src: string) => { const handleFileMove = async (dest: string, src: string) => {
if (await moveFileIsAllowed(src, dest) === false) return if (await moveFileIsAllowed(src, dest) === false) return
try { try {
@ -403,6 +447,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
handleContextMenu={handleContextMenu} handleContextMenu={handleContextMenu}
moveFile={handleFileMove} moveFile={handleFileMove}
moveFolder={handleFolderMove} moveFolder={handleFolderMove}
moveFolderSilently={moveFolderSilently}
moveFileSilently={moveFileSilently}
handleClickFolder={handleClickFolder} handleClickFolder={handleClickFolder}
createNewFile={props.createNewFile} createNewFile={props.createNewFile}
createNewFolder={props.createNewFolder} createNewFolder={props.createNewFolder}

Loading…
Cancel
Save