FIX: add title attribute for notifications

This commit is contained in:
Maja Komel 2019-05-27 15:25:27 +02:00 committed by Guo Xiang Tan
parent 6afd7f0eae
commit c9a34aa10c
2 changed files with 38 additions and 4 deletions

View File

@ -147,13 +147,22 @@ createWidget("notification-item", {
html(attrs) {
const notificationType = attrs.notification_type;
const lookup = this.site.get("notificationLookup");
const notName = lookup[notificationType];
const notificationName = lookup[notificationType];
let { data } = attrs;
let infoKey = notName === "custom" ? data.message : notName;
let text = emojiUnescape(this.text(notificationType, notName));
let infoKey =
notificationName === "custom" ? data.message : notificationName;
let text = emojiUnescape(this.text(notificationType, notificationName));
let icon = iconNode(`notification.${infoKey}`);
let title;
if (notificationName) {
title = I18n.t(`notification.titles.${notificationName}`);
} else {
title = "";
}
// We can use a `<p>` tag here once other languages have fixed their HTML
// translations.
let html = new RawHtml({ html: `<div>${text}</div>` });
@ -162,7 +171,11 @@ createWidget("notification-item", {
const href = this.url();
return href
? h("a", { attributes: { href, "data-auto-route": true } }, contents)
? h(
"a",
{ attributes: { href, title, "data-auto-route": true } },
contents
)
: contents;
},

View File

@ -1712,6 +1712,27 @@ en:
confirm_body: "Success! Notifications have been enabled."
custom: "Notification from {{username}} on %{site_title}"
titles:
mentioned: "mentioned"
replied: "new reply"
quoted: "quoted"
edited: "edited"
liked: "new like"
private_message: "new private message"
invited_to_private_message: "invited to private message"
invitee_accepted: "invite accepted"
posted: "new post"
moved_post: "post moved"
linked: "linked"
granted_badge: "badge granted"
invited_to_topic: "invited to topic"
group_mentioned: "group mentioned"
group_message_summary: "new group messages"
watching_first_post: "new topic"
topic_reminder: "topic reminder"
liked_consolidated: "new likes"
post_approved: "post approved"
upload_selector:
title: "Add an image"
title_with_attachments: "Add an image or a file"