Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b4a4469
Initialise fileSystem reducer
ioedeveloper Apr 12, 2021
3c4606f
template files
ioedeveloper Apr 12, 2021
48f6b50
File provider actions
ioedeveloper Apr 15, 2021
ee357b6
Change files structure.
ioedeveloper Apr 19, 2021
99395f7
Resolve directory
ioedeveloper Apr 19, 2021
be2341a
Complete input fields functionality
ioedeveloper Apr 21, 2021
837490e
Fix file added bug
ioedeveloper Apr 22, 2021
49e0da7
Fix event bugs
ioedeveloper Apr 23, 2021
7deedba
replace directory bug
ioedeveloper Apr 24, 2021
7033c20
Fixed file/folder removed bug
ioedeveloper Apr 24, 2021
ed03204
Init plugin
ioedeveloper Apr 24, 2021
59afc28
Renames but appends to bottom
ioedeveloper Apr 24, 2021
b71001e
Fixed renamed position
ioedeveloper Apr 25, 2021
1f7d1fa
Complete notifications setup
ioedeveloper Apr 25, 2021
b584142
Update selector for blank input field.
ioedeveloper Apr 26, 2021
383ac93
Expand externally loaded files
ioedeveloper Apr 26, 2021
8dfeb65
Fix failing tests
ioedeveloper Apr 27, 2021
3a1a03a
Fixed exists callback bug
ioedeveloper Apr 27, 2021
bf80ca9
Changed remixd set and createDir implementation, changed fileProvider…
ioedeveloper Apr 29, 2021
9b9fa8c
Add tests for workspace alert modal
ioedeveloper Apr 29, 2021
cbd0233
Fixed library deployment test
ioedeveloper Apr 29, 2021
d96f11c
Fixed failing tests
ioedeveloper Apr 29, 2021
7ef4483
Conditionally close alert
ioedeveloper Apr 29, 2021
3dfd5ef
Rename helper function to createNonClashingNameAsync
ioedeveloper Apr 29, 2021
9272951
Revert "Fixed library deployment test"
ioedeveloper Apr 29, 2021
0cfab43
Fixed file linking for libraries
ioedeveloper Apr 30, 2021
c991d4a
Fixed failing tests
ioedeveloper Apr 30, 2021
e6a36a3
Wait for workspace creation before fetching
ioedeveloper May 11, 2021
e638250
Revert "Wait for workspace creation before fetching"
ioedeveloper May 12, 2021
9fb30ce
Wait for exists asynchronous check.
ioedeveloper May 12, 2021
3e0c62a
Use provider name in callback
ioedeveloper May 12, 2021
cb86b5d
Fixed failing chrome test
ioedeveloper May 12, 2021
90eb487
Fixed e2e tests
ioedeveloper May 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/remix-ide-e2e/src/commands/addFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC
.clickLaunchIcon('filePanel')
.click('li[data-id="treeViewLitreeViewItemREADME.txt"]') // focus on root directory
.click('.newFile')
.waitForElementContainsText('*[data-id="treeViewLitreeViewItem/blank"]', '', 60000)
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', name)
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementContainsText('*[data-id$="/blank"]', '', 60000)
.sendKeys('*[data-id$="/blank"] .remixui_items', name)
.sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER)
.pause(2000)
.waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000)
.setEditorValue(content.content)
Expand Down
9 changes: 8 additions & 1 deletion apps/remix-ide-e2e/src/helpers/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import { NightwatchBrowser } from 'nightwatch'

require('dotenv').config()

export default function (browser: NightwatchBrowser, callback: VoidFunction, url?: string, preloadPlugins = true): void {
export default function (browser: NightwatchBrowser, callback: VoidFunction, url?: string, preloadPlugins = true, closeWorkspaceAlert = true): void {
browser
.url(url || 'http://127.0.0.1:8080')
.pause(5000)
.switchBrowserTab(0)
.perform((done) => {
if (closeWorkspaceAlert) {
browser.waitForElementVisible('*[data-id="modalDialogModalBody"]', 60000)
.modalFooterOKClick()
}
done()
})
.fullscreenWindow(() => {
if (preloadPlugins) {
initModules(browser, () => {
Expand Down
12 changes: 6 additions & 6 deletions apps/remix-ide-e2e/src/tests/fileExplorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ module.exports = {
.click('li[data-id="treeViewLitreeViewItemREADME.txt"]') // focus on root directory
.click('*[data-id="fileExplorerNewFilecreateNewFile"]')
.pause(1000)
.waitForElementVisible('*[data-id="treeViewLitreeViewItem/blank"]')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', '5_New_contract.sol')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id$="/blank"]')
.sendKeys('*[data-id$="/blank"] .remixui_items', '5_New_contract.sol')
.sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id="treeViewLitreeViewItem5_New_contract.sol"]', 7000)
},

Expand All @@ -49,9 +49,9 @@ module.exports = {
.click('li[data-id="treeViewLitreeViewItemREADME.txt"]') // focus on root directory
.click('[data-id="fileExplorerNewFilecreateNewFolder"]')
.pause(1000)
.waitForElementVisible('*[data-id="treeViewLitreeViewItem/blank"]')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', 'Browser_Tests')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id$="/blank"]')
.sendKeys('*[data-id$="/blank"] .remixui_items', 'Browser_Tests')
.sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id="treeViewLitreeViewItemBrowser_Tests"]')
},

Expand Down
6 changes: 3 additions & 3 deletions apps/remix-ide-e2e/src/tests/gist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ module.exports = {
.waitForElementVisible('*[data-id="fileExplorerNewFilecreateNewFolder"]')
.click('[data-id="fileExplorerNewFilecreateNewFolder"]')
.pause(1000)
.waitForElementVisible('*[data-id="treeViewLitreeViewItem/blank"]')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', 'Browser_Tests')
.sendKeys('*[data-id="treeViewLitreeViewItem/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id$="/blank"]')
.sendKeys('*[data-id$="/blank"] .remixui_items', 'Browser_Tests')
.sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER)
.waitForElementVisible('*[data-id="treeViewLitreeViewItemBrowser_Tests"]')
.addFile('File.sol', { content: '' })
.click('*[data-id="fileExplorerNewFilepublishToGist"]')
Expand Down
3 changes: 1 addition & 2 deletions apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ function runTests (browser: NightwatchBrowser) {
.click('*[data-id="treeViewLitreeViewItemcontracts"]')
.openFile('contracts/3_Ballot.sol')
.clickLaunchIcon('solidityUnitTesting')
.pause(500)
.setValue('*[data-id="uiPathInput"]', 'tests')
.pause(2000)
.verify.attributeEquals('*[data-id="uiPathInput"]', 'value', 'tests')
.scrollAndClick('#runTestsTabRunAction')
.waitForElementVisible('*[data-id="testTabSolidityUnitTestsOutputheader"]', 120000)
.waitForElementPresent('#solidityUnittestsOutput div[class^="testPass"]', 60000)
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const sources = [

module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080/#optimize=true&runs=300&evmVersion=istanbul&version=soljson-v0.7.4+commit.3f05b770.js&code=cHJhZ21hIHNvbGlkaXR5ID49MC42LjAgPDAuNy4wOwoKaW1wb3J0ICJodHRwczovL2dpdGh1Yi5jb20vT3BlblplcHBlbGluL29wZW56ZXBwZWxpbi1jb250cmFjdHMvYmxvYi9tYXN0ZXIvY29udHJhY3RzL2FjY2Vzcy9Pd25hYmxlLnNvbCI7Cgpjb250cmFjdCBHZXRQYWlkIGlzIE93bmFibGUgewogIGZ1bmN0aW9uIHdpdGhkcmF3KCkgZXh0ZXJuYWwgb25seU93bmVyIHsKICB9Cn0')
init(browser, done, 'http://127.0.0.1:8080/#optimize=true&runs=300&evmVersion=istanbul&version=soljson-v0.7.4+commit.3f05b770.js&code=cHJhZ21hIHNvbGlkaXR5ID49MC42LjAgPDAuNy4wOwoKaW1wb3J0ICJodHRwczovL2dpdGh1Yi5jb20vT3BlblplcHBlbGluL29wZW56ZXBwZWxpbi1jb250cmFjdHMvYmxvYi9tYXN0ZXIvY29udHJhY3RzL2FjY2Vzcy9Pd25hYmxlLnNvbCI7Cgpjb250cmFjdCBHZXRQYWlkIGlzIE93bmFibGUgewogIGZ1bmN0aW9uIHdpdGhkcmF3KCkgZXh0ZXJuYWwgb25seU93bmVyIHsKICB9Cn0', true, false)
},

'@sources': function () {
Expand Down
6 changes: 3 additions & 3 deletions apps/remix-ide/src/app/compiler/compiler-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ module.exports = class CompilerImports extends Plugin {
if (provider.type === 'localhost' && !provider.isConnected()) {
return reject(new Error(`file provider ${provider.type} not available while trying to resolve ${url}`))
}
provider.exists(url, (error, exist) => {
if (error) return reject(error)

provider.exists(url).then(exist => {
/*
if the path is absolute and the file does not exist, we can stop here
Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/<path>" and we'll end in an infinite loop.
Expand Down Expand Up @@ -162,6 +160,8 @@ module.exports = class CompilerImports extends Plugin {
if (error) return reject(error)
resolve(content)
})
}).catch(error => {
return reject(error)
})
}
})
Expand Down
5 changes: 3 additions & 2 deletions apps/remix-ide/src/app/editor/contextView.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ class ContextView {
if (filename !== this._deps.config.get('currentFile')) {
const provider = this._deps.fileManager.fileProviderOf(filename)
if (provider) {
provider.exists(filename, (error, exist) => {
if (error) return console.log(error)
provider.exists(filename).then(exist => {
this._deps.fileManager.open(filename)
jumpToLine(lineColumn)
}).catch(error => {
if (error) return console.log(error)
})
}
} else {
Expand Down
5 changes: 1 addition & 4 deletions apps/remix-ide/src/app/files/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ class FileManager extends Plugin {
try {
path = this.limitPluginScope(path)
const provider = this.fileProviderOf(path)
const result = provider.exists(path, (err, result) => {
if (err) return false
return result
})
const result = provider.exists(path)

return result
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide/src/app/files/fileProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class FileProvider {
})
}

exists (path, cb) {
async exists (path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to add async if the content of the function is not using await ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding async returns a promise. I added it because fileManager expects a promise just like how remixdProvider returns a promise.

// todo check the type (directory/file) as well #2386
// currently it is not possible to have a file and folder with same path
const ret = this._exists(path)
if (cb) cb(null, ret)

return ret
}

Expand Down
9 changes: 4 additions & 5 deletions apps/remix-ide/src/app/files/remixDProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,15 @@ module.exports = class RemixDProvider extends FileProvider {
})
}

exists (path, cb) {
if (!this._isReady) return cb && cb('provider not ready')
exists (path) {
if (!this._isReady) throw new Error('provider not ready')
const unprefixedpath = this.removePrefix(path)

return this._appManager.call('remixd', 'exists', { path: unprefixedpath })
.then((result) => {
if (cb) return cb(null, result)
return result
}).catch((error) => {
if (cb) return cb(error)
})
.catch((error) => {
throw new Error(error)
})
}
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/files/workspaceFileProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WorkspaceFileProvider extends FileProvider {
if (!this.workspace) this.createWorkspace()
path = path.replace(/^\/|\/$/g, '') // remove first and last slash
if (path.startsWith(this.workspacesPath + '/' + this.workspace)) return path
if (path.startsWith(this.workspace)) return this.workspacesPath + '/' + this.workspace
if (path.startsWith(this.workspace)) return path.replace(this.workspace, this.workspacesPath + '/' + this.workspace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand this change, is this a fix for when a folder has the same name as the workspace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes an issue i had when querying provider.exists(). If i have a path like default_workspace/contracts/ballot.sol, before resolving if the path exists removePrefix() is called. Now with the previous check, since the path starts with default_workspace, .workspaces/default_workspace is returned and when this (.workspaces/default_workspace) is checked if it exists, it always returns true. My change fixes that.

path = super.removePrefix(path)
let ret = this.workspacesPath + '/' + this.workspace + '/' + (path === '/' ? '' : path)

Expand Down
19 changes: 12 additions & 7 deletions apps/remix-ide/src/app/panels/file-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ module.exports = class Filepanel extends ViewPlugin {
const browserProvider = this._deps.fileProviders.browser
const workspacePath = 'browser/' + workspaceProvider.workspacesPath + '/' + name
const workspaceRootPath = 'browser/' + workspaceProvider.workspacesPath
if (!browserProvider.exists(workspaceRootPath)) browserProvider.createDir(workspaceRootPath)
if (!browserProvider.exists(workspacePath)) browserProvider.createDir(workspacePath)
const workspaceRootPathExists = await browserProvider.exists(workspaceRootPath)
const workspacePathExists = await browserProvider.exists(workspacePath)

if (!workspaceRootPathExists) browserProvider.createDir(workspaceRootPath)
if (!workspacePathExists) browserProvider.createDir(workspacePath)
}

async workspaceExists (name) {
Expand All @@ -209,11 +212,13 @@ module.exports = class Filepanel extends ViewPlugin {
workspaceProvider.setWorkspace(workspaceName)
await this.request.setWorkspace(workspaceName) // tells the react component to switch to that workspace
for (const file in examples) {
try {
await workspaceProvider.set(examples[file].name, examples[file].content)
} catch (error) {
console.error(error)
}
setTimeout(async () => { // space creation of files to give react ui time to update.
try {
await workspaceProvider.set(examples[file].name, examples[file].content)
} catch (error) {
console.error(error)
}
}, 10)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion apps/remix-ide/src/app/tabs/testTab/testTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class TestTabLogic {
// Checking to ignore the value which contains only whitespaces
if (!path || !(/\S/.test(path))) return
const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0])
fileProvider.exists(path, (e, res) => { if (!res) fileProvider.createDir(path) })
fileProvider.exists(path).then(res => {
if (!res) fileProvider.createDir(path)
})
}

pathExists (path) {
Expand Down
5 changes: 3 additions & 2 deletions apps/remix-ide/src/app/ui/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ Renderer.prototype._errorClick = function (errFile, errLine, errCol) {
// TODO: refactor with this._components.contextView.jumpTo
var provider = self._deps.fileManager.fileProviderOf(errFile)
if (provider) {
provider.exists(errFile, (error, exist) => {
if (error) return console.log(error)
provider.exists(errFile).then(exist => {
self._deps.fileManager.open(errFile)
editor.gotoLine(errLine, errCol)
}).catch(error => {
if (error) return console.log(error)
})
}
} else {
Expand Down
35 changes: 27 additions & 8 deletions apps/remix-ide/src/lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ module.exports = {
async.whilst(
() => { return exist },
(callback) => {
fileProvider.exists(name + counter + prefix + '.' + ext, (error, currentExist) => {
if (error) {
callback(error)
} else {
exist = currentExist
if (exist) counter = (counter | 0) + 1
callback()
}
fileProvider.exists(name + counter + prefix + '.' + ext).then(currentExist => {
exist = currentExist
if (exist) counter = (counter | 0) + 1
callback()
}).catch(error => {
if (error) console.log(error)
})
},
(error) => { cb(error, name + counter + prefix + '.' + ext) }
Expand All @@ -52,6 +50,27 @@ module.exports = {
createNonClashingName (name, fileProvider, cb) {
this.createNonClashingNameWithPrefix(name, fileProvider, '', cb)
},
async createNonClashingNameAsync (name, fileManager, prefix = '') {
if (!name) name = 'Undefined'
let counter = ''
let ext = 'sol'
const reg = /(.*)\.([^.]+)/g
const split = reg.exec(name)
if (split) {
name = split[1]
ext = split[2]
}
let exist = true

do {
const isDuplicate = await fileManager.exists(name + counter + prefix + '.' + ext)

if (isDuplicate) counter = (counter | 0) + 1
else exist = false
} while (exist)

return name + counter + prefix + '.' + ext
},
checkSpecialChars (name) {
return name.match(/[:*?"<>\\'|]/) != null
},
Expand Down
Loading