Jelajahi Sumber

Fix kernel status indicator to only show busy when it is actually busy.

Jason Grout 6 tahun lalu
induk
melakukan
290c4db00b
1 mengubah file dengan 13 tambahan dan 4 penghapusan
  1. 13 4
      packages/apputils/src/toolbar.tsx

+ 13 - 4
packages/apputils/src/toolbar.tsx

@@ -3,6 +3,8 @@
 
 import { UseSignal, ReactWidget } from './vdom';
 
+import { Kernel } from '@jupyterlab/services';
+
 import { Button } from '@jupyterlab/ui-components';
 
 import { IIterator, find, map, some } from '@phosphor/algorithm';
@@ -400,8 +402,7 @@ export namespace Toolbar {
    * Create a kernel status indicator item.
    *
    * #### Notes
-   * It show display a busy status if the kernel status is
-   * not idle.
+   * It will show a busy status if the kernel status is busy.
    * It will show the current status in the node title.
    * It can handle a change to the context or the kernel.
    */
@@ -679,10 +680,18 @@ namespace Private {
         return;
       }
       let status = session.status;
-      this.toggleClass(TOOLBAR_IDLE_CLASS, status === 'idle');
-      this.toggleClass(TOOLBAR_BUSY_CLASS, status !== 'idle');
+      const busy = this._isBusy(status);
+      this.toggleClass(TOOLBAR_BUSY_CLASS, busy);
+      this.toggleClass(TOOLBAR_IDLE_CLASS, !busy);
       let title = 'Kernel ' + status[0].toUpperCase() + status.slice(1);
       this.node.title = title;
     }
+
+    /**
+     * Check if status should be shown as busy.
+     */
+    private _isBusy(status: Kernel.Status): boolean {
+      return status === 'busy';
+    }
   }
 }