From 350d5a0ba77ad14c594d60f74229dde169ad07cc Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 25 Sep 2023 09:28:55 +0200 Subject: [PATCH 01/14] fixing drag drop issues --- .../src/app/tabs/locales/en/filePanel.json | 3 ++ .../drag-n-drop/src/lib/drag-n-drop.tsx | 23 +++++++++++++-- .../src/lib/components/file-explorer.tsx | 28 +++++++++++++++---- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json index cdc270f480..0554b0ffa7 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json @@ -73,6 +73,7 @@ "filePanel.features": "Features", "filePanel.upgradeability": "Upgradeability", "filePanel.ok": "OK", + "filePanel.yes": "Yes", "filePanel.cancel": "Cancel", "filePanel.createNewWorkspace": "create a new workspace", "filePanel.connectToLocalhost": "connect to localhost", @@ -115,6 +116,8 @@ "filePanel.validationErrorMsg": "Special characters are not allowed", "filePanel.reservedKeyword": "Reserved Keyword", "filePanel.reservedKeywordMsg": "File name contains Remix reserved keywords. \"{content}\"", + "filePanel.moveFile": "Moving files", + "filePanel.moveFileMsg1": "Are you sure you want to move {src} to {dest}?", "filePanel.movingFileFailed": "Moving File Failed", "filePanel.movingFileFailedMsg": "Unexpected error while moving file: {src}", "filePanel.movingFolderFailed": "Moving Folder Failed", diff --git a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx index 6d991d9663..ec68db4a7e 100644 --- a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx +++ b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx @@ -27,6 +27,11 @@ export const Draggable = (props: DraggableType) => { destination = props.file, context = useContext(MoveContext) + // delay timer + const [timer, setTimer] = useState() + // folder to open + const [folderToOpen, setFolderToOpen] = useState() + const handleDrop = (event: React.DragEvent) => { event.preventDefault() @@ -50,8 +55,15 @@ export const Draggable = (props: DraggableType) => { const handleDragover = (event: React.DragEvent) => { //Checks if the folder is opened event.preventDefault() - if (destination.isDirectory && !props.expandedPath.includes(destination.path)) { - props.handleClickFolder(destination.path, destination.type) + if (destination.isDirectory && !props.expandedPath.includes(destination.path) && folderToOpen !== destination.path && props.handleClickFolder) { + setFolderToOpen(destination.path) + timer && clearTimeout(timer) + setTimer( + setTimeout(() => { + props.handleClickFolder(destination.path, destination.type) + setFolderToOpen(null) + }, 500) + ) } } @@ -75,7 +87,12 @@ export const Draggable = (props: DraggableType) => { onDrop={(event) => { handleDrop(event) }} - onDragStart={() => { + onDragStart={(event) => { + if(destination && destination.path === '/'){ + event.preventDefault() + event.stopPropagation + }else + if (destination) { handleDrag() } 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 70ebf68898..8bbdfa1c08 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -9,7 +9,7 @@ import '../css/file-explorer.css' import {checkSpecialChars, extractNameFromKey, extractParentFromKey, joinPath} from '@remix-ui/helper' // eslint-disable-next-line @typescript-eslint/no-unused-vars import {FileRender} from './file-render' -import {Drag} from '@remix-ui/drag-n-drop' +import {Drag, Draggable} from '@remix-ui/drag-n-drop' import {ROOT_PATH} from '../utils/constants' export const FileExplorer = (props: FileExplorerProps) => { @@ -290,8 +290,15 @@ export const FileExplorer = (props: FileExplorerProps) => { } const handleFileMove = (dest: string, src: string) => { - try { - props.dispatchMoveFile(src, dest) + try{ + props.modal( + intl.formatMessage({id: 'filePanel.moveFile'}), + intl.formatMessage({id: 'filePanel.moveFileMsg1'}, {src, dest}), + intl.formatMessage({id: 'filePanel.yes'}), + () => props.dispatchMoveFile(src, dest), + intl.formatMessage({id: 'filePanel.cancel'}), + () => {} + ) } catch (error) { props.modal( intl.formatMessage({id: 'filePanel.movingFileFailed'}), @@ -300,11 +307,19 @@ export const FileExplorer = (props: FileExplorerProps) => { async () => {} ) } + } const handleFolderMove = (dest: string, src: string) => { try { - props.dispatchMoveFolder(src, dest) + props.modal( + intl.formatMessage({id: 'filePanel.moveFile'}), + intl.formatMessage({id: 'filePanel.moveFileMsg1'}, {src, dest}), + intl.formatMessage({id: 'filePanel.yes'}), + () => props.dispatchMoveFolder(src, dest), + intl.formatMessage({id: 'filePanel.cancel'}), + () => {} + ) } catch (error) { props.modal( intl.formatMessage({id: 'filePanel.movingFolderFailed'}), @@ -337,7 +352,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } expand={true} > -
+
{files[ROOT_PATH] && Object.keys(files[ROOT_PATH]).map((key, index) => ( @@ -362,6 +377,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
+ +
+
From ecf171fa8315976de719afba21ce59d43c5fbe23 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 25 Sep 2023 09:36:49 +0200 Subject: [PATCH 02/14] lint --- .../src/lib/components/file-explorer.tsx | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 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 8bbdfa1c08..2fa15a10a5 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -290,41 +290,40 @@ export const FileExplorer = (props: FileExplorerProps) => { } const handleFileMove = (dest: string, src: string) => { - try{ - props.modal( - intl.formatMessage({id: 'filePanel.moveFile'}), - intl.formatMessage({id: 'filePanel.moveFileMsg1'}, {src, dest}), - intl.formatMessage({id: 'filePanel.yes'}), - () => props.dispatchMoveFile(src, dest), - intl.formatMessage({id: 'filePanel.cancel'}), - () => {} - ) + try { + props.modal( + intl.formatMessage({ id: 'filePanel.moveFile' }), + intl.formatMessage({ id: 'filePanel.moveFileMsg1' }, { src, dest }), + intl.formatMessage({ id: 'filePanel.yes' }), + () => props.dispatchMoveFile(src, dest), + intl.formatMessage({ id: 'filePanel.cancel' }), + () => {} + ) } catch (error) { props.modal( - intl.formatMessage({id: 'filePanel.movingFileFailed'}), - intl.formatMessage({id: 'filePanel.movingFileFailedMsg'}, {src}), - intl.formatMessage({id: 'filePanel.close'}), + intl.formatMessage({ id: 'filePanel.movingFileFailed' }), + intl.formatMessage({ id: 'filePanel.movingFileFailedMsg' }, { src }), + intl.formatMessage({ id: 'filePanel.close' }), async () => {} ) } - } const handleFolderMove = (dest: string, src: string) => { try { props.modal( - intl.formatMessage({id: 'filePanel.moveFile'}), - intl.formatMessage({id: 'filePanel.moveFileMsg1'}, {src, dest}), - intl.formatMessage({id: 'filePanel.yes'}), + intl.formatMessage({ id: 'filePanel.moveFile' }), + intl.formatMessage({ id: 'filePanel.moveFileMsg1' }, { src, dest }), + intl.formatMessage({ id: 'filePanel.yes' }), () => props.dispatchMoveFolder(src, dest), - intl.formatMessage({id: 'filePanel.cancel'}), + intl.formatMessage({ id: 'filePanel.cancel' }), () => {} ) } catch (error) { props.modal( - intl.formatMessage({id: 'filePanel.movingFolderFailed'}), - intl.formatMessage({id: 'filePanel.movingFolderFailedMsg'}, {src}), - intl.formatMessage({id: 'filePanel.close'}), + intl.formatMessage({ id: 'filePanel.movingFolderFailed' }), + intl.formatMessage({ id: 'filePanel.movingFolderFailedMsg' }, { src }), + intl.formatMessage({ id: 'filePanel.close' }), async () => {} ) } From 3320e8b94c6b505bd2a00373be1dc64dfd5518f7 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 15:27:49 +0200 Subject: [PATCH 03/14] prevent unneeded modals --- apps/remix-ide/src/app/files/fileManager.ts | 44 +++++++++++++++++++ .../drag-n-drop/src/lib/drag-n-drop.tsx | 2 +- .../workspace/src/lib/actions/index.ts | 13 ++++++ .../src/lib/components/file-explorer.tsx | 12 +++-- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index e24680e91f..0a80758214 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -904,6 +904,50 @@ class FileManager extends Plugin { return exists } + + async moveFileIsAllowed (src: string, dest: string) { + try { + src = this.normalize(src) + dest = this.normalize(dest) + src = this.limitPluginScope(src) + dest = this.limitPluginScope(dest) + await this._handleExists(src, `Cannot move ${src}. Path does not exist.`) + await this._handleExists(dest, `Cannot move content into ${dest}. Path does not exist.`) + await this._handleIsFile(src, `Cannot move ${src}. Path is not a file.`) + await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) + const fileName = helper.extractNameFromKey(src) + + if (await this.exists(dest + '/' + fileName)) { + return false + } + return true + } catch (e) { + console.log(e) + return false + } + } + + async moveDirIsAllowed (src: string, dest: string) { + try { + src = this.normalize(src) + dest = this.normalize(dest) + src = this.limitPluginScope(src) + dest = this.limitPluginScope(dest) + await this._handleExists(src, `Cannot move ${src}. Path does not exist.`) + await this._handleExists(dest, `Cannot move content into ${dest}. Path does not exist.`) + await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) + await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) + const dirName = helper.extractNameFromKey(src) + if (await this.exists(dest + '/' + dirName) || src === dest) { + return false + } + return true + } catch (e) { + console.log(e) + return false + } + } + /** * Moves a file to a new folder * @param {string} src path of the source file diff --git a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx index ec68db4a7e..96259d6d41 100644 --- a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx +++ b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx @@ -62,7 +62,7 @@ export const Draggable = (props: DraggableType) => { setTimeout(() => { props.handleClickFolder(destination.path, destination.type) setFolderToOpen(null) - }, 500) + }, 600) ) } } diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index e34b9db417..9b8691319d 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -514,3 +514,16 @@ export const moveFolder = async (src: string, dest: string) => { dispatch(displayPopUp('Oops! An error ocurred while performing moveDir operation.' + error)) } } + +export const moveFileIsAllowed = async (src: string, dest: string) => { + const fileManager = plugin.fileManager + const isAllowed = await fileManager.moveFileIsAllowed(src, dest) + return isAllowed +} + +export const moveFolderIsAllowed = async (src: string, dest: string) => { + const fileManager = plugin.fileManager + const isAllowed = await fileManager.moveDirIsAllowed(src, dest) + return isAllowed +} + 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 13f9c34120..eb2f773e3a 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -11,6 +11,7 @@ import {checkSpecialChars, extractNameFromKey, extractParentFromKey, joinPath} f import {FileRender} from './file-render' import {Drag, Draggable} from '@remix-ui/drag-n-drop' import {ROOT_PATH} from '../utils/constants' +import { moveFileIsAllowed, moveFolderIsAllowed } from '../actions' export const FileExplorer = (props: FileExplorerProps) => { const intl = useIntl() @@ -289,7 +290,8 @@ export const FileExplorer = (props: FileExplorerProps) => { props.dispatchHandleExpandPath(expandPath) } - const handleFileMove = (dest: string, src: string) => { + const handleFileMove = async (dest: string, src: string) => { + if(await moveFileIsAllowed(src, dest) === false) return try { props.modal( intl.formatMessage({ id: 'filePanel.moveFile' }), @@ -309,7 +311,8 @@ export const FileExplorer = (props: FileExplorerProps) => { } } - const handleFolderMove = (dest: string, src: string) => { + const handleFolderMove = async (dest: string, src: string) => { + if(await moveFolderIsAllowed(src, dest) === false) return try { props.modal( intl.formatMessage({ id: 'filePanel.moveFile' }), @@ -354,7 +357,7 @@ export const FileExplorer = (props: FileExplorerProps) => { -
+
{files[ROOT_PATH] && Object.keys(files[ROOT_PATH]).map((key, index) => ( @@ -378,6 +381,9 @@ export const FileExplorer = (props: FileExplorerProps) => { ))}
+ +
+
From 800d2fe4973561f491f3dfc9c1c828c6abd40250 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 27 Sep 2023 20:24:02 +0530 Subject: [PATCH 04/14] bump dev version to 0.36.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48bff5484a..459fa39cbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remix-project", - "version": "0.36.0-dev", + "version": "0.36.1-dev", "license": "MIT", "description": "Ethereum Remix Monorepo", "keywords": [ From 9a5f725059c190ef9f1d60e056a504904fd5ac0f Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 27 Sep 2023 17:25:01 +0200 Subject: [PATCH 05/14] Update drag-n-drop.tsx --- libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx index 96259d6d41..6427dbed12 100644 --- a/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx +++ b/libs/remix-ui/drag-n-drop/src/lib/drag-n-drop.tsx @@ -88,10 +88,10 @@ export const Draggable = (props: DraggableType) => { handleDrop(event) }} onDragStart={(event) => { - if(destination && destination.path === '/'){ + if (destination && destination.path === '/'){ event.preventDefault() event.stopPropagation - }else + } else if (destination) { handleDrag() From 0b34d248b9f12afc1d84716aeab217b0d72dac15 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 13:39:34 +0200 Subject: [PATCH 06/14] alphabetic file folder sorting --- .../src/lib/components/file-explorer.tsx | 16 +++++++++++++-- .../src/lib/components/file-render.tsx | 19 +++++++++++++++--- .../remix-ui/workspace/src/lib/utils/index.ts | 20 ++++++++++++++++++- 3 files changed, 49 insertions(+), 6 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 a3b94e22c1..42cd18619d 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -3,7 +3,7 @@ import {useIntl} from 'react-intl' import {TreeView, TreeViewItem} from '@remix-ui/tree-view' // eslint-disable-line import {FileExplorerMenu} from './file-explorer-menu' // eslint-disable-line import {FileExplorerContextMenu} from './file-explorer-context-menu' // eslint-disable-line -import {FileExplorerProps, WorkSpaceState} from '../types' +import {FileExplorerProps, FileType, WorkSpaceState} from '../types' import '../css/file-explorer.css' import {checkSpecialChars, extractNameFromKey, extractParentFromKey, joinPath} from '@remix-ui/helper' @@ -11,6 +11,7 @@ import {checkSpecialChars, extractNameFromKey, extractParentFromKey, joinPath} f import {FileRender} from './file-render' import {Drag} from '@remix-ui/drag-n-drop' import {ROOT_PATH} from '../utils/constants' +import { fileKeySort } from '../utils' export const FileExplorer = (props: FileExplorerProps) => { const intl = useIntl() @@ -32,6 +33,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } = props const [state, setState] = useState(workspaceState) const treeRef = useRef(null) + const [childrenKeys, setChildrenKeys] = useState([]) useEffect(() => { if (contextMenuItems) { @@ -315,6 +317,16 @@ export const FileExplorer = (props: FileExplorerProps) => { } } + useEffect(() => { + if(files[ROOT_PATH]){ + const children: FileType[] = files[ROOT_PATH] as any + setChildrenKeys(fileKeySort(children)) + } else{ + setChildrenKeys([]) + } + }, [props]) + + return (
@@ -343,7 +355,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
{files[ROOT_PATH] && - Object.keys(files[ROOT_PATH]).map((key, index) => ( + childrenKeys.map((key, index) => ( { const [file, setFile] = useState({} as FileType) const [hover, setHover] = useState(false) const [icon, setIcon] = useState('') + const [childrenKeys, setChildrenKeys] = useState([]) useEffect(() => { if (props.file && props.file.path && props.file.type) { @@ -38,6 +40,17 @@ export const FileRender = (props: RenderFileProps) => { } }, [props.file]) + useEffect(() => { + + if(file.child){ + const children: FileType[] = file.child as any + setChildrenKeys(fileKeySort(children)) + } else { + setChildrenKeys([]) + } + + }, [file.child, props.expandPath, props.file]) + const labelClass = props.focusEdit.element === file.path ? 'bg-light' @@ -85,8 +98,8 @@ export const FileRender = (props: RenderFileProps) => { return ( @@ -108,7 +121,7 @@ export const FileRender = (props: RenderFileProps) => { > {file.child ? ( - {Object.keys(file.child).map((key, index) => ( + {childrenKeys.map((key, index) => ( { + const directories = Object.keys(children).filter((key: string) => children[key].isDirectory && children[key].name !== '') + + // sort case insensitive + directories.sort((a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase())) + + const fileKeys = Object.keys(children).filter((key: string) => !children[key].isDirectory && children[key].name !== '') + // sort case insensitive + fileKeys.sort((a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase())) + + // find the children with a blank name + const blankChildren = Object.keys(children).filter((key: string) => children[key].name === '') + + const keys = [...directories, ...fileKeys, ...blankChildren] + return keys +} \ No newline at end of file From a739065c2b56362fecc6006e2fb2aa5166416252 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 13:42:16 +0200 Subject: [PATCH 07/14] revert --- libs/remix-ui/workspace/src/lib/components/file-render.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/components/file-render.tsx b/libs/remix-ui/workspace/src/lib/components/file-render.tsx index 4d69cd9311..3690d3b359 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-render.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-render.tsx @@ -98,8 +98,8 @@ export const FileRender = (props: RenderFileProps) => { return ( From 7f8667ef20b615f027498b154c695b9a584628c6 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 14:44:18 +0200 Subject: [PATCH 08/14] fix remixd sorting --- .../workspace/src/lib/components/file-explorer.tsx | 9 +++++++-- .../workspace/src/lib/components/file-render.tsx | 12 +++++++----- 2 files changed, 14 insertions(+), 7 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 42cd18619d..7f84851951 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -319,8 +319,13 @@ export const FileExplorer = (props: FileExplorerProps) => { useEffect(() => { if(files[ROOT_PATH]){ - const children: FileType[] = files[ROOT_PATH] as any - setChildrenKeys(fileKeySort(children)) + + try { + const children: FileType[] = files[ROOT_PATH] as any + setChildrenKeys(fileKeySort(children)) + } catch (error) { + setChildrenKeys(Object.keys(files[ROOT_PATH])) + } } else{ setChildrenKeys([]) } diff --git a/libs/remix-ui/workspace/src/lib/components/file-render.tsx b/libs/remix-ui/workspace/src/lib/components/file-render.tsx index 3690d3b359..a23ed76df3 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-render.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-render.tsx @@ -41,14 +41,16 @@ export const FileRender = (props: RenderFileProps) => { }, [props.file]) useEffect(() => { - - if(file.child){ - const children: FileType[] = file.child as any - setChildrenKeys(fileKeySort(children)) + if (file.child) { + try { + const children: FileType[] = file.child as any + setChildrenKeys(fileKeySort(children)) + } catch (e) { + setChildrenKeys(Object.keys(file.child)) + } } else { setChildrenKeys([]) } - }, [file.child, props.expandPath, props.file]) const labelClass = From 65cad499a7c74ea6621a1eaa7993e2f15c54a22b Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 27 Sep 2023 17:26:13 +0200 Subject: [PATCH 09/14] Update file-explorer.tsx --- libs/remix-ui/workspace/src/lib/components/file-explorer.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 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 7f84851951..49064fea9d 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -318,8 +318,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } useEffect(() => { - if(files[ROOT_PATH]){ - + if (files[ROOT_PATH]){ try { const children: FileType[] = files[ROOT_PATH] as any setChildrenKeys(fileKeySort(children)) From 4cbf5bac6c344b1be80d51e8151bcb9c1f63d73a Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 27 Sep 2023 17:41:10 +0200 Subject: [PATCH 10/14] fe style improvements --- .../components/file-explorer-context-menu.tsx | 2 +- .../src/lib/components/file-explorer-menu.tsx | 25 ++++++++++++------- .../src/lib/components/file-explorer.tsx | 8 +++--- .../workspace/src/lib/css/file-explorer.css | 4 +-- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx index 998d432f16..a11b5ccf41 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx @@ -111,7 +111,7 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) => return groupedActions.map((groupItem, groupIndex) => groupItem.map((item, index) => { key++ - const className = `remixui_liitem ${group !== item.group ? 'border-top' : ''}` + const className = `px-3 remixui_liitem ${group !== item.group ? 'border-top' : ''}` group = item.group if (item.name === 'Upload File') { return ( diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx index 7dcc5cdf16..89d777f6fd 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx @@ -67,12 +67,7 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { return ( <> - - - {props.title} - - - + {state.menuItems.map(({action, title, icon, placement}, index) => { if (action === 'uploadFile') { return ( @@ -83,7 +78,13 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { tooltipText={} key={`index-${action}-${placement}-${icon}`} > - diff --git a/libs/remix-ui/workspace/src/lib/css/file-explorer.css b/libs/remix-ui/workspace/src/lib/css/file-explorer.css index 6f6f23a1e7..b67c5f24c7 100644 --- a/libs/remix-ui/workspace/src/lib/css/file-explorer.css +++ b/libs/remix-ui/workspace/src/lib/css/file-explorer.css @@ -23,10 +23,10 @@ input[type="file"] { .remixui_file { padding : 4px; } -.remixui_newFile i { +.remixui_menuItem i { cursor : pointer; } -.remixui_newFile:hover { +.remixui_menuItem:hover { transform : scale(1.3); } .remixui_menu { From 17d2347183e29646682ed73a8912f0394c2e4e45 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 19:25:34 +0200 Subject: [PATCH 11/14] fix dragging folder into ancestor --- apps/remix-ide/src/app/files/fileManager.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 0a80758214..00ecb3b4e0 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -938,9 +938,16 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) const dirName = helper.extractNameFromKey(src) + const provider = this.fileProviderOf(src) + if (await this.exists(dest + '/' + dirName) || src === dest) { return false } + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } return true } catch (e) { console.log(e) @@ -998,7 +1005,13 @@ class FileManager extends Plugin { if (await this.exists(dest + '/' + dirName) || src === dest) { throw createError({ code: 'EEXIST', message: `Cannot move ${src}. Folder already exists at destination ${dest}` }) } - await this.copyDir(src, dest, dirName) + const provider = this.fileProviderOf(src) + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } + await this.inDepthCopy(src, dest, dirName) await this.remove(src) } catch (e) { From 1d5d8329241f6e37ef2e39fc430872f7520a796c Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 19:26:25 +0200 Subject: [PATCH 12/14] Revert "fix dragging folder into ancestor" This reverts commit 17d2347183e29646682ed73a8912f0394c2e4e45. --- apps/remix-ide/src/app/files/fileManager.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 00ecb3b4e0..0a80758214 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -938,16 +938,9 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) const dirName = helper.extractNameFromKey(src) - const provider = this.fileProviderOf(src) - if (await this.exists(dest + '/' + dirName) || src === dest) { return false } - - if (provider.isSubDirectory(src, dest)) { - this.call('notification', 'toast', recursivePasteToastMsg()) - return false - } return true } catch (e) { console.log(e) @@ -1005,13 +998,7 @@ class FileManager extends Plugin { if (await this.exists(dest + '/' + dirName) || src === dest) { throw createError({ code: 'EEXIST', message: `Cannot move ${src}. Folder already exists at destination ${dest}` }) } - const provider = this.fileProviderOf(src) - - if (provider.isSubDirectory(src, dest)) { - this.call('notification', 'toast', recursivePasteToastMsg()) - return false - } - await this.inDepthCopy(src, dest, dirName) + await this.copyDir(src, dest, dirName) await this.remove(src) } catch (e) { From cc7beaca310df4514a283478fa571d15a624d41e Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 19:27:19 +0200 Subject: [PATCH 13/14] fix dragging into ancestor --- apps/remix-ide/src/app/files/fileManager.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 0a80758214..00ecb3b4e0 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -938,9 +938,16 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) const dirName = helper.extractNameFromKey(src) + const provider = this.fileProviderOf(src) + if (await this.exists(dest + '/' + dirName) || src === dest) { return false } + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } return true } catch (e) { console.log(e) @@ -998,7 +1005,13 @@ class FileManager extends Plugin { if (await this.exists(dest + '/' + dirName) || src === dest) { throw createError({ code: 'EEXIST', message: `Cannot move ${src}. Folder already exists at destination ${dest}` }) } - await this.copyDir(src, dest, dirName) + const provider = this.fileProviderOf(src) + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } + await this.inDepthCopy(src, dest, dirName) await this.remove(src) } catch (e) { From 98b35f45f1873a410b5f7bcf6a7af578d1ce0921 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 28 Sep 2023 20:19:16 +0530 Subject: [PATCH 14/14] bump dev version to 0.37.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 459fa39cbd..9c221c3688 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remix-project", - "version": "0.36.1-dev", + "version": "0.37.0-dev", "license": "MIT", "description": "Ethereum Remix Monorepo", "keywords": [