Bug 1444301 - Add help items to menu; r?jryans draft
authorBrian Birtles <birtles@gmail.com>
Thu, 05 Apr 2018 10:13:22 +0900
changeset 777593 0da3cca42ba95214d77472f87077d839aca88c4a
parent 777592 28596775282ff36da4b5dff446b5bbb1a01abacc
child 777594 12f15d8d2a1c34e1d76aee91ea223b96ea8e66c2
push id105256
push userbmo:bbirtles@mozilla.com
push dateThu, 05 Apr 2018 01:56:46 +0000
reviewersjryans
bugs1444301
milestone61.0a1
Bug 1444301 - Add help items to menu; r?jryans MozReview-Commit-ID: PwW9OK8eOV
devtools/client/framework/components/toolbox-toolbar.js
devtools/client/locales/en-US/toolbox.properties
--- a/devtools/client/framework/components/toolbox-toolbar.js
+++ b/devtools/client/framework/components/toolbox-toolbar.js
@@ -341,15 +341,59 @@ function showToolboxMenu(
   // Settings
   menu.append(new MenuItem({
     id: "toolbox-menu-settings",
     label: L10N.getStr("toolbox.menu.settings.label"),
     accelerator: L10N.getStr("toolbox.help.key"),
     click: () => selectTool("options"),
   }));
 
+  if (menu.items.length) {
+    menu.append(new MenuItem({ type: "separator" }));
+  }
+
+  // REVIEWER: Should this logic be factored out somewhere common? Where?
+  // Should we prefer the implementation in dom-panel.js::openLink?
+  // https://searchfox.org/mozilla-central/rev/a0665934fa05158a5a943d4c8b277465910c029c/devtools/client/dom/dom-panel.js#181-186
+  const openLink = url => {
+    const parentDoc = toolbox.doc;
+    if (!parentDoc) {
+      return;
+    }
+
+    const win = parentDoc.querySelector("window");
+    if (!win) {
+      return;
+    }
+
+    const top = win.ownerDocument.defaultView.top;
+    if (!top || typeof top.openUILinkIn !== "function") {
+      return;
+    }
+
+    top.openUILinkIn(url, "tab");
+  };
+
+  // Getting started
+  menu.append(new MenuItem({
+    id: "toolbox-menu-gettingstarted",
+    label: L10N.getStr("toolbox.menu.gettingStarted.label"),
+    click: evt => {
+      openLink("https://developer.mozilla.org/docs/Tools");
+    },
+  }));
+
+  // Give feedback
+  menu.append(new MenuItem({
+    id: "toolbox-menu-feedback",
+    label: L10N.getStr("toolbox.menu.giveFeedback.label"),
+    click: () => {
+      openLink("https://discourse.mozilla.org/c/devtools");
+    },
+  }));
+
   const rect = menuButton.getBoundingClientRect();
   const screenX = menuButton.ownerDocument.defaultView.mozInnerScreenX;
   const screenY = menuButton.ownerDocument.defaultView.mozInnerScreenY;
 
   // Display the popup below the button.
   menu.popup(rect.left + screenX, rect.bottom + screenY, toolbox);
 }
--- a/devtools/client/locales/en-US/toolbox.properties
+++ b/devtools/client/locales/en-US/toolbox.properties
@@ -171,16 +171,22 @@ toolbox.menu.hideconsole.label=Hide cons
 toolbox.menu.noautohide.label=Disable popup auto-hide
 
 # LOCALIZATION NOTE (toolbox.menu.settings.label): This is the label for the
 # item in the "..." menu in the toolbox that brings up the Settings (Options)
 # panel.
 # The keyboard shortcut will be shown to the side of the label.
 toolbox.menu.settings.label=Settings
 
+# LOCALIZATION NOTE (toolbox.menu.gettingStarted.label): This is the label for the
+toolbox.menu.gettingStarted.label=Getting started
+
+# LOCALIZATION NOTE (toolbox.menu.giveFeedback.label): This is the label for the
+toolbox.menu.giveFeedback.label=Give feedback
+
 # LOCALIZATION NOTE (toolbox.closebutton.tooltip): This is the tooltip for
 # the close button the developer tools toolbox.
 toolbox.closebutton.tooltip=Close Developer Tools
 
 # LOCALIZATION NOTE (toolbox.allToolsButton.tooltip): This is the tooltip for the
 # "all tools" button displayed when some tools are hidden by overflow of the toolbar.
 toolbox.allToolsButton.tooltip=Select another tool