Bug 1712033 - Fix text wrap in identity warning notification. r=mkmelin,darktrojan
authorAlessandro Castellani <alessandro@thunderbird.net>
Wed, 26 May 2021 13:19:43 +0300
changeset 42515 27585f222900ca0c0e155a56bc47413b9722e327
parent 42514 608510dc5b9284dce94b99e329debaab05170ecb
child 42516 e0d24a8aa6283462bd8ad2ddbe10f7f7cc0eb68a
push id3121
push usertbbld-merge
push dateMon, 31 May 2021 21:07:04 +0000
treeherdercomm-beta@a02c59e58d79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, darktrojan
bugs1712033
Bug 1712033 - Fix text wrap in identity warning notification. r=mkmelin,darktrojan Differential Revision: https://phabricator.services.mozilla.com/D115663
mail/components/compose/content/MsgComposeCommands.js
mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties
mail/locales/en-US/messenger/messengercompose/messengercompose.ftl
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -9575,38 +9575,38 @@ var gComposeNotificationBar = {
       gComposeNotification.getNotificationWithValue("blockedContent")
     );
   },
 
   clearNotifications(aValue) {
     gComposeNotification.removeAllNotifications(true);
   },
 
-  setIdentityWarning(aIdentityName) {
-    if (!gComposeNotification.getNotificationWithValue("identityWarning")) {
-      let text = getComposeBundle()
-        .getString("identityWarning")
-        .split("%S");
-      let label = new DocumentFragment();
-      label.appendChild(document.createTextNode(text[0]));
-      label.appendChild(
-        document.createElementNS("http://www.w3.org/1999/xhtml", "b")
-      );
-      label.lastElementChild.appendChild(
-        document.createTextNode(aIdentityName)
-      );
-      label.appendChild(document.createTextNode(text[1]));
-      gComposeNotification.appendNotification(
-        label,
-        "identityWarning",
-        null,
-        gComposeNotification.PRIORITY_WARNING_HIGH,
-        null
-      );
-    }
+  /**
+   * Show a warning notification when a newly typed identity in the Form field
+   * doesn't match any existing identity.
+   *
+   * @param {string} identity - The name of the identity to add to the
+   *   notification. Most likely an email address.
+   */
+  async setIdentityWarning(identity) {
+    // Bail out if we are already showing this type of notification.
+    if (gComposeNotification.getNotificationWithValue("identityWarning")) {
+      return;
+    }
+
+    gComposeNotification.appendNotification(
+      await document.l10n.formatValue("compose-missing-identity-warning", {
+        identity,
+      }),
+      "identityWarning",
+      null,
+      gComposeNotification.PRIORITY_WARNING_HIGH,
+      null
+    );
   },
 
   clearIdentityWarning() {
     let idWarning = gComposeNotification.getNotificationWithValue(
       "identityWarning"
     );
     if (idWarning) {
       gComposeNotification.removeNotification(idWarning);
--- a/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties
+++ b/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties
@@ -467,20 +467,16 @@ blockedAllowResource=Unblock %S
 blockedContentMessage=%S has blocked a file from loading into this message. Unblocking the file will include it in your sent message.;%S has blocked some files from loading into this message. Unblocking a file will include it in your sent message.
 
 blockedContentPrefLabel=Options
 blockedContentPrefAccesskey=O
 
 blockedContentPrefLabelUnix=Preferences
 blockedContentPrefAccesskeyUnix=P
 
-## Identity matching warning notification bar.
-## LOCALIZATION NOTE(identityWarning): %S will be replaced with the identity name.
-identityWarning=A unique identity matching the From address was not found. The message will be sent using the current From field and settings from identity %S.
-
 ## Recipient pills fields.
 ## LOCALIZATION NOTE(confirmRemoveRecipientRowTitle2): %S will be replaced with the field name.
 confirmRemoveRecipientRowTitle2=Remove %S Addresses
 ## LOCALIZATION NOTE(confirmRemoveRecipientRowBody2): %S will be replaced with the field name.
 confirmRemoveRecipientRowBody2=Are you sure you want to remove the %S addresses?
 confirmRemoveRecipientRowButton=Remove
 
 ## LOCALIZATION NOTE headersSpaceStyle is for aligning label of a newly create recipient row.
--- a/mail/locales/en-US/messenger/messengercompose/messengercompose.ftl
+++ b/mail/locales/en-US/messenger/messengercompose/messengercompose.ftl
@@ -162,8 +162,14 @@ many-public-recipients-info = The {$count} recipients in To and Cc will see each other’s address. You can avoid disclosing recipients by using Bcc instead.
 
 many-public-recipients-bcc =
   .label = Use Bcc Instead
   .accesskey = U
 
 many-public-recipients-ignore =
   .label = Keep Recipients Public
   .accesskey  = K
+
+## Notifications
+
+# Variables:
+# $identity (string) - The name of the used identity, most likely an email address.
+compose-missing-identity-warning = A unique identity matching the From address was not found. The message will be sent using the current From field and settings from identity { $identity }.