Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move filemanager api to new api #2733

Merged
merged 25 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
56a09c9
Moved getFolder to new API readdir
ioedeveloper Apr 13, 2020
0e7e1e5
Added error code and handlers
ioedeveloper Apr 13, 2020
a545296
Moved getFile, setFile and switchFile to new API
ioedeveloper Apr 15, 2020
4e3b8d1
Fix linting error
ioedeveloper Apr 15, 2020
df91b92
Changed logic for file/dir exists to use file provider
ioedeveloper Apr 16, 2020
9c830a1
implemented mkdir and rmdir
ioedeveloper Apr 20, 2020
de2a467
Implemented unlink and changed implementation of error handler
ioedeveloper Apr 20, 2020
0488a4c
Fixed linting error
ioedeveloper Apr 20, 2020
b5ce812
Fixed broken writeFile function
ioedeveloper Apr 20, 2020
b45004d
Removed delay used for debugging
ioedeveloper Apr 21, 2020
12bc629
Implemented receive response in async/await
ioedeveloper May 5, 2020
fcec4fe
Changed fileExplorer to async/await to fix remixd error
ioedeveloper May 6, 2020
4cc3802
Fixed Remixd folder delete bug and changed rmdir, unlink to remove api
ioedeveloper May 7, 2020
210671f
Fixed error with isDirectory in file provider
ioedeveloper May 7, 2020
d6fd520
Fixed linting error
ioedeveloper May 7, 2020
aa2cd0a
Update remixd version
ioedeveloper May 12, 2020
21e644f
Update remixd dependency in package.json
ioedeveloper May 12, 2020
30a7e8f
Fixed failing test
ioedeveloper May 13, 2020
ae79ff3
Removed unnecessary comments
ioedeveloper May 13, 2020
b94fe92
Update terminal test with new filemanager api
ioedeveloper May 13, 2020
fc09e7e
Changed switchFile event to openFile event
ioedeveloper May 13, 2020
10bb3a7
Removed comment
ioedeveloper May 15, 2020
2cf7ed5
changed nightwatch switchFile command to openFile
ioedeveloper May 15, 2020
129bf2e
ensure file is opened before marking it
yann300 May 19, 2020
4fa4d42
Implemented old api redirection to new api
ioedeveloper May 25, 2020
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
23,999 changes: 11,751 additions & 12,248 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"remix-solidity": "0.3.30",
"remix-tabs": "1.0.48",
"remix-tests": "0.1.33",
"remixd": "0.1.8-alpha.10",
"remixd": "0.1.8-alpha.16",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think lock file also needs to be checked in

"request": "^2.83.0",
"rimraf": "^2.6.1",
"selenium-standalone": "^6.17.0",
Expand All @@ -81,7 +81,6 @@
"dependencies": {
"@remixproject/engine": "^0.2.3",
"http-server": "^0.11.1",
"remixd": "0.1.8-alpha.10",
"standard": "^8.5.0"
},
"repository": {
Expand Down Expand Up @@ -185,7 +184,6 @@
"nightwatch_local_fileExplorer": "nightwatch ./test-browser/tests/fileExplorer.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_debugger": "nightwatch ./test-browser/tests/debugger.test.js --config nightwatch.js --env chrome ",
"nightwatch_local_editor": "nightwatch ./test-browser/tests/editor.test.js --config nightwatch.js --env chrome ",

"nightwatch_local_runAndDeploy": "nightwatch ./test-browser/tests/runAndDeploy.js --config nightwatch.js --env chrome-runAndDeploy ",
"onchange": "onchange build/app.js -- npm-run-all lint",
"prepublish": "mkdirp build; npm-run-all -ls downloadsolc_root build",
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
if (error) console.error(error)
if (Object.keys(filesList).length === 0) {
for (let file in examples) {
fileManager.setFile(examples[file].name, examples[file].content)
fileManager.writeFile(examples[file].name, examples[file].content)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/editor/contextView.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ContextView {
if (provider) {
provider.exists(filename, (error, exist) => {
if (error) return console.log(error)
this._deps.fileManager.switchFile(filename)
this._deps.fileManager.open(filename)
jumpToLine(lineColumn)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/editor/sourceHighlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SourceHighlighter {
}
}

currentSourceLocationFromfileName (lineColumnPos, filePath, style) {
async currentSourceLocationFromfileName (lineColumnPos, filePath, style) {
if (this.statementMarker) this._deps.editor.removeMarker(this.statementMarker, this.source)
if (this.fullLineMarker) this._deps.editor.removeMarker(this.fullLineMarker, this.source)
this.statementMarker = null
Expand All @@ -40,7 +40,7 @@ class SourceHighlighter {
if (lineColumnPos) {
this.source = filePath
if (this._deps.config.get('currentFile') !== this.source) {
this._deps.fileManager.switchFile(this.source)
await this._deps.fileManager.open(this.source)
}

const css = csjs`
Expand Down
34 changes: 24 additions & 10 deletions src/app/files/file-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function fileExplorer (localRegistry, files, menuItems) {
}

self.events.register('focus', function (path) {
self._deps.fileManager.switchFile(path)
self._deps.fileManager.open(path)
})

self._components.registry.put({ api: self, name: `fileexplorer/${self.files.type}` })
Expand Down Expand Up @@ -234,11 +234,16 @@ function fileExplorer (localRegistry, files, menuItems) {
const currentFoldername = extractNameFromKey(key)

modalDialogCustom.confirm(`Confirm to delete folder`, `Are you sure you want to delete ${currentFoldername} folder?`,
() => {
if (!files.remove(key)) {
async () => {
const fileManager = self._deps.fileManager
const removeFolder = await fileManager.remove(key)

if (!removeFolder) {
tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`)
} else {
self.updatePath('browser')
const { type } = fileManager.currentFileProvider()

self.updatePath(type)
}
}, () => {})
}
Expand Down Expand Up @@ -275,9 +280,16 @@ function fileExplorer (localRegistry, files, menuItems) {

modalDialogCustom.confirm(
`Delete file`, `Are you sure you want to delete ${currentFilename} file?`,
() => {
files.remove(key)
self.updatePath('browser')
async () => {
const fileManager = self._deps.fileManager
const removeFile = await fileManager.remove(key)

if (!removeFile) {
tooltip(`Failed to remove file ${key}.`)
} else {
const { type } = fileManager.currentFileProvider()
self.updatePath(type)
}
},
() => {}
)
Expand Down Expand Up @@ -578,13 +590,15 @@ fileExplorer.prototype.createNewFile = function (parentFolder = 'browser') {
let self = this
modalDialogCustom.prompt('Create new file', 'File Name (e.g Untitled.sol)', 'Untitled.sol', (input) => {
if (!input) input = 'New file'
helper.createNonClashingName(parentFolder + '/' + input, self.files, (error, newName) => {
helper.createNonClashingName(parentFolder + '/' + input, self.files, async (error, newName) => {
if (error) return tooltip('Failed to create file ' + newName + ' ' + error)
const fileManager = self._deps.fileManager
const createFile = await fileManager.writeFile(newName, '')

if (!self.files.set(newName, '')) {
if (!createFile) {
tooltip('Failed to create file ' + newName)
} else {
self._deps.fileManager.switchFile(newName)
await fileManager.open(newName)
if (newName.includes('_test.sol')) {
self.events.trigger('newTestFileCreated', [newName])
}
Expand Down
Loading