diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index b317dade6d..891e5a1692 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -172,6 +172,7 @@ function fileExplorer (localRegistry, files, menuItems) { }) self.treeView.event.register('nodeRightClick', function (key, data, label, event) { + if (self.files.readonly) return if (key === self.files.type) return MENU_HANDLE && MENU_HANDLE.hide(null, true) MENU_HANDLE = contextMenu(event, { @@ -190,17 +191,27 @@ function fileExplorer (localRegistry, files, menuItems) { self.treeView.event.register('leafRightClick', function (key, data, label, event) { if (key === self.files.type) return MENU_HANDLE && MENU_HANDLE.hide(null, true) - MENU_HANDLE = contextMenu(event, { - 'Rename': () => { + let actions = {} + if (!self.files.readonly) { + actions['Rename'] = () => { if (self.files.readonly) { return tooltip('cannot rename file. ' + self.files.type + ' is a read only explorer') } var name = label.querySelector('label[data-path="' + key + '"]') if (name) editModeOn(name) - }, - 'Delete': () => { + } + actions['Delete'] = () => { 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) }, () => {}) } - }) + } + if (self.files.type !== 'browser') { + actions['Copy to Browser explorer'] = () => { + files.get(key, (error, content) => { + if (error) return tooltip(error) + self._deps.fileManager.setFile(`browser/${label.innerText}`, content) + }) + } + } + MENU_HANDLE = contextMenu(event, actions) }) self.treeView.event.register('leafClick', function (key, data, label) { diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 342f9d85f2..19d64c8608 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -189,6 +189,12 @@ class FileManager extends FileSystemApi { this.switchFile() } + unselectCurrentFile () { + this.saveCurrentFile() + this._deps.config.set('currentFile', '') + this.events.emit('noFileSelected') + } + switchFile (file) { const _switchFile = (file) => { this.saveCurrentFile() diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index f6eccd3a7f..9a4d0a3814 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -51,11 +51,11 @@ class EditorPanel { } self.tabProxy = new TabProxy(self._deps.fileManager, self._components.editor, self.appStore, self.appManager) let showApp = function (name) { + self._deps.fileManager.unselectCurrentFile() self.mainPanelComponent.showContent(name) self._view.editor.style.display = 'none' self._components.contextView.hide() self._view.mainPanel.style.display = 'block' - self.tabProxy.sh } self.appManager.event.on('ensureActivated', (name) => { if (name === 'home') { diff --git a/src/app/ui/contextMenu.js b/src/app/ui/contextMenu.js index b4d09a72ec..8052adf5f7 100644 --- a/src/app/ui/contextMenu.js +++ b/src/app/ui/contextMenu.js @@ -7,7 +7,6 @@ var css = csjs` { display: none; position: fixed; - width:100px; border-radius: 2px; z-index: 1000; box-shadow: 0 0 4px var(--dark);