diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index 7b9a16bc20..2f1dc0c73a 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -28,10 +28,10 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) .sendKeys('*[data-id$="/blank"] .remixui_items', name) .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) - .pause(2000) + // .pause(2000) .waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) - .setEditorValue(content.content) - .pause(1000) + .setEditorValue(content.content).pause(5000) + // .pause(1000) .perform(function () { done() }) diff --git a/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx b/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx index 50c4699997..fbea56c2cd 100644 --- a/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx +++ b/apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx @@ -21,7 +21,7 @@ import './app.css' const client = new RemixPlugin() function App () { - const [payload, setPayload] = useState('') + const [payload, setPayload] = useState('["one/two/three/four/file.js","content"]') const [log, setLog] = useState() const [started, setStarted] = useState(false) const [events, setEvents] = useState() diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index 9036d422ff..08eb4ed91e 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -4,7 +4,7 @@ import init from '../helpers/init' module.exports = { before: function (browser: NightwatchBrowser, done: VoidFunction) { - init(browser, done, 'http://localhost:8080?plugins=solidity,udapp', false) + init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false) }, 'Should execution a simple console command': function (browser: NightwatchBrowser) { @@ -34,7 +34,6 @@ module.exports = { 'Async/Await Script': function (browser: NightwatchBrowser) { browser .addFile('asyncAwait.js', { content: asyncAwait }) - .openFile('asyncAwait.js') .executeScript('remix.execute("asyncAwait.js")') .waitForElementContainsText('*[data-id="terminalJournal"]', 'Waiting Promise', 60000) .waitForElementContainsText('*[data-id="terminalJournal"]', 'result - ', 60000) @@ -44,8 +43,6 @@ module.exports = { 'Call Remix File Manager from a script': function (browser: NightwatchBrowser) { browser .addFile('asyncAwaitWithFileManagerAccess.js', { content: asyncAwaitWithFileManagerAccess }) - .openFile('asyncAwaitWithFileManagerAccess.js') - .pause(5000) .executeScript('remix.execute(\'asyncAwaitWithFileManagerAccess.js\')') .waitForElementContainsText('*[data-id="terminalJournal"]', 'contract Ballot {', 60000) }, @@ -109,12 +106,12 @@ module.exports = { .clickLaunchIcon('filePanel') .click('*[data-id="treeViewDivtreeViewItem"]') // make sure we create the file at the root folder .addFile('deployWithEthersJs.js', { content: deployWithEthersJs }) - .openFile('deployWithEthersJs.js') + // .openFile('deployWithEthersJs.js') .pause(1000) .click('[data-id="treeViewDivtreeViewItemcontracts"]') .openFile('contracts/2_Owner.sol') .clickLaunchIcon('solidity') - .click('*[data-id="compilerContainerCompileBtn"]') // compile Owner + .click('*[data-id="compilerContainerCompileBtn"]').pause(5000) // compile Owner .executeScript('remix.execute(\'deployWithEthersJs.js\')') .waitForElementContainsText('*[data-id="terminalJournal"]', 'Contract Address:', 60000) .waitForElementContainsText('*[data-id="terminalJournal"]', '0xd9145CCE52D386f254917e481eB44e9943F39138', 60000) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 3463435730..45b498c4aa 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -331,8 +331,7 @@ class FileManager extends Plugin { throw createError({ code: 'EEXIST', message: `Cannot create directory ${path}` }) } const provider = this.fileProviderOf(path) - - return provider.createDir(path) + return await provider.createDir(path) } catch (e) { throw new Error(e) } @@ -621,26 +620,26 @@ class FileManager extends Plugin { const provider = resolved.provider this._deps.config.set('currentFile', file) this.openedFiles[file] = file - await (() => { - return new Promise((resolve, reject) => { - provider.get(file, (error, content) => { - if (error) { - console.log(error) - reject(error) + + return new Promise((resolve, reject) => { + provider.get(file, (error, content) => { + console.log('get file content', file, content) + if (error) { + console.log(error) + reject(error) + } else { + if (provider.isReadOnly(file)) { + this.editor.openReadOnly(file, content) } else { - if (provider.isReadOnly(file)) { - this.editor.openReadOnly(file, content) - } else { - this.editor.open(file, content) - } - // TODO: Only keep `this.emit` (issue#2210) - this.emit('currentFileChanged', file) - this.events.emit('currentFileChanged', file) - resolve() + this.editor.open(file, content) } - }) + // TODO: Only keep `this.emit` (issue#2210) + this.emit('currentFileChanged', file) + this.events.emit('currentFileChanged', file) + resolve() + } }) - })() + }) } } diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index e8b45c2ac8..01cefdf188 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -1,7 +1,6 @@ 'use strict' import { CompilerImports } from '@remix-project/core-plugin' -import { ConsoleLogs } from 'libs/remix-lib/src/helpers/hhconsoleSigs' const EventManager = require('events') const modalDialogCustom = require('../ui/modal-dialog-custom') const tooltip = require('../ui/tooltip') @@ -109,20 +108,21 @@ class FileProvider { return null } - await this.createDir(path.substr(0, path.lastIndexOf('/'))) - try { - await window.remixFileSystem.writeFile(unprefixedpath, content, 'utf8') - } catch (e) { - if (cb) cb(e) - return false - } - if (!exists) { - this.event.emit('fileAdded', this._normalizePath(unprefixedpath), false) - } else { - this.event.emit('fileChanged', this._normalizePath(unprefixedpath)) - } - if (cb) cb() - return true + await this.createDir(path.substr(0, path.lastIndexOf('/')), async () => { + try { + await window.remixFileSystem.writeFile(unprefixedpath, content, 'utf8') + } catch (e) { + if (cb) cb(e) + return false + } + if (!exists) { + this.event.emit('fileAdded', this._normalizePath(unprefixedpath), false) + } else { + this.event.emit('fileChanged', this._normalizePath(unprefixedpath)) + } + if (cb) cb() + return true + }) } async createDir (path, cb) { @@ -135,14 +135,16 @@ class FileProvider { if (!await window.remixFileSystem.exists(currentCheck)) { try { await window.remixFileSystem.mkdir(currentCheck) - console.log('folder add', currentCheck, this._normalizePath(currentCheck)) - this.event.emit('folderAdded', this._normalizePath(currentCheck)) - console.log("folderd added") } catch (error) { console.log(error) } } } + currentCheck = '' + for (const value of paths) { + currentCheck = currentCheck + '/' + value + this.event.emit('folderAdded', this._normalizePath(currentCheck)) + } if (cb) cb() } @@ -280,21 +282,17 @@ class FileProvider { path = this.removePrefix(path) if (path.indexOf('/') !== 0) path = '/' + path try { - console.log('res dir', path) const files = await window.remixFileSystem.readdir(path) const ret = {} - console.log(files) if (files) { for (let element of files) { path = path.replace(/^\/|\/$/g, '') // remove first and last slash element = element.replace(/^\/|\/$/g, '') // remove first and last slash const absPath = (path === '/' ? '' : path) + '/' + element - console.log("stat ", absPath, await window.remixFileSystem.stat(absPath)) ret[absPath.indexOf('/') === 0 ? absPath.substr(1, absPath.length) : absPath] = { isDirectory: (await window.remixFileSystem.stat(absPath)).isDirectory() } // ^ ret does not accept path starting with '/' } } - console.log("return", ret) if (cb) cb(null, ret) return ret } catch (error) { diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index bd3adf9b7f..feae5c3554 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -422,6 +422,9 @@ export class LandingPage extends ViewPlugin { }, 1000) } } + const setDemoFile = async () => { + } + const onAcceptDownloadn = async () => { await downloadFiles() const el = document.getElementById('modal-dialog') @@ -472,6 +475,9 @@ export class LandingPage extends ViewPlugin {
+ +
setDemoFile()}>SETFILE
+
${img} diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 732df69d97..f834990ac5 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -155,10 +155,6 @@ export class RemixAppManager extends PluginManager { pattern: [], sticky: true }) - //await this.call('filePanel', 'deleteWorkspace', `default_workspace`) - console.log("----------------------------------------------") - await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, true) - await this.call('fileManager', 'setFile', `one/two/files.js` ,"test") } } diff --git a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx index 8b729f07d4..7dec6ed64f 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -142,7 +142,6 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { if (cb) cb() return } - provider.get(file, (error, content) => { console.log({ content }) if (error) { diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index 3d11dcabe3..42d2d2b485 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.ts @@ -140,21 +140,18 @@ const fileAdded = async (filePath: string) => { } const folderAdded = async (folderPath: string) => { - console.log('folder add event', folderPath) const provider = plugin.fileManager.currentFileProvider() let path = extractParentFromKey(folderPath) || provider.workspace || provider.type || '' const promise = new Promise((resolve) => { provider.resolveDirectory(path, (error, fileTree) => { if (error) console.error(error) - console.log('resolve', JSON.stringify(fileTree)) resolve(fileTree) }) }) promise.then((files) => { folderPath = folderPath.replace(/^\/+/, '') - console.log('folderd add success', path, folderPath, JSON.stringify(files)) dispatch(folderAddedSuccess(path, folderPath, files)) }).catch((error) => { console.error(error) diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index 9b3d2e85fc..53891615c2 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -190,10 +190,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => { }) } - useEffect(() => { - console.log(JSON.stringify(fs.browser.files)) - },[JSON.stringify(fs.browser.files).length]) - const value = { fs, modal, diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index ab960dcbad..3e571f660c 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -646,14 +646,25 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s if (state.mode === 'browser') { if (payload.path === state.browser.currentWorkspace) { let files = normalize(payload.fileTree, payload.path, payload.type) - files = _.merge(files, state.browser.files[state.browser.currentWorkspace]) if (deletePath) delete files[deletePath] return { [state.browser.currentWorkspace]: files } } else { let files = state.browser.files const _path = splitPath(state, payload.path) - const prevFiles = _.get(files, _path) + let prevFiles = _.get(files, _path) + + if(!prevFiles){ + var object = {}, o = object; + for(let pa of _path) { + o = o[pa] = {}; + if(pa !== _path[0]) + o = o['child'] = {} + } + files = _.defaultsDeep(files, object) + prevFiles = _.get(files, _path) + } + if (prevFiles) { prevFiles.child = _.merge(normalize(payload.fileTree, payload.path, payload.type), prevFiles.child)