pull/5370/head
yann300 7 months ago committed by Joseph Izang
parent 803ffb612e
commit 215d356972
  1. 4
      apps/remix-ide-e2e/src/tests/file_explorer_multiselect.test.ts
  2. 2
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  3. 43
      libs/remix-ui/workspace/src/lib/components/flat-tree-drop.tsx
  4. 1
      libs/remix-ui/workspace/src/lib/components/flat-tree.tsx

@ -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' })

@ -347,7 +347,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
intl.formatMessage({ id: 'filePanel.cancel' }),
() => reject()
)
})
})
}
const handleTreeClick = (event: SyntheticEvent) => {

@ -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<NodeJS.Timeout>()
// folder to open
const [folderToOpen, setFolderToOpen] = useState<string>()
const globalFEContext = useContext(FileSystemContext)
const [selectedItems, setSelectedItems] = useState<DragStructure[]>([])
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<void>
*/
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<void>
*/
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 (<div
onDrop={onDrop} onDragOver={onDragOver}
className="d-flex h-100"

@ -72,7 +72,6 @@ export const FlatTree = (props: FlatTreeProps) => {
const virtuoso = useRef<VirtuosoHandle>(null)
const [selectedItems, setSelectedItems] = useState<DragStructure[]>([])
const labelClass = (file: FileType) =>
props.focusEdit.element === file.path
? 'bg-light'

Loading…
Cancel
Save