Bug 1414447 - Use displayed definitions in toolbox component for kb nav. r=jryans a=gchang
authorEitan Isaacson <eitan@monotonous.org>
Mon, 13 Nov 2017 15:31:00 +0200
changeset 444809 13271ee1aac0e9d4afca5eadee3ef815f73e15e1
parent 444808 8297b7a3b50cdff3cf8eef7ff6698d253f146ab7
child 444810 1dedf706dac630f65d7e677bdad6315f092a624b
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, gchang
bugs1414447
milestone58.0
Bug 1414447 - Use displayed definitions in toolbox component for kb nav. r=jryans a=gchang
devtools/client/framework/components/toolbox-controller.js
devtools/client/framework/toolbox.js
--- a/devtools/client/framework/components/toolbox-controller.js
+++ b/devtools/client/framework/components/toolbox-controller.js
@@ -142,16 +142,20 @@ class ToolboxController extends Componen
     this.updateButtonIds();
   }
 
   setPanelDefinitions(panelDefinitions) {
     this.setState({ panelDefinitions });
     this.updateButtonIds();
   }
 
+  get panelDefinitions() {
+    return this.state.panelDefinitions;
+  }
+
   setToolboxButtons(toolboxButtons) {
     // Listen for updates of the checked attribute.
     this.state.toolboxButtons.forEach(button => {
       button.off("updatechecked", this.state.checkedButtonsUpdated);
     });
     toolboxButtons.forEach(button => {
       button.on("updatechecked", this.state.checkedButtonsUpdated);
     });
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -1920,35 +1920,35 @@ Toolbox.prototype = {
   reloadTarget: function (force) {
     this.target.activeTab.reload({ force: force });
   },
 
   /**
    * Loads the tool next to the currently selected tool.
    */
   selectNextTool: function () {
-    const index = this.panelDefinitions.findIndex(({id}) => id === this.currentToolId);
-    let definition = this.panelDefinitions[index + 1];
+    let definitions = this.component.panelDefinitions;
+    const index = definitions.findIndex(({id}) => id === this.currentToolId);
+    let definition = definitions[index + 1];
     if (!definition) {
-      definition = index === -1
-        ? this.panelDefinitions[0]
-        : this.optionsDefinition;
+      definition = index === -1 ? definitions[0] : this.optionsDefinition;
     }
     return this.selectTool(definition.id);
   },
 
   /**
    * Loads the tool just left to the currently selected tool.
    */
   selectPreviousTool: function () {
-    const index = this.panelDefinitions.findIndex(({id}) => id === this.currentToolId);
-    let definition = this.panelDefinitions[index - 1];
+    let definitions = this.component.panelDefinitions;
+    const index = definitions.findIndex(({id}) => id === this.currentToolId);
+    let definition = definitions[index - 1];
     if (!definition) {
       definition = index === -1
-        ? this.panelDefinitions[this.panelDefinitions.length - 1]
+        ? definitions[definitions.length - 1]
         : this.optionsDefinition;
     }
     return this.selectTool(definition.id);
   },
 
   /**
    * Highlights the tool's tab if it is not the currently selected tool.
    *