Commit 2413a190 authored by LianaHus's avatar LianaHus

added "delete from remix"

parent 70fbfbe2
...@@ -220,14 +220,20 @@ function fileExplorer (localRegistry, files, menuItems) { ...@@ -220,14 +220,20 @@ function fileExplorer (localRegistry, files, menuItems) {
} }
actions['Delete'] = () => { actions['Delete'] = () => {
if (self.files.readonly) { return tooltip('cannot delete file. ' + self.files.type + ' is a read only explorer') } if (self.files.readonly) { return tooltip('cannot delete file. ' + self.files.type + ' is a read only explorer') }
modalDialogCustom.confirm('Delete a file', 'Are you sure you want to delete this file?', () => { files.remove(key) }, () => {}) modalDialogCustom.confirm(
'Delete a file', 'Are you sure you want to delete this file?',
() => { files.remove(key) },
() => {}
)
} }
} else { } else {
actions['Copy to Browser explorer'] = () => { actions['Delete from remix'] = () => {
files.get(key, (error, content) => { modalDialogCustom.confirm(
if (error) return tooltip(error) 'Delete from remix',
self._deps.fileManager.setFile(`browser/${label.innerText}`, content) 'Are you sure you want to delete this file from remix?',
}) () => { files.remove(key) },
() => {}
)
} }
} }
MENU_HANDLE = contextMenu(event, actions) MENU_HANDLE = contextMenu(event, actions)
......
...@@ -71,7 +71,7 @@ class FileProvider { ...@@ -71,7 +71,7 @@ class FileProvider {
} }
addReadOnly (path, content, url) { addReadOnly (path, content, url) {
this.readonlyItems.push('browser/' + path) this.readonlyItems.push(this.type + '/' + path)
if (!url) this.normalizedNames[url] = path if (!url) this.normalizedNames[url] = path
return this.set(path, content) return this.set(path, content)
} }
...@@ -80,12 +80,15 @@ class FileProvider { ...@@ -80,12 +80,15 @@ class FileProvider {
return this.readonlyItems.includes(path) return this.readonlyItems.includes(path)
} }
remove (path) { _removeFromReadonlyList (path) {
// remove from readonly list
const indexToRemove = this.readonlyItems.indexOf(path) const indexToRemove = this.readonlyItems.indexOf(path)
if (indexToRemove !== -1) { if (indexToRemove !== -1) {
this.readonlyItems.splice(indexToRemove, 1) this.readonlyItems.splice(indexToRemove, 1)
} }
}
remove (path) {
this._removeFromReadonlyList(path)
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
if (!this._exists(unprefixedpath)) { if (!this._exists(unprefixedpath)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment