Browse Source

MainAreaWidget attribute name change: ready -> reveal

Jason Grout 7 years ago
parent
commit
dba0b632f8

+ 19 - 19
packages/apputils/src/mainareawidget.ts

@@ -67,12 +67,12 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
     this.title.changed.connect(this._updateContentTitle, this);
     content.disposed.connect(() => this.dispose());
 
-    if (options.ready) {
+    if (options.reveal) {
       layout.addWidget(spinner);
       // Make sure the ready promise is a Promise<void> to avoid leaking any
       // results.
-      this._ready = options.ready.then(() => {
-        this._isReady = true;
+      this._reveal = options.reveal.then(() => {
+        this._isRevealed = true;
         const active = document.activeElement === spinner.node;
         spinner.dispose();
         layout.addWidget(content);
@@ -95,8 +95,8 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
     } else {
       spinner.dispose();
       layout.addWidget(content);
-      this._isReady = true;
-      this._ready = Promise.resolve(void 0);
+      this._isRevealed = true;
+      this._reveal = Promise.resolve(undefined);
     }
   }
 
@@ -111,17 +111,17 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
   readonly toolbar: Toolbar;
 
   /**
-   * Whether the widget is fully populated.
+   * Whether the widget is revealed.
    */
-  get isReady(): boolean {
-    return this._isReady;
+  get isRevealed(): boolean {
+    return this._isRevealed;
   }
 
   /**
-   * A promise that resolves when the widget is fully populated.
+   * A promise that resolves when the widget is ready to be revealed.
    */
-  get ready(): Promise<void> {
-    return this._ready;
+  get reveal(): Promise<void> {
+    return this._reveal;
   }
 
   /**
@@ -139,7 +139,7 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
     case 'mouseup':
     case 'mouseout':
       let target = event.target as HTMLElement;
-      if (this._isReady &&
+      if (this._isRevealed &&
           this.toolbar.node.contains(document.activeElement) &&
           target.tagName !== 'SELECT') {
         this._focusContent();
@@ -170,7 +170,7 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
    * Handle `'activate-request'` messages.
    */
   protected onActivateRequest(msg: Message): void {
-    if (this._isReady) {
+    if (this._isRevealed) {
       this._focusContent();
     } else {
       this._spinner.node.focus();
@@ -239,8 +239,8 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
   private _changeGuard = false;
   private _spinner = new Spinner();
 
-  private _isReady = false;
-  private _ready: Promise<void>;
+  private _isRevealed = false;
+  private _reveal: Promise<void>;
 }
 
 
@@ -265,9 +265,9 @@ namespace MainAreaWidget {
     toolbar?: Toolbar;
 
     /**
-     * An optional promise for when the content is ready to be shown.
+     * An optional promise for when the content is ready to be revealed.
      */
-    ready?: Promise<any>;
+    reveal?: Promise<any>;
   }
 
   /**
@@ -293,9 +293,9 @@ namespace MainAreaWidget {
     toolbar?: Toolbar;
 
     /**
-     * An optional promise for when the content is ready to be shown.
+     * An optional promise for when the content is ready to be revealed.
      */
-    ready?: Promise<any>;
+    reveal?: Promise<any>;
   }
 
 }

+ 8 - 8
packages/csvviewer/src/widget.ts

@@ -72,7 +72,7 @@ class CSVViewer extends Widget {
 
     this._context.ready.then(() => {
       this._updateGrid();
-      this._ready.resolve(undefined);
+      this._reveal.resolve(undefined);
       // Throttle the rendering rate of the widget.
       this._monitor = new ActivityMonitor({
         signal: context.model.contentChanged,
@@ -90,10 +90,10 @@ class CSVViewer extends Widget {
   }
 
   /**
-   * A promise that resolves when the csv viewer is ready.
+   * A promise that resolves when the csv viewer is ready to be revealed.
    */
-  get ready() {
-    return this._ready.promise;
+  get reveal() {
+    return this._reveal.promise;
   }
 
   /**
@@ -145,7 +145,7 @@ class CSVViewer extends Widget {
   private _grid: DataGrid;
   private _monitor: ActivityMonitor<any, any> | null = null;
   private _delimiter = ',';
-  private _ready = new PromiseDelegate<void>();
+  private _reveal = new PromiseDelegate<void>();
 }
 
 
@@ -169,10 +169,10 @@ namespace CSVViewer {
 export
 class CSVDocumentWidget extends DocumentWidget<CSVViewer> {
   constructor(options: CSVDocumentWidget.IOptions) {
-    let {content, context, delimiter, ready, ...other} = options;
+    let {content, context, delimiter, reveal, ...other} = options;
     content = content || Private.createContent(context);
-    ready = Promise.all([ready, content.ready]);
-    super({content, context, ready, ...other});
+    reveal = Promise.all([reveal, content.reveal]);
+    super({content, context, reveal, ...other});
 
     if (delimiter) {
       content.delimiter = delimiter;

+ 2 - 2
packages/docregistry/src/default.ts

@@ -419,8 +419,8 @@ export
 class DocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.IModel = DocumentRegistry.IModel> extends MainAreaWidget<T> implements IDocumentWidget<T, U> {
   constructor(options: DocumentWidget.IOptions<T, U>) {
 
-    // Include the context ready promise in the widget ready promise
-    options.ready = Promise.all([options.ready, options.context.ready]);
+    // Include the context ready promise in the widget reveal promise
+    options.reveal = Promise.all([options.reveal, options.context.ready]);
     super(options);
 
     this.context = options.context;

+ 1 - 1
packages/docregistry/src/registry.ts

@@ -1204,7 +1204,7 @@ interface IDocumentWidget<T extends Widget = Widget, U extends DocumentRegistry.
   /**
    * A promise resolving when the content widget is ready to be revealed.
    */
-  readonly ready: Promise<void>;
+  readonly reveal: Promise<void>;
 
   /**
    * The context associated with the document.

+ 5 - 5
packages/notebook/src/panel.ts

@@ -62,8 +62,8 @@ class NotebookPanel extends DocumentWidget<Notebook, INotebookModel> {
    */
   constructor(options: DocumentWidget.IOptions<Notebook, INotebookModel>) {
     // Set default options
-    const notebookReady = new PromiseDelegate<void>();
-    options.ready = Promise.all([options.ready, notebookReady.promise]);
+    const notebookReveal = new PromiseDelegate<void>();
+    options.reveal = Promise.all([options.reveal, notebookReveal.promise]);
     super(options);
     this._activated = new Signal<this, void>(this);
 
@@ -81,11 +81,11 @@ class NotebookPanel extends DocumentWidget<Notebook, INotebookModel> {
         return;
       }
 
-      // The notebook widget is now ready to be shown.
-      notebookReady.resolve(undefined);
+      // The notebook widget is now ready to be revealed.
+      notebookReveal.resolve(undefined);
     });
 
-    this.ready.then(() => {
+    this.reveal.then(() => {
       // Set the document edit mode on initial open if it looks like a new document.
       if (this.content.widgets.length === 1) {
         let cellModel = this.content.widgets[0].model;

+ 10 - 10
tests/test-docregistry/src/default.spec.ts

@@ -601,23 +601,23 @@ describe('docregistry/default', () => {
 
     });
 
-    describe('#ready', () => {
+    describe('#reveal', () => {
       beforeEach(setup);
 
-      it('should resolve after the ready and context ready promises', async () => {
+      it('should resolve after the reveal and context ready promises', async () => {
         let x = Object.create(null);
-        let ready = sleep(300, x);
+        let reveal = sleep(300, x);
         let contextReady = Promise.all([context.ready, x]);
-        let widget = new DocumentWidget({ context, content, ready: ready});
-        expect(widget.isReady).to.be(false);
+        let widget = new DocumentWidget({ context, content, reveal});
+        expect(widget.isRevealed).to.be(false);
 
-        // Our promise should resolve before the widget ready promise.
-        expect(await Promise.race([widget.ready, ready])).to.be(x);
+        // Our promise should resolve before the widget reveal promise.
+        expect(await Promise.race([widget.reveal, reveal])).to.be(x);
         // The context ready promise should also resolve first.
         context.initialize(true);
-        expect(await Promise.race([widget.ready, contextReady])).to.eql([undefined, x]);
-        // The widget.ready promise should finally resolve.
-        expect(await widget.ready).to.be(undefined);
+        expect(await Promise.race([widget.reveal, contextReady])).to.eql([undefined, x]);
+        // The widget.reveal promise should finally resolve.
+        expect(await widget.reveal).to.be(undefined);
       });
 
     });