Bug 1368667 - Remove KeyValueTable as it is similar to GenericTable r?chutten draft
authorflyingrub <flyinggrub@gmail.com>
Thu, 01 Jun 2017 12:22:21 +0200
changeset 588286 e65919c33936d78107d359c4065cb6bd377cfa41
parent 588285 bcec035092eb547be315af3925673b53e6f902d6
child 588287 2358f00b529b49b93fcd950b722a5de2857d9308
push id61982
push userbmo:flyinggrub@gmail.com
push dateFri, 02 Jun 2017 13:39:34 +0000
reviewerschutten
bugs1368667
milestone55.0a1
Bug 1368667 - Remove KeyValueTable as it is similar to GenericTable r?chutten GenericTable expect an array of array as data where KeyValueTable used to expect an object. Use explodeObject() to process an object so it can be used by GenericTable. MozReview-Commit-ID: 6hxxFwF2KXg
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1439,82 +1439,16 @@ function RenderObject(aObject) {
   }
   output = "{\"" + keys[0] + "\":\u00A0" + JSON.stringify(aObject[keys[0]]);
   for (let i = 1; i < keys.length; i++) {
     output += ", \"" + keys[i] + "\":\u00A0" + JSON.stringify(aObject[keys[i]]);
   }
   return output + "}";
 }
 
-var KeyValueTable = {
-  /**
-   * Returns a 2-column table with keys and values
-   * @param aMeasurements Each key in this JS object is rendered as a row in
-   *                      the table with its corresponding value
-   * @param aKeysLabel    Column header for the keys column
-   * @param aValuesLabel  Column header for the values column
-   */
-  render: function KeyValueTable_render(aMeasurements, aKeysLabel, aValuesLabel) {
-    let table = document.createElement("table");
-    this.renderHeader(table, aKeysLabel, aValuesLabel);
-    this.renderBody(table, aMeasurements);
-    return table;
-  },
-
-  /**
-   * Create the table header
-   * Tabs & newlines added to cells to make it easier to copy-paste.
-   *
-   * @param aTable Table element
-   * @param aKeysLabel    Column header for the keys column
-   * @param aValuesLabel  Column header for the values column
-   */
-  renderHeader: function KeyValueTable_renderHeader(aTable, aKeysLabel, aValuesLabel) {
-    let headerRow = document.createElement("tr");
-    aTable.appendChild(headerRow);
-
-    let keysColumn = document.createElement("th");
-    keysColumn.appendChild(document.createTextNode(aKeysLabel + "\t"));
-    let valuesColumn = document.createElement("th");
-    valuesColumn.appendChild(document.createTextNode(aValuesLabel + "\n"));
-
-    headerRow.appendChild(keysColumn);
-    headerRow.appendChild(valuesColumn);
-  },
-
-  /**
-   * Create the table body
-   * Tabs & newlines added to cells to make it easier to copy-paste.
-   *
-   * @param aTable Table element
-   * @param aMeasurements Key/value map
-   */
-  renderBody: function KeyValueTable_renderBody(aTable, aMeasurements) {
-    for (let [key, value] of Object.entries(aMeasurements)) {
-      // use .valueOf() to unbox Number, String, etc. objects
-      if (value &&
-         (typeof value == "object") &&
-         (typeof value.valueOf() == "object")) {
-        value = RenderObject(value);
-      }
-
-      let newRow = document.createElement("tr");
-      aTable.appendChild(newRow);
-
-      let keyField = document.createElement("td");
-      keyField.appendChild(document.createTextNode(key + "\t"));
-      newRow.appendChild(keyField);
-
-      let valueField = document.createElement("td");
-      valueField.appendChild(document.createTextNode(value + "\n"));
-      newRow.appendChild(valueField);
-    }
-  }
-};
-
 var GenericTable = {
 
   defaultHeadings: [
     bundle.GetStringFromName("keysHeader"),
     bundle.GetStringFromName("valuesHeader")
   ],
 
   /**