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

disable "discard changes" in context menu of FE #2477

Merged
merged 2 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions src/app/files/file-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,16 @@ function fileExplorer (localRegistry, files, menuItems) {
const provider = self._deps.fileManager.fileProviderOf(key)
actions['Create File'] = () => self.createNewFile(key)
actions['Create Folder'] = () => self.createNewFolder(key)
// @todo(#2386) not fully implemented. Readd later when fixed
if (provider.isExternalFolder(key)) {
actions['Discard changes'] = () => {
/* actions['Discard changes'] = () => {
modalDialogCustom.confirm(
'Discard changes',
'Are you sure you want to discard all your changes?',
() => { self.files.discardChanges(key) },
() => {}
)
}
} */
} else {
const folderPath = extractExternalFolder(key)
actions['Rename'] = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/app/files/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class FileManager extends Plugin {
}

fileChangedEvent (path) {
this.syncEditor(path)
// @todo(#2386) use only for discard changes function.
// this.syncEditor(path)
}

fileRenamedEvent (oldName, newName, isFolder) {
Expand Down
11 changes: 11 additions & 0 deletions src/app/tabs/compile-tab.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/app/tabs/compileTab/compilerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class CompilerContainer {
}

deactivate () {
// deactivate editor listeners
this.editor.event.unregister('contentChanged')
this.editor.event.unregister('sessionSwitched')
}

activate () {
Expand All @@ -50,8 +53,10 @@ class CompilerContainer {
}

listenToEvents () {
this.editor.event.register('contentChanged', this.scheduleCompilation.bind(this))
this.editor.event.register('sessionSwitched', this.scheduleCompilation.bind(this))
this.editor.event.register('sessionSwitched', () => {
if (!this._view.compileIcon) return
this.scheduleCompilation()
})

this.compileTabLogic.event.on('startingCompilation', () => {
if (!this._view.compileIcon) return
Expand All @@ -73,6 +78,7 @@ class CompilerContainer {

this.editor.event.register('contentChanged', () => {
if (!this._view.compileIcon) return
this.scheduleCompilation.bind(this)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why you need to bind here.

this._view.compileIcon.classList.add(`${css.bouncingIcon}`) // @TODO: compileView tab
})

Expand Down Expand Up @@ -131,6 +137,7 @@ class CompilerContainer {

// Load solc compiler version according to pragma in contract file
_setCompilerVersionFromPragma (filename) {
if (!this.data.allversions) return
this.compileTabLogic.fileManager.getFile(filename).then(data => {
const pragmaArr = data.match(/(pragma solidity (.+?);)/g)
if (pragmaArr && pragmaArr.length === 1) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/ui/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ module.exports = (event, items) => {
window.removeEventListener('click', hide)
}

var menu = Object.keys(items).map((item, index) => {
var current = yo`<li id="menuitem${item.toLowerCase()}" class=${css.liitem}>${item}</li>`
const menu = Object.keys(items).map((item, index) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

const current = yo`<li id="menuitem${item.toLowerCase()}" class=${css.liitem}>${item}</li>`
current.onclick = () => { hide(null, true); items[item]() }
return current
})
var container = yo`<div class="p-1 ${css.container} bg-light"><ul id='menuitems'>${menu}</ul></div>`
const container = yo`<div class="p-1 ${css.container} bg-light shadow border"><ul id='menuitems'>${menu}</ul></div>`
container.style.left = event.pageX + 'px'
container.style.top = event.pageY + 'px'
container.style.display = 'block'
Expand Down