Skip to content

Commit

Permalink
Bug 1853638 - Fix protections dashboard menu tooltip. r=bvandersloot,…
Browse files Browse the repository at this point in the history
…fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D188449
  • Loading branch information
eemeli committed Sep 20, 2023
1 parent fe2d53e commit 6a03950
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
27 changes: 19 additions & 8 deletions browser/base/content/browser-siteProtections.js
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ var gProtectionsHandler = {
case "browser:purge-session-history":
// We need to update the earliest recorded date if history has been
// cleared.
this._hasEarliestRecord = false;
this._earliestRecordedDate = 0;
this.maybeUpdateEarliestRecordedDateTooltip();
break;
}
Expand Down Expand Up @@ -2290,11 +2290,22 @@ var gProtectionsHandler = {
},

setTrackersBlockedCounter(trackerCount) {
document.l10n.setAttributes(
this._protectionsPopupTrackersCounterDescription,
"protections-footer-blocked-tracker-counter",
{ trackerCount, date: 0 }
);
if (this._earliestRecordedDate) {
document.l10n.setAttributes(
this._protectionsPopupTrackersCounterDescription,
"protections-footer-blocked-tracker-counter",
{ trackerCount, date: this._earliestRecordedDate }
);
} else {
document.l10n.setAttributes(
this._protectionsPopupTrackersCounterDescription,
"protections-footer-blocked-tracker-counter-no-tooltip",
{ trackerCount }
);
this._protectionsPopupTrackersCounterDescription.removeAttribute(
"tooltiptext"
);
}

// Show the counter if the number of tracker is not zero.
this._protectionsPopupTrackersCounterBox.toggleAttribute(
Expand Down Expand Up @@ -2588,7 +2599,7 @@ var gProtectionsHandler = {
async maybeUpdateEarliestRecordedDateTooltip(trackerCount) {
// If we've already updated or the popup isn't in the DOM yet, don't bother
// doing this:
if (this._hasEarliestRecord || !this._protectionsPopup) {
if (this._earliestRecordedDate || !this._protectionsPopup) {
return;
}

Expand All @@ -2605,7 +2616,7 @@ var gProtectionsHandler = {
"protections-footer-blocked-tracker-counter",
{ trackerCount, date }
);
this._hasEarliestRecord = true;
this._earliestRecordedDate = date;
}
},
};
8 changes: 8 additions & 0 deletions browser/locales/en-US/browser/siteProtections.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ protections-footer-blocked-tracker-counter =
*[other] { $trackerCount } Blocked
}
.tooltiptext = Since { DATETIME($date, year: "numeric", month: "long", day: "numeric") }
# This text indicates the total number of trackers blocked on all sites.
# It should be the same as protections-footer-blocked-tracker-counter;
# this message is used to leave out the tooltip when the date is not available.
protections-footer-blocked-tracker-counter-no-tooltip =
{ $trackerCount ->
[one] { $trackerCount } Blocked
*[other] { $trackerCount } Blocked
}
# In English this looks like "Firefox blocked over 10,000 trackers since October 2019"
protections-milestone =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

import fluent.syntax.ast as FTL
from fluent.migrate.transforms import COPY_PATTERN


def migrate(ctx):
"""Bug 1853638 - Fix protections dashboard menu tooltip, part {index}."""

file = "browser/browser/siteProtections.ftl"
ctx.add_transforms(
file,
file,
[
FTL.Message(
id=FTL.Identifier(
"protections-footer-blocked-tracker-counter-no-tooltip"
),
value=COPY_PATTERN(file, "protections-footer-blocked-tracker-counter"),
),
],
)

0 comments on commit 6a03950

Please sign in to comment.