flattentree
filip mertens 11 months ago
parent fc0f963412
commit f00008ac41
  1. 4
      apps/remix-ide/src/app/files/electronProvider.ts
  2. 1
      apps/remix-ide/src/app/panels/file-panel.js
  3. 2
      apps/remix-ide/src/app/plugins/electron/fsPlugin.ts
  4. 5
      apps/remixdesktop/src/plugins/fsPlugin.ts
  5. 1
      libs/remix-ui/workspace/src/lib/actions/events.ts
  6. 11
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  7. 11
      libs/remix-ui/workspace/src/lib/components/flat-tree.tsx
  8. 19
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts
  9. 13
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  10. 1
      libs/remix-ui/workspace/src/lib/utils/index.ts

@ -20,9 +20,7 @@ export class ElectronProvider extends FileProvider {
this.handleEvent(event, path)
})
this._appManager.on('fs', 'eventGroup', async (data) => {
console.log('eventGroup', data)
for (const event of data) {
console.log('event', event)
this.handleEvent(event.payload[0], event.payload[1])
}
})
@ -56,7 +54,6 @@ export class ElectronProvider extends FileProvider {
// isDirectory is already included
// this is a more efficient version of the default implementation
async resolveDirectory(path, cb) {
console.log('resolveDirectory', path)
path = this.removePrefix(path)
if (path.indexOf('/') !== 0) path = '/' + path
try {
@ -71,7 +68,6 @@ export class ElectronProvider extends FileProvider {
// ^ ret does not accept path starting with '/'
}
}
console.log('resolveDirectory done')
if (cb) cb(null, ret)
return ret
} catch (error) {

@ -91,7 +91,6 @@ module.exports = class Filepanel extends ViewPlugin {
)
}
updateComponent(state) {
console.log('updateComponent', state)
return (
<FileSystemProvider plugin={state.plugin} />
)

@ -47,7 +47,6 @@ export class fsPlugin extends ElectronPlugin {
return await this.call('fs', 'rmdir', path)
},
readdir: async (path: string) => {
console.log('readdir', path)
path = fixPath(path)
const files = await this.call('fs', 'readdir', path)
return files
@ -61,7 +60,6 @@ export class fsPlugin extends ElectronPlugin {
return await this.call('fs', 'mkdir', path)
},
readFile: async (path: string, options) => {
console.log('readFile', path)
try {
path = fixPath(path)
const file = await this.call('fs', 'readFile', path, options)

@ -45,7 +45,7 @@ export class FSPlugin extends ElectronBasePlugin {
try {
const stat = await fs.stat(folder)
if (stat.isDirectory()) {
createWindow(folder)
// do nothing
}
} catch (e) {
console.log('error opening folder', folder, e)
@ -56,9 +56,8 @@ export class FSPlugin extends ElectronBasePlugin {
const newFolders = openedFolders.filter((f: string) => !foldersToDelete.includes(f))
this.call('electronconfig', 'writeConfig', {recentFolders: newFolders})
}
} else {
createWindow()
}
createWindow()
}
async removeCloseListener(): Promise<void> {

@ -192,7 +192,6 @@ const fileAdded = async (filePath: string) => {
const folderAdded = async (folderPath: string) => {
const provider = plugin.fileManager.currentFileProvider()
const path = extractParentFromKey(folderPath) || ROOT_PATH
console.log('folderAdded', path)
if (isElectron()) {
const isExpanded = await plugin.call('filePanel', 'isExpanded', path)
if (!isExpanded) return

@ -153,7 +153,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
const handleClickFile = (path: string, type: WorkspaceElement) => {
console.log('handleClickFile', path, type)
if (!state.ctrlKey) {
props.dispatchHandleClickFile(path, type)
} else {
@ -195,7 +194,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
} else {
expandPath = [...new Set(props.expandPath.filter((key) => key && typeof key === 'string' && !key.startsWith(path)))]
}
console.log('handleClickFolder', path, type)
props.dispatchSetFocusElement([{ key: path, type }])
props.dispatchHandleExpandPath(expandPath)
}
@ -335,16 +333,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
)
}
}
useEffect(() => {
console.log('fe files changed', ROOT_PATH, files, flatTree)
}, [flatTree, files])
useEffect(() => {
console.log('FE RENDER', ROOT_PATH)
}, [])
const handleTreeClick = (event: SyntheticEvent) => {
let target = event.target as HTMLElement
while (target && target.getAttribute && !target.getAttribute('data-path')) {

@ -70,7 +70,6 @@ export const FlatTree = (props: FlatTreeProps) => {
const isOnScreen = useOnScreen(props.treeRef)
useEffect(() => {
console.log('is on screen', isOnScreen)
if(isOnScreen) {
setViewPortHeight()
}
@ -88,10 +87,6 @@ export const FlatTree = (props: FlatTreeProps) => {
? 'bg-light border-no-shift'
: ''
useEffect(() => {
console.log('PROP flat tree changed', props.flatTree)
}, [props.flatTree])
useEffect(() => {
}, [expandPath, focusEdit, focusElement])
@ -117,13 +112,11 @@ export const FlatTree = (props: FlatTreeProps) => {
const onDragStart = async (event: SyntheticEvent) => {
const target = await getEventTarget(event)
console.log(flatTree[target.path], target.path)
setDragSource(flatTree[target.path])
setIsDragging(true)
}
useEffect(() => {
console.log('drag source', dragSource)
if (isDragging) {
mouseTimer = {
path: null,
@ -134,11 +127,9 @@ export const FlatTree = (props: FlatTreeProps) => {
const onDragEnd = (event: SyntheticEvent) => {
setIsDragging(false)
console.log('drag end', event)
}
const getFlatTreeItem = (path: string) => {
console.log('get flat tree item', path, flatTree[path])
return flatTree[path]
}
@ -153,11 +144,9 @@ export const FlatTree = (props: FlatTreeProps) => {
}
const onMouseMove = async (e: any) => {
///console.log('mouse move', e)
const target = await getEventTarget(e, true)
if (target && target.path) {
if (mouseTimer.path !== target.path) {
//console.log('set timer', target)
setShowMouseOverTarget(false)
mouseTimer = {
path: target.path,

@ -127,7 +127,6 @@ export const browserInitialState: BrowserState = {
}
export const browserReducer = (state = browserInitialState, action: Actions) => {
console.log('browserReducer', action)
switch (action.type) {
case 'SET_CURRENT_WORKSPACE': {
const payload = action.payload
@ -188,13 +187,8 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
case 'FETCH_DIRECTORY_SUCCESS': {
const payload = action.payload
console.log('FETCH_DIRECTORY_SUCCESS', payload)
const startTime = new Date().getTime()
const fd = fetchDirectoryContent(state, payload)
const flatTree = flattenTree(fd, state.mode === 'browser'? state.browser.expandPath : state.localhost.expandPath)
const endTime = new Date().getTime()
console.log('fetchDirectoryContent tree', endTime - startTime, fd, flatTree)
return {
...state,
@ -261,14 +255,8 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
case 'FETCH_WORKSPACE_DIRECTORY_SUCCESS': {
const payload = action.payload
if(state.mode === 'browser'){
console.log('FETCH_WORKSPACE_DIRECTORY_SUCCESS', payload)
}
const startTime = new Date().getTime()
const fd = fetchWorkspaceDirectoryContent(state, payload)
const flatTree = flattenTree(fd, state.mode === 'browser'? state.browser.expandPath : state.localhost.expandPath)
const endTime = new Date().getTime()
console.log('fetchDirectoryContent tree', endTime - startTime, fd, flatTree)
return {
...state,
@ -346,7 +334,6 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
const payload = action.payload
const fd = fileAdded(state, payload)
const dir = extractParentFromKey(payload)
console.log('FILE_ADDED_SUCCESS', payload, dir)
const browserExpandPath = state.mode === 'browser' && !isElectron() ? [...new Set([...state.browser.expandPath, payload])] : state.browser.expandPath
const localhostExpandPath = state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload])] : state.localhost.expandPath
const flatTree = flattenTree(fd, state.mode === 'browser'? browserExpandPath : localhostExpandPath)
@ -378,7 +365,6 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
case 'FOLDER_ADDED_SUCCESS': {
const payload = action.payload
const fd = fetchDirectoryContent(state, payload)
console.log('FOLDER_ADDED_SUCCESS', payload)
const browserExpandPath = state.mode === 'browser' && !isElectron() ? [...new Set([...state.browser.expandPath, payload.folderPath])] : state.browser.expandPath
const localhostExpandPath = state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload.folderPath])] : state.localhost.expandPath
const flatTree = flattenTree(fd, state.mode === 'browser'? browserExpandPath : localhostExpandPath)
@ -480,7 +466,6 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
case 'REMOVE_INPUT_FIELD': {
const payload = action.payload
const fd = removeInputField(state, payload.path)
console.log('REMOVE_INPUT_FIELD', payload, fd)
const flatTree = flattenTree(fd, state.mode === 'browser'? state.browser.expandPath : state.localhost.expandPath)
return {
...state,
@ -893,7 +878,6 @@ export const browserReducer = (state = browserInitialState, action: Actions) =>
}
const flattenTree = (files, expandPath: string[]) =>{
console.log('flattenTree', files, expandPath)
const flatTree = {}
const mapChild = (file: FileType) => {
@ -909,7 +893,6 @@ const flattenTree = (files, expandPath: string[]) =>{
mapChild(files[ROOT_PATH][key])
})
console.log('flat tree', flatTree)
return flatTree
}
@ -967,7 +950,6 @@ const removeInputField = (
let files =
state.mode === 'browser' ? state.browser.files : state.localhost.files
const root = ROOT_PATH
console.log('removeInputField', path, files, root)
if (path === root) {
delete files[root][path + '/' + 'blank']
return files
@ -1095,7 +1077,6 @@ const fetchWorkspaceDirectoryContent = (
state: BrowserState,
payload: {fileTree; path: string}
): {[x: string]: Record<string, FileType>} => {
console.log('fetchWorkspaceDirectoryContent', payload.fileTree)
payload.fileTree = fileKeySort(payload.fileTree)
const files = normalize(payload.fileTree, ROOT_PATH)

@ -78,10 +78,6 @@ export function Workspace() {
dragStatus: false
})
useEffect(() => {
console.log("platform", platform)
},[platform])
useEffect(() => {
if (canPaste) {
addMenuItems([
@ -114,14 +110,6 @@ export function Workspace() {
}
}, [canPaste])
useEffect(() => {
console.log('WORKSPACE RENDER')
})
useEffect(() => {
console.log("workspace state")
},[currentWorkspace])
useEffect(() => {
let workspaceName = localStorage.getItem('currentWorkspace')
if (!workspaceName && global.fs.browser.workspaces.length) {
@ -921,7 +909,6 @@ export function Workspace() {
}}
onContextMenu={(e) => {
e.preventDefault()
console.log(e)
handleContextMenu(e.pageX, e.pageY, ROOT_PATH, 'workspace', 'workspace')
}}
>

@ -138,7 +138,6 @@ export const fileKeySort = (fileTree: any) => {
//const blankChildren = Object.keys(children).filter((key: string) => children[key].name === '')
const keys = [...directories, ...fileKeys]
console.log('sorted keys', keys)
// rebuild the fileTree using the keys
const newFileTree = {}
keys.forEach((key: string) => {

Loading…
Cancel
Save