Sfoglia il codice sorgente

Fix handling of kernel selector

Steven Silvester 7 anni fa
parent
commit
c895522e0a
1 ha cambiato i file con 8 aggiunte e 16 eliminazioni
  1. 8 16
      packages/apputils/src/clientsession.ts

+ 8 - 16
packages/apputils/src/clientsession.ts

@@ -588,10 +588,15 @@ class ClientSession implements IClientSession {
     if (this.isDisposed) {
       return Promise.resolve(void 0);
     }
-    return Private.selectKernel(this).then(model => {
-      if (this.isDisposed || model === void 0) {
+    return showDialog({
+      title: 'Select Kernel',
+      body: new Private.KernelSelector(this),
+      buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'SELECT' })]
+    }).then(result => {
+      if (this.isDisposed || !result.button.accept) {
         return;
       }
+      let model = result.value;
       if (model === null && this._session) {
         return this.shutdown().then(() => this._kernelChanged.emit(null));
       }
@@ -867,23 +872,10 @@ namespace ClientSession {
  * The namespace for module private data.
  */
 namespace Private {
-  /**
-   * Select a kernel for the session.
-   */
-  export
-  function selectKernel(session: ClientSession): Promise<Kernel.IModel | null> {
-    return showDialog({
-      title: 'Select Kernel',
-      body: new KernelSelector(session),
-      buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'SELECT' })]
-    }).then(result => {
-      return result.value;
-    });
-  }
-
   /**
    * A widget that provides a kernel selection.
    */
+  export
   class KernelSelector extends Widget {
     /**
      * Create a new kernel selector widget.