|
|
|
@ -135,44 +135,39 @@ class FileManager extends FileSystemApi { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async setFile (path, content) { |
|
|
|
|
if (this.currentRequest) { |
|
|
|
|
let reject = false |
|
|
|
|
let saveAsCopy = false |
|
|
|
|
let actions = (toaster) => { |
|
|
|
|
return yo` |
|
|
|
|
<div class="container ml-1"> |
|
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { |
|
|
|
|
|
|
|
|
|
function acceptFileRewriting (e, toaster) { |
|
|
|
|
reject = false |
|
|
|
|
e.target.innerHTML = 'Accepted' |
|
|
|
|
toaster.hide() |
|
|
|
|
toaster.forceResolve() |
|
|
|
|
}}> |
|
|
|
|
Accept |
|
|
|
|
</button> |
|
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { |
|
|
|
|
} |
|
|
|
|
function cancelFileRewriting (e, toaster) { |
|
|
|
|
reject = true |
|
|
|
|
e.target.innerHTML = 'Canceled' |
|
|
|
|
toaster.hide() |
|
|
|
|
}}> |
|
|
|
|
Cancel |
|
|
|
|
</button> |
|
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { |
|
|
|
|
if (saveAsCopy) return |
|
|
|
|
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) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
e.target.innerHTML = 'Saved' |
|
|
|
|
const saveFileAsCopy = (e, toaster) => { |
|
|
|
|
if (saveAsCopy) return |
|
|
|
|
this._saveAsCopy(path, content) |
|
|
|
|
|
|
|
|
|
saveAsCopy = true |
|
|
|
|
e.target.innerHTML = 'Saved' |
|
|
|
|
toaster.hide() |
|
|
|
|
}}> |
|
|
|
|
} |
|
|
|
|
if (this.currentRequest) { |
|
|
|
|
let actions = (toaster) => { |
|
|
|
|
return yo` |
|
|
|
|
<div class="container ml-1"> |
|
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => acceptFileRewriting(e, toaster)}> |
|
|
|
|
Accept |
|
|
|
|
</button> |
|
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => cancelFileRewriting(e, toaster)}> |
|
|
|
|
Cancel |
|
|
|
|
</button> |
|
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick="${(e) => saveFileAsCopy(e, toaster)}"> |
|
|
|
|
Save As Copy |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
@ -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) { |
|
|
|
|