diff --git a/apps/remix-ide-e2e/src/tests/file_explorer_multiselect.test.ts b/apps/remix-ide-e2e/src/tests/file_explorer_multiselect.test.ts index 65ff7c553e..8d1ce137d1 100644 --- a/apps/remix-ide-e2e/src/tests/file_explorer_multiselect.test.ts +++ b/apps/remix-ide-e2e/src/tests/file_explorer_multiselect.test.ts @@ -23,7 +23,7 @@ module.exports = { .assert.visible('.bg-secondary[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]') .assert.visible('.bg-secondary[data-id="treeViewLitreeViewItemtests"]') }, - 'Should select multiple items in file explorer to tests folder #group1': function (browser: NightwatchBrowser) { + 'Should drag and drop multiple files in file explorer to tests folder #group1': function (browser: NightwatchBrowser) { const selectedElements = [] browser .click({ selector: '//*[@data-id="treeViewLitreeViewItemcontracts/1_Storage.sol"]', locateStrategy: 'xpath' }) @@ -45,7 +45,7 @@ module.exports = { .waitForElementNotPresent('li[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]') }) }, - 'should select multiple files and folders in file explorer to contracts folder #group1': function (browser: NightwatchBrowser) { + 'should drag and drop multiple files and folders in file explorer to contracts folder #group1': function (browser: NightwatchBrowser) { const selectedElements = [] browser .click({ selector: '//*[@data-id="treeViewLitreeViewItemtests"]', locateStrategy: 'xpath' }) diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index 47599beca3..3d421830a1 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -347,7 +347,7 @@ export const FileExplorer = (props: FileExplorerProps) => { intl.formatMessage({ id: 'filePanel.cancel' }), () => reject() ) - }) + }) } const handleTreeClick = (event: SyntheticEvent) => { diff --git a/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx b/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx index d825bb99ad..75697137b2 100644 --- a/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx +++ b/libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx @@ -4,8 +4,6 @@ import { buildMultiSelectedItemProfiles, getEventTarget } from '../utils/getEven import { extractParentFromKey } from '@remix-ui/helper' import { FileSystemContext } from '../contexts' - - export const FlatTreeDrop = (props: FlatTreeDropProps) => { const { getFlatTreeItem, dragSource, handleClickFolder, expandPath } = props @@ -13,9 +11,6 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { const [timer, setTimer] = useState() // folder to open const [folderToOpen, setFolderToOpen] = useState() - const globalFEContext = useContext(FileSystemContext) - - const [selectedItems, setSelectedItems] = useState([]) const onDragOver = async (e: SyntheticEvent) => { e.preventDefault() @@ -66,23 +61,12 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { props.setFilesSelected(filePaths) if (dragDestination.isDirectory) { - if (dragSource.isDirectory) { - await props.warnMovingItems(filePaths, dragDestination.path) - await moveFoldersSilently(props.selectedItems, dragDestination.path) - } else { - await props.warnMovingItems(filePaths, dragDestination.path) - await moveFilesSilently(props.selectedItems, dragDestination.path) - } + await props.warnMovingItems(filePaths, dragDestination.path) + await moveItemsSilently(props.selectedItems, dragDestination.path) } else { const path = extractParentFromKey(dragDestination.path) || '/' - - if (dragSource.isDirectory) { - await props.warnMovingItems(filePaths, path) - await moveFoldersSilently(props.selectedItems, path) - } else { - await props.warnMovingItems(filePaths, path) - await moveFilesSilently(props.selectedItems, path) - } + await props.warnMovingItems(filePaths, path) + await moveItemsSilently(props.selectedItems, path) } } @@ -92,33 +76,18 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { * @param dragSource source FileExplorer item being dragged. * @returns Promise */ - const moveFilesSilently = async (items: DragStructure[], targetPath: string) => { + const moveItemsSilently = async (items: DragStructure[], targetPath: string) => { const promises = items.filter(item => item.path !== targetPath) .map(async (item) => { if (item.type === 'file') { await props.moveFileSilently(targetPath, item.path) - } - }) - await Promise.all(promises) - } - - /** - * Moves items silently without showing a confirmation dialog. - * @param items MultiSelected items built into a DragStructure profile - * @param dragSource source FileExplorer item being dragged. - * @returns Promise - */ - const moveFoldersSilently = async (items: DragStructure[], targetPath: string) => { - const promises = items.filter(item => item.path !== targetPath) - .map(async (item) => { - if (item.type === 'folder') { + } else if (item.type === 'folder') { await props.moveFolderSilently(targetPath, item.path) } }) await Promise.all(promises) } - return (
{ const virtuoso = useRef(null) const [selectedItems, setSelectedItems] = useState([]) - const labelClass = (file: FileType) => props.focusEdit.element === file.path ? 'bg-light'