Bug 1306781 - New console frontend: Add title on repeat element. r=linclark

MozReview-Commit-ID: L10G6ShRuXR
This commit is contained in:
Nicolas Chevobbe 2016-10-02 15:16:49 -07:00
parent b1b922dcdb
commit 602cb980ef
4 changed files with 30 additions and 1 deletions

View File

@ -12,6 +12,8 @@ const {
DOM: dom,
PropTypes
} = require("devtools/client/shared/vendor/react");
const { PluralForm } = require("devtools/shared/plural-form");
const { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages");
MessageRepeat.displayName = "MessageRepeat";
@ -22,7 +24,13 @@ MessageRepeat.propTypes = {
function MessageRepeat(props) {
const { repeat } = props;
const visibility = repeat > 1 ? "visible" : "hidden";
return dom.span({className: "message-repeats", style: {visibility}}, repeat);
return dom.span({
className: "message-repeats",
style: {visibility},
title: PluralForm.get(repeat, l10n.getStr("messageRepeats.tooltip2"))
.replace("#1", repeat)
}, repeat);
}
module.exports = MessageRepeat;

View File

@ -41,6 +41,7 @@ describe("ConsoleAPICall component:", () => {
const wrapper = render(ConsoleApiCall({ message, onViewSourceInDebugger }));
expect(wrapper.find(".message-repeats").text()).toBe("107");
expect(wrapper.find(".message-repeats").prop("title")).toBe("107 repeats");
expect(wrapper.find("span > span.message-flex-body > span.message-body.devtools-monospace + span.message-repeats").length).toBe(1);
});

View File

@ -0,0 +1,18 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
module.exports = {
PluralForm: {
get: function (occurence, str) {
// @TODO Remove when loading the actual strings from webconsole.properties
// is done in the L10n fixture.
if (str === "messageRepeats.tooltip2") {
return `${occurence} repeats`;
}
return str;
}
}
};

View File

@ -27,6 +27,8 @@ requireHacker.global_hook("default", path => {
return `module.exports = require("devtools/client/webconsole/new-console-output/test/fixtures/WebConsoleUtils")`;
case "devtools/shared/l10n":
return `module.exports = require("devtools/client/webconsole/new-console-output/test/fixtures/LocalizationHelper")`;
case "devtools/shared/plural-form":
return `module.exports = require("devtools/client/webconsole/new-console-output/test/fixtures/PluralForm")`;
case "Services":
case "Services.default":
return `module.exports = require("devtools/client/webconsole/new-console-output/test/fixtures/Services")`;