diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 38e35e302b..ce0ddac4e3 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -135,44 +135,39 @@ class FileManager extends FileSystemApi { } async setFile (path, content) { + let reject = false + let saveAsCopy = false + + function acceptFileRewriting (e, toaster) { + reject = false + e.target.innerHTML = 'Accepted' + toaster.hide() + toaster.forceResolve() + } + function cancelFileRewriting (e, toaster) { + reject = true + e.target.innerHTML = 'Canceled' + toaster.hide() + } + const saveFileAsCopy = (e, toaster) => { + if (saveAsCopy) return + this._saveAsCopy(path, content) + + saveAsCopy = true + e.target.innerHTML = 'Saved' + toaster.hide() + } if (this.currentRequest) { - let reject = false - let saveAsCopy = false let actions = (toaster) => { return yo`
- - -
@@ -206,6 +201,20 @@ class FileManager extends FileSystemApi { }) } + _saveAsCopy (path, content) { + const fileProvider = this.fileProviderOf(path) + if (fileProvider) { + helper.createNonClashingNameWithPrefix(path, fileProvider, '', (error, copyName) => { + if (error) { + console.log('createNonClashingNameWithPrefix', error) + copyName = path + '.' + this.currentRequest.from + } + this._setFileInternal(copyName, content) + this.switchFile(copyName) + }) + } + } + removeTabsOf (provider) { for (var tab in this.openedFiles) { if (this.fileProviderOf(tab).type === provider.type) { diff --git a/src/app/ui/tooltip.js b/src/app/ui/tooltip.js index 72025e1464..4ddc20d39b 100644 --- a/src/app/ui/tooltip.js +++ b/src/app/ui/tooltip.js @@ -55,8 +55,17 @@ class Toaster { const shortTooltipText = (canShorten && tooltipText.length > 201) ? tooltipText.substring(0, 200) + '...' : tooltipText this.resolveFn = resolve + function showFullMessage () { + modal.alert(tooltipText) + } + + function closeTheToaster (self) { + self.hide() + over() + resolve() + } let button = tooltipText.length > 201 ? yo` - + ` : `` this.tooltip = yo` @@ -67,11 +76,7 @@ class Toaster { ${actionElement} - + ` let timeOut = () => {