From 48c0102d17623432ee3a2dce669de780ddda7b3b Mon Sep 17 00:00:00 2001 From: ganna Date: Thu, 6 Jul 2023 19:21:59 +0000 Subject: [PATCH] Bug 1825792 - Use moz-support-link in the addon abuse report dialog r=extension-reviewers,fluent-reviewers,tgiles,flod,robwu Differential Revision: https://phabricator.services.mozilla.com/D180505 --- .../bug_1825792_abuse_report_panel.py | 56 +++++++++++++++++++ .../en-US/toolkit/about/abuseReports.ftl | 5 +- .../content/abuse-report-frame.html | 18 ++++-- .../extensions/content/abuse-report-panel.js | 17 +----- .../test/browser/browser_html_abuse_report.js | 15 ++++- 5 files changed, 84 insertions(+), 27 deletions(-) create mode 100644 python/l10n/fluent_migrations/bug_1825792_abuse_report_panel.py diff --git a/python/l10n/fluent_migrations/bug_1825792_abuse_report_panel.py b/python/l10n/fluent_migrations/bug_1825792_abuse_report_panel.py new file mode 100644 index 000000000000..c00ced6bbf8f --- /dev/null +++ b/python/l10n/fluent_migrations/bug_1825792_abuse_report_panel.py @@ -0,0 +1,56 @@ +# 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 TransformPattern + + +class STRIP_LEARNMORE(TransformPattern): + # Used to remove `SOME TEXT` from a string + def visit_TextElement(self, node): + link_start = node.value.find('') + if link_start != -1: + # Replace string up to the link, remove remaining spaces afterwards. + # Removing an extra character directly is not safe, as it could be + # punctuation. + node.value = node.value[:link_start].rstrip() + + return node + + +class EXTRACT_LEARNMORE(TransformPattern): + # Used to extract SOME TEXT from `SOME TEXT` + def visit_TextElement(self, node): + text_start = node.value.find(">") + 1 + text_end = node.value.find("") + if text_start != -1 and text_end != -1: + node.value = node.value[text_start:text_end].strip() + + return node + + +def migrate(ctx): + """Bug 1825792 - Use moz-support-link in the addon abuse report dialog, part {index}.""" + + abuse_reports = "toolkit/toolkit/about/abuseReports.ftl" + ctx.add_transforms( + abuse_reports, + abuse_reports, + [ + FTL.Message( + id=FTL.Identifier("abuse-report-learnmore-intro"), + value=STRIP_LEARNMORE( + abuse_reports, + "abuse-report-learnmore", + ), + ), + FTL.Message( + id=FTL.Identifier("abuse-report-learnmore-link"), + value=EXTRACT_LEARNMORE( + abuse_reports, + "abuse-report-learnmore", + ), + ), + ], + ) diff --git a/toolkit/locales/en-US/toolkit/about/abuseReports.ftl b/toolkit/locales/en-US/toolkit/about/abuseReports.ftl index d565bd05cd2e..4cccf78dd11d 100644 --- a/toolkit/locales/en-US/toolkit/about/abuseReports.ftl +++ b/toolkit/locales/en-US/toolkit/about/abuseReports.ftl @@ -18,9 +18,8 @@ abuse-report-subtitle = What’s the issue? # $author-name (string) - Name of the add-on author abuse-report-addon-authored-by = by { $author-name } -abuse-report-learnmore = - Unsure what issue to select? - Learn more about reporting extensions and themes +abuse-report-learnmore-intro = Unsure what issue to select? +abuse-report-learnmore-link = Learn more about reporting extensions and themes abuse-report-submit-description = Describe the problem (optional) abuse-report-textarea = diff --git a/toolkit/mozapps/extensions/content/abuse-report-frame.html b/toolkit/mozapps/extensions/content/abuse-report-frame.html index 03285fb1650b..e487749c9299 100644 --- a/toolkit/mozapps/extensions/content/abuse-report-frame.html +++ b/toolkit/mozapps/extensions/content/abuse-report-frame.html @@ -20,6 +20,10 @@ +