Bug 1444301 - Add help items to menu; r=jryans
authorBrian Birtles <birtles@gmail.com>
Thu, 05 Apr 2018 10:13:22 +0900
changeset 778795 4abc98b602917c64f3fe7465fe580275cf42d581
parent 778794 9140b553db46cc8d8fcd39ef30a74d68649fb780
child 778796 154ca4e5a0d2ef9e3d8b0f4d23c804496eff7b47
push id105582
push userkgupta@mozilla.com
push dateFri, 06 Apr 2018 21:31:13 +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
devtools/client/shared/link.js
devtools/client/shared/moz.build
--- a/devtools/client/framework/components/toolbox-toolbar.js
+++ b/devtools/client/framework/components/toolbox-toolbar.js
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 const { Component, createFactory } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 const {div, button} = dom;
+const {openLink} = require("devtools/client/shared/link");
 
 const Menu = require("devtools/client/framework/menu");
 const MenuItem = require("devtools/client/framework/menu-item");
 const ToolboxTab = createFactory(require("devtools/client/framework/components/toolbox-tab"));
 const ToolboxTabs = createFactory(require("devtools/client/framework/components/toolbox-tabs"));
 
 /**
  * This is the overall component for the toolbox toolbar. It is designed to not know how
@@ -358,15 +359,37 @@ function showMeatballMenu(
   // Settings
   menu.append(new MenuItem({
     id: "toolbox-meatball-menu-settings",
     label: L10N.getStr("toolbox.meatballMenu.settings.label"),
     accelerator: L10N.getStr("toolbox.help.key"),
     click: () => selectTool("options"),
   }));
 
+  if (menu.items.length) {
+    menu.append(new MenuItem({ type: "separator" }));
+  }
+
+  // Getting started
+  menu.append(new MenuItem({
+    id: "toolbox-meatball-menu-gettingstarted",
+    label: L10N.getStr("toolbox.meatballMenu.gettingStarted.label"),
+    click: () => {
+      openLink("https://developer.mozilla.org/docs/Tools", toolbox);
+    },
+  }));
+
+  // Give feedback
+  menu.append(new MenuItem({
+    id: "toolbox-meatball-menu-feedback",
+    label: L10N.getStr("toolbox.meatballMenu.giveFeedback.label"),
+    click: () => {
+      openLink("https://discourse.mozilla.org/c/devtools", toolbox);
+    },
+  }));
+
   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
@@ -168,16 +168,24 @@ toolbox.meatballMenu.hideconsole.label=H
 toolbox.meatballMenu.noautohide.label=Disable popup auto-hide
 
 # LOCALIZATION NOTE (toolbox.meatballMenu.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.meatballMenu.settings.label=Settings
 
+# LOCALIZATION NOTE (toolbox.meatballMenu.gettingStarted.label): This is the
+# label for the Getting Started menu item.
+toolbox.meatballMenu.gettingStarted.label=Getting started
+
+# LOCALIZATION NOTE (toolbox.meatballMenu.giveFeedback.label): This is the label
+# for the Give feedback menu item.
+toolbox.meatballMenu.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
 
new file mode 100644
--- /dev/null
+++ b/devtools/client/shared/link.js
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+/**
+ * Opens |url| in a new tab.
+ */
+exports.openLink = async function(url, toolbox) {
+  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");
+};
--- a/devtools/client/shared/moz.build
+++ b/devtools/client/shared/moz.build
@@ -31,16 +31,17 @@ DevToolsModules(
     'DOMHelpers.jsm',
     'doorhanger.js',
     'enum.js',
     'file-saver.js',
     'getjson.js',
     'inplace-editor.js',
     'key-shortcuts.js',
     'keycodes.js',
+    'link.js',
     'natural-sort.js',
     'network-throttling-profiles.js',
     'node-attribute-parser.js',
     'options-view.js',
     'output-parser.js',
     'poller.js',
     'prefs.js',
     'react-utils.js',