Bug 1291427 - Table headers are not removed when selecting an empty storage r=miker
☠☠ backed out by d3d719ba0691 ☠ ☠
authoravi.mathur <avi.mathur.engg+moz@gmail.com>
Fri, 08 Mar 2019 14:17:27 +0000
changeset 521040 c8a4f2586fc0
parent 521039 b56791a96f96
child 521041 42193ad4cde7
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiker
bugs1291427
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1291427 - Table headers are not removed when selecting an empty storage r=miker Before this change clicking on Storage Type use to show table headers from previous selection. Now clicking on Storage Type will reset table headers also in case empty table headers will get cleared. Differential Revision: https://phabricator.services.mozilla.com/D22327
devtools/client/storage/ui.js
--- a/devtools/client/storage/ui.js
+++ b/devtools/client/storage/ui.js
@@ -75,17 +75,16 @@ const ITEM_NAME_MAX_LENGTH = 32;
  * @param {Target} target
  *        Interface for the page we're debugging
  * @param {Window} panelWin
  *        Window of the toolbox panel to populate UI in.
  */
 class StorageUI {
   constructor(front, target, panelWin, toolbox) {
     EventEmitter.decorate(this);
-
     this._target = target;
     this._window = panelWin;
     this._panelDoc = panelWin.document;
     this._toolbox = toolbox;
     this.front = front;
     this.storageTypes = null;
     this.sidebarToggledOpen = null;
     this.shouldLoadMoreItems = true;
@@ -625,16 +624,18 @@ class StorageUI {
           await this._target.actorHasMethod(type, "removeAllSessionCookies");
 
         await this.resetColumns(type, host, subType);
       }
 
       const {data} = await storageType.getStoreObjects(host, names, fetchOpts);
       if (data.length) {
         await this.populateTable(data, reason);
+      } else {
+        await this.clearHeaders();
       }
       this.updateToolbar();
       this.emit("store-objects-updated");
     } catch (ex) {
       console.error(ex);
     }
   }
 
@@ -648,17 +649,18 @@ class StorageUI {
     // The first node is just a title e.g. "Cookies" so we need to be at least
     // 2 nodes in to show the add button.
     const canAdd = this.actorSupportsAddItem && howManyNodesIn > 1;
 
     if (canAdd) {
       this._addButton.hidden = false;
       this._addButton.setAttribute("tooltiptext",
         L10N.getFormatStr("storage.popupMenu.addItemLabel"));
-    } else {
+    }
+    if (!canAdd || this.table.columns.size < 1) {
       this._addButton.hidden = true;
       this._addButton.removeAttribute("tooltiptext");
     }
   }
 
   /**
    * Populates the storage tree which displays the list of storages present for
    * the page.
@@ -980,26 +982,35 @@ class StorageUI {
     const [type, host] = item;
     this.table.host = host;
     this.table.datatype = type;
 
     this.updateToolbar();
 
     let names = null;
     if (!host) {
+      // If selected item has no host then reset table headers :Bug 1291427
+      await this.clearHeaders();
       return;
     }
     if (item.length > 2) {
       names = [JSON.stringify(item.slice(2))];
     }
     await this.fetchStorageObjects(type, host, names, REASON.POPULATE);
     this.itemOffset = 0;
   }
 
   /**
+   * Clear the column headers in the storage table
+   */
+  async clearHeaders() {
+    this.table.setColumns({}, null, {}, {});
+  }
+
+  /**
    * Resets the column headers in the storage table with the pased object `data`
    *
    * @param {string} type
    *        The type of storage corresponding to the after-reset columns in the
    *        table.
    * @param {string} host
    *        The host name corresponding to the table after reset.
    *