don't display the context menu for folder if !read only && display Copy to browser ifreadonly

pull/1/head
yann300 6 years ago
parent 12508b679f
commit 121ca338f4
  1. 21
      src/app/files/file-explorer.js
  2. 1
      src/app/ui/contextMenu.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) {

@ -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);

Loading…
Cancel
Save