瀏覽代碼

Trigger notifyCommandsChanged at the application level.

Ian Rose 7 年之前
父節點
當前提交
862cd654ed

+ 6 - 0
packages/application-extension/src/index.ts

@@ -47,6 +47,12 @@ const main: JupyterLabPlugin<void> = {
   activate: (app: JupyterLab, palette: ICommandPalette) => {
     addCommands(app, palette);
 
+    // If the currently active widget changes,
+    // trigger a refresh of the commands.
+    app.shell.currentChanged.connect(() => {
+      app.commands.notifyCommandChanged(CommandIDs.closeAll);
+    });
+
     let builder = app.serviceManager.builder;
 
     let doBuild = () => {

+ 0 - 7
packages/codemirror-extension/src/index.ts

@@ -150,13 +150,6 @@ function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMe
     }
   });
 
-  // Update the command registry when the codemirror state changes.
-  tracker.currentChanged.connect(() => {
-    if (tracker.size <= 1) {
-      commands.notifyCommandChanged(CommandIDs.changeKeyMap);
-    }
-  });
-
   /**
    * A test for whether the tracker has an active widget.
    */

+ 0 - 7
packages/console-extension/src/index.ts

@@ -146,13 +146,6 @@ function activateConsole(app: JupyterLab, mainMenu: IMainMenu, palette: ICommand
     when: manager.ready
   });
 
-  // Update the command registry when the console state changes.
-  tracker.currentChanged.connect(() => {
-    if (tracker.size <= 1) {
-      commands.notifyCommandChanged(CommandIDs.interrupt);
-    }
-  });
-
   // The launcher callback.
   let callback = (cwd: string, name: string) => {
     return createConsole({ basePath: cwd, kernelPreference: { name } });

+ 0 - 7
packages/imageviewer-extension/src/index.ts

@@ -123,13 +123,6 @@ function addCommands(tracker: IImageTracker, commands: CommandRegistry) {
     return tracker.currentWidget !== null;
   }
 
-  // Update the command registry when the image viewer state changes.
-  tracker.currentChanged.connect(() => {
-    if (tracker.size <= 1) {
-      commands.notifyCommandChanged(CommandIDs.zoomIn);
-    }
-  });
-
   commands.addCommand('imageviewer:zoom-in', {
     execute: zoomIn,
     label: 'Zoom In',

+ 0 - 7
packages/notebook-extension/src/index.ts

@@ -393,13 +393,6 @@ function activateNotebookHandler(app: JupyterLab, mainMenu: IMainMenu, palette:
     when: services.ready
   });
 
-  // Update the command registry when the notebook state changes.
-  tracker.currentChanged.connect(() => {
-    if (tracker.size <= 1) {
-      commands.notifyCommandChanged(CommandIDs.interrupt);
-    }
-  });
-
   let registry = app.docRegistry;
   registry.addModelFactory(new NotebookModelFactory({}));
   registry.addWidgetFactory(factory);

+ 0 - 7
packages/terminal-extension/src/index.ts

@@ -99,13 +99,6 @@ function activate(app: JupyterLab, mainMenu: IMainMenu, palette: ICommandPalette
     name: widget => widget.session && widget.session.name
   });
 
-  // Update the command registry when the terminal state changes.
-  tracker.currentChanged.connect(() => {
-    if (tracker.size <= 1) {
-      commands.notifyCommandChanged(CommandIDs.refresh);
-    }
-  });
-
   addCommands(app, serviceManager, tracker);
 
   // Add some commands to the application view menu.