added accept button to toaster for setfile

pull/1/head
LianaHus 6 years ago
parent e4c026bd5d
commit c388b78eec
  1. 31
      src/app/files/fileManager.js

@ -138,8 +138,24 @@ class FileManager extends FileSystemApi {
if (this.currentRequest) { if (this.currentRequest) {
let reject = false let reject = false
let savedAsCopy = false let savedAsCopy = false
let accept = false
let actions = (toaster) => { let actions = (toaster) => {
return yo`<div class="container ml-1"> return yo`
<div class="container ml-1">
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => {
accept = true;
e.target.innerHTML = 'Accepted';
const fileProvider = this.fileProviderOf(path)
if (!fileProvider) return
if (!fileProvider.set(path, content)) {
return modalDialogCustom.alert('Failed to create a file ' + path)
}
this.syncEditor(path)
this.switchFile(path)
toaster.hide()
}}>
Accept
</button>
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { <button class="btn btn-primary btn-sm m-1" onclick=${(e) => {
reject = true; reject = true;
e.target.innerHTML = 'Canceled'; e.target.innerHTML = 'Canceled';
@ -156,25 +172,28 @@ class FileManager extends FileSystemApi {
if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error)
if (!fileProvider.set(newFile, content)) return modalDialogCustom.alert('Failed to create a file ' + newFile) if (!fileProvider.set(newFile, content)) return modalDialogCustom.alert('Failed to create a file ' + newFile)
this.switchFile(newFile) this.switchFile(newFile)
this.syncEditor(path)
}) })
e.target.innerHTML = 'Saved' e.target.innerHTML = 'Saved'
toaster.hide() toaster.hide()
}}> }}>
Save As Copy Save As Copy
</button> </button>
</div>` </div>
`
} }
await toaster(yo` await toaster(yo`
<div> <div>
<i class="fas fa-exclamation-triangle text-danger mr-1"></i> <i class="fas fa-exclamation-triangle text-danger mr-1"></i>
<span> <span>
${this.currentRequest.from}<span class="text-danger"> is modyfing </span>${path} ${this.currentRequest.from}<span class="text-danger"> is trying to modify </span>${path}
</span> </span>
</div>`, actions, { time: 4000 }) </div>
`, actions, { time: 4000 })
if (reject) throw new Error(`set file operation on ${path} aborted by user.`) if (reject) throw new Error(`set file operation on ${path} aborted by user.`)
if (savedAsCopy) return if (accept || savedAsCopy) return
else this._setFileInternal(path, content)
} }
this._setFileInternal(path, content)
} }
_setFileInternal (path, content) { _setFileInternal (path, content) {

Loading…
Cancel
Save