From b0776057f9a7705100e8e9f406e56e50894096ae Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 29 Apr 2024 09:35:17 +0100 Subject: [PATCH] changes after review --- .../src/lib/components/file-explorer.tsx | 19 ++++++++++--------- .../src/lib/components/flat-tree-drop.tsx | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) 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 b3eaeddab1..f4aaa85e8e 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -304,13 +304,13 @@ export const FileExplorer = (props: FileExplorerProps) => { if (dest.length === 0 || sourcesrc.length === 0) return if (await moveFilesIsAllowed(sourcesrc, dest) === false) return - const src = sourcesrc.length === 1 ? sourcesrc[0] : sourcesrc.join('\n') try { props.dispatchMoveFiles(sourcesrc, dest) } catch (error) { props.modal( intl.formatMessage({ id: 'filePanel.movingFileFailed' }), - intl.formatMessage({ id: 'filePanel.movingFileFailedMsg' }, { src }), + intl.formatMessage({ id: 'filePanel.movingFileFailedMsg' }, { src: sourcesrc.join(' ') }), + intl.formatMessage({ id: 'filePanel.close' }), async () => { } ) @@ -328,13 +328,13 @@ export const FileExplorer = (props: FileExplorerProps) => { if (dest.length === 0 || sourcesrc.length === 0) return if (await moveFoldersIsAllowed(sourcesrc, dest) === false) return - const src = sourcesrc.length === 1 ? sourcesrc[0] : sourcesrc.join('\n') + // console.log('moveFolderSilently', { src, dest, sourcesrc }) try { props.dispatchMoveFolders(sourcesrc, dest) } catch (error) { props.modal( intl.formatMessage({ id: 'filePanel.movingFolderFailed' }), - intl.formatMessage({ id: 'filePanel.movingFolderFailedMsg' }, { src }), + intl.formatMessage({ id: 'filePanel.movingFolderFailedMsg' }, { src: sourcesrc.join(' ') }), intl.formatMessage({ id: 'filePanel.close' }), async () => { } ) @@ -343,9 +343,10 @@ export const FileExplorer = (props: FileExplorerProps) => { const handleFileMove = async (dest: string, sourcesrc: string[]) => { if (await moveFilesIsAllowed(sourcesrc, dest) === false) return - const files = filesSelected && filesSelected.length > 0 && filesSelected.join('\n') - console.log(files) - const src = files.length > 0 ? files : sourcesrc.length === 1 ? sourcesrc[0] : sourcesrc.join('\n') + console.log('What files have been selected?', filesSelected) + const files = filesSelected && filesSelected.length > 0 && filesSelected.join(' ') + const src = files.length > 0 ? files : sourcesrc.length === 1 ? sourcesrc[0] : sourcesrc.join(' ') + console.log('handleFileMove sourcesrc', {files, sourcesrc, dest, src }) try { props.modal( intl.formatMessage({ id: 'filePanel.moveFile' }), @@ -367,9 +368,9 @@ export const FileExplorer = (props: FileExplorerProps) => { const handleFolderMove = async (dest: string, sourcesrc: string[]) => { if (await moveFoldersIsAllowed(sourcesrc, dest) === false) return - const folders = filesSelected && filesSelected.length > 0 && filesSelected.join('\n') + const folders = filesSelected && filesSelected.length > 0 && filesSelected.join(' ') console.log(folders) - const src = folders.length > 0 ? folders : sourcesrc.length === 1 ? sourcesrc[0] : sourcesrc.join('\n') + const src = folders.length > 0 ? folders : sourcesrc.length === 1 ? sourcesrc[0] : sourcesrc.join(' ') try { props.modal( intl.formatMessage({ id: 'filePanel.moveFile' }), 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 652b1e43f8..2a5c29575b 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 @@ -53,12 +53,13 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { } const onDrop = async (event: SyntheticEvent) => { + event.stopPropagation() event.preventDefault() const target = await getEventTarget(event) const items = buildMultiSelectedItemProfiles(target) const filePaths = [] - // console.log('onDrop', { items, target, filePaths }) + let dragDestination: any if (!target || !target.path) { dragDestination = { @@ -68,8 +69,7 @@ export const FlatTreeDrop = (props: FlatTreeDropProps) => { } else { dragDestination = getFlatTreeItem(target.path) } - - filePaths.push(dragDestination.path) + items.forEach((item) => filePaths.push(item.path)) props.setFilesSelected(filePaths)