Bug 1473211 - Stop using string concatenation for string IDs in MeatballMenu; r=jdescottes

Using the full string each time, although more verbose, allows us to easily
search for string IDs and see where they are used.

Differential Revision: https://phabricator.services.mozilla.com/D2590

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Birtles 2018-08-01 13:26:53 +00:00
parent 09eac64963
commit 575af8cffc

View File

@ -15,6 +15,7 @@ const MenuList = createFactory(
const dom = require("devtools/client/shared/vendor/react-dom-factories");
const { hr } = dom;
const { openDocLink } = require("devtools/client/shared/link");
const { assert } = require("devtools/shared/DevToolsUtils");
class MeatballMenu extends PureComponent {
static get propTypes() {
@ -94,14 +95,35 @@ class MeatballMenu extends PureComponent {
// Dock options
for (const hostType of this.props.hostTypes) {
const l10nkey =
hostType.position === "window" ? "separateWindow" : hostType.position;
// This is more verbose than it needs to be but lets us easily search for
// l10n entities.
let l10nkey;
switch (hostType.position) {
case "window":
l10nkey = "toolbox.meatballMenu.dock.separateWindow.label";
break;
case "bottom":
l10nkey = "toolbox.meatballMenu.dock.bottom.label";
break;
case "left":
l10nkey = "toolbox.meatballMenu.dock.left.label";
break;
case "right":
l10nkey = "toolbox.meatballMenu.dock.right.label";
break;
default:
assert(false, `Unexpected hostType.position: ${hostType.position}`);
break;
}
items.push(
MenuItem({
id: `toolbox-meatball-menu-dock-${hostType.position}`,
label: this.props.L10N.getStr(
`toolbox.meatballMenu.dock.${l10nkey}.label`
),
label: this.props.L10N.getStr(l10nkey),
onClick: () => hostType.switchHost(),
checked: hostType.position === this.props.currentHostType,
className: "iconic",
@ -115,14 +137,13 @@ class MeatballMenu extends PureComponent {
// Split console
if (this.props.currentToolId !== "webconsole") {
const l10nkey = this.props.isSplitConsoleActive
? "toolbox.meatballMenu.hideconsole.label"
: "toolbox.meatballMenu.splitconsole.label";
items.push(
MenuItem({
id: "toolbox-meatball-menu-splitconsole",
label: this.props.L10N.getStr(
`toolbox.meatballMenu.${
this.props.isSplitConsoleActive ? "hideconsole" : "splitconsole"
}.label`
),
label: this.props.L10N.getStr(l10nkey),
accelerator: "Esc",
onClick: this.props.toggleSplitConsole,
className: "iconic",