|
|
@ -138,41 +138,35 @@ class FileManager extends FileSystemApi { |
|
|
|
if (this.currentRequest) { |
|
|
|
if (this.currentRequest) { |
|
|
|
let reject = false |
|
|
|
let reject = false |
|
|
|
let saveAsCopy = 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() |
|
|
|
|
|
|
|
} |
|
|
|
let actions = (toaster) => { |
|
|
|
let actions = (toaster) => { |
|
|
|
return yo` |
|
|
|
return yo` |
|
|
|
<div class="container ml-1"> |
|
|
|
<div class="container ml-1"> |
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { |
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => acceptFileRewriting(e, toaster)}> |
|
|
|
reject = false |
|
|
|
|
|
|
|
e.target.innerHTML = 'Accepted' |
|
|
|
|
|
|
|
toaster.hide() |
|
|
|
|
|
|
|
toaster.forceResolve() |
|
|
|
|
|
|
|
}}> |
|
|
|
|
|
|
|
Accept |
|
|
|
Accept |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { |
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => cancelFileRewriting(e, toaster)}> |
|
|
|
reject = true |
|
|
|
|
|
|
|
e.target.innerHTML = 'Canceled' |
|
|
|
|
|
|
|
toaster.hide() |
|
|
|
|
|
|
|
}}> |
|
|
|
|
|
|
|
Cancel |
|
|
|
Cancel |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick=${(e) => { |
|
|
|
<button class="btn btn-primary btn-sm m-1" onclick="${(e) => saveFileAsCopy(e, toaster)}"> |
|
|
|
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' |
|
|
|
|
|
|
|
saveAsCopy = true |
|
|
|
|
|
|
|
toaster.hide() |
|
|
|
|
|
|
|
}}> |
|
|
|
|
|
|
|
Save As Copy |
|
|
|
Save As Copy |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -185,7 +179,7 @@ class FileManager extends FileSystemApi { |
|
|
|
${this.currentRequest.from}<span class="text-danger font-weight-bold"> is trying to modify </span>${path} |
|
|
|
${this.currentRequest.from}<span class="text-danger font-weight-bold"> is trying to modify </span>${path} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
`, actions, { time: 5000 })
|
|
|
|
`, actions, { time: 15000 })
|
|
|
|
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 (saveAsCopy) return |
|
|
|
if (saveAsCopy) return |
|
|
|
} |
|
|
|
} |
|
|
@ -206,6 +200,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) { |
|
|
|
removeTabsOf (provider) { |
|
|
|
for (var tab in this.openedFiles) { |
|
|
|
for (var tab in this.openedFiles) { |
|
|
|
if (this.fileProviderOf(tab).type === provider.type) { |
|
|
|
if (this.fileProviderOf(tab).type === provider.type) { |
|
|
|