Przeglądaj źródła

Clean up directory context menu

Steven Silvester 7 lat temu
rodzic
commit
e5f678772d
1 zmienionych plików z 16 dodań i 10 usunięć
  1. 16 10
      packages/filebrowser-extension/src/index.ts

+ 16 - 10
packages/filebrowser-extension/src/index.ts

@@ -392,21 +392,27 @@ function createContextMenu(model: Contents.IModel, commands: CommandRegistry, re
 
   menu.addItem({ command: CommandIDs.open });
 
-  const factories = registry.preferredWidgetFactories(path).map(f => f.name);
-  if (path && factories.length > 1) {
-    const command =  'docmanager:open';
-    const openWith = new Menu({ commands });
-    openWith.title.label = 'Open With...';
-    factories.forEach(factory => {
-      openWith.addItem({ args: { factory, path }, command });
-    });
-    menu.addItem({ type: 'submenu', submenu: openWith });
+  if (model.type !== 'directory') {
+    const factories = registry.preferredWidgetFactories(path).map(f => f.name);
+    if (path && factories.length > 1) {
+      const command =  'docmanager:open';
+      const openWith = new Menu({ commands });
+      openWith.title.label = 'Open With...';
+      factories.forEach(factory => {
+        openWith.addItem({ args: { factory, path }, command });
+      });
+      menu.addItem({ type: 'submenu', submenu: openWith });
+    }
   }
 
   menu.addItem({ command: CommandIDs.rename });
   menu.addItem({ command: CommandIDs.del });
   menu.addItem({ command: CommandIDs.cut });
-  menu.addItem({ command: CommandIDs.copy });
+
+  if (model.type !== 'directory') {
+    menu.addItem({ command: CommandIDs.copy });
+  }
+
   menu.addItem({ command: CommandIDs.paste });
 
   if (model.type !== 'directory') {