浏览代码

Only enable delete menu item for root nodes

master
Shadowfacts 4 个月前
父节点
当前提交
9e258b71f4
签署人:: Shadowfacts <me@shadowfacts.net> GPG 密钥 ID: 94A5AB95422746E5
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5
    1
      MongoView/View Controllers/QueryViewController.swift

+ 5
- 1
MongoView/View Controllers/QueryViewController.swift 查看文件

@@ -173,7 +173,11 @@ class QueryViewController: NSViewController {
173 173
 extension QueryViewController: NSMenuItemValidation {
174 174
     func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
175 175
         if menuItem.action == #selector(deleteNode(_:)) {
176
-            return outlineView.clickedRow != -1
176
+            if outlineView.clickedRow != -1, let node = outlineView.item(atRow: outlineView.clickedRow) as? Node, node.parent == nil {
177
+                return true
178
+            } else {
179
+                return false
180
+            }
177 181
         }
178 182
         return true
179 183
     }

正在加载...
取消
保存