DEV: Use `this.site.get("notification_types")` instead.
Follow up to fcb7422213
.
This commit is contained in:
parent
54db23e4ff
commit
d9d36f241d
|
@ -1,3 +0,0 @@
|
||||||
<% Notification.types.each do |key, value| %>
|
|
||||||
export const <%= key.upcase %>_TYPE = <%= value %>;
|
|
||||||
<% end %>
|
|
|
@ -13,13 +13,6 @@ import { setTransientHeader } from "discourse/lib/ajax";
|
||||||
import { userPath } from "discourse/lib/url";
|
import { userPath } from "discourse/lib/url";
|
||||||
import { iconNode } from "discourse-common/lib/icon-library";
|
import { iconNode } from "discourse-common/lib/icon-library";
|
||||||
|
|
||||||
import {
|
|
||||||
LIKED_TYPE,
|
|
||||||
INVITEE_ACCEPTED_TYPE,
|
|
||||||
GROUP_MESSAGE_SUMMARY_TYPE,
|
|
||||||
LIKED_CONSOLIDATED_TYPE
|
|
||||||
} from "discourse/widgets/concerns/notification-types";
|
|
||||||
|
|
||||||
createWidget("notification-item", {
|
createWidget("notification-item", {
|
||||||
tagName: "li",
|
tagName: "li",
|
||||||
|
|
||||||
|
@ -37,6 +30,7 @@ createWidget("notification-item", {
|
||||||
url() {
|
url() {
|
||||||
const attrs = this.attrs;
|
const attrs = this.attrs;
|
||||||
const data = attrs.data;
|
const data = attrs.data;
|
||||||
|
const notificationTypes = this.site.get("notification_types");
|
||||||
|
|
||||||
const badgeId = data.badge_id;
|
const badgeId = data.badge_id;
|
||||||
if (badgeId) {
|
if (badgeId) {
|
||||||
|
@ -60,11 +54,11 @@ createWidget("notification-item", {
|
||||||
return postUrl(attrs.slug, topicId, attrs.post_number);
|
return postUrl(attrs.slug, topicId, attrs.post_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.notification_type === INVITEE_ACCEPTED_TYPE) {
|
if (attrs.notification_type === notificationTypes.invitee_accepted) {
|
||||||
return userPath(data.display_username);
|
return userPath(data.display_username);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.notification_type === LIKED_CONSOLIDATED_TYPE) {
|
if (attrs.notification_type === notificationTypes.liked_consolidated) {
|
||||||
return userPath(
|
return userPath(
|
||||||
`${this.attrs.username ||
|
`${this.attrs.username ||
|
||||||
this.currentUser
|
this.currentUser
|
||||||
|
@ -97,7 +91,10 @@ createWidget("notification-item", {
|
||||||
|
|
||||||
let title;
|
let title;
|
||||||
|
|
||||||
if (this.attrs.notification_type === LIKED_CONSOLIDATED_TYPE) {
|
if (
|
||||||
|
this.attrs.notification_type ===
|
||||||
|
this.site.get("notification_types").liked_consolidated
|
||||||
|
) {
|
||||||
title = I18n.t("notifications.liked_consolidated_description", {
|
title = I18n.t("notifications.liked_consolidated_description", {
|
||||||
count: parseInt(data.count)
|
count: parseInt(data.count)
|
||||||
});
|
});
|
||||||
|
@ -114,7 +111,9 @@ createWidget("notification-item", {
|
||||||
const scope =
|
const scope =
|
||||||
notName === "custom" ? data.message : `notifications.${notName}`;
|
notName === "custom" ? data.message : `notifications.${notName}`;
|
||||||
|
|
||||||
if (notificationType === GROUP_MESSAGE_SUMMARY_TYPE) {
|
const notificationTypes = this.site.get("notification_types");
|
||||||
|
|
||||||
|
if (notificationType === notificationTypes.group_message_summary) {
|
||||||
const count = data.inbox_count;
|
const count = data.inbox_count;
|
||||||
const group_name = data.group_name;
|
const group_name = data.group_name;
|
||||||
return I18n.t(scope, { count, group_name });
|
return I18n.t(scope, { count, group_name });
|
||||||
|
@ -123,7 +122,7 @@ createWidget("notification-item", {
|
||||||
const username = formatUsername(data.display_username);
|
const username = formatUsername(data.display_username);
|
||||||
const description = this.description();
|
const description = this.description();
|
||||||
|
|
||||||
if (notificationType === LIKED_TYPE && data.count > 1) {
|
if (notificationType === notificationTypes.liked && data.count > 1) {
|
||||||
const count = data.count - 2;
|
const count = data.count - 2;
|
||||||
const username2 = formatUsername(data.username2);
|
const username2 = formatUsername(data.username2);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export const NOTIFICATION_TYPES = <%= Notification.types.to_json %>;
|
|
@ -1,15 +1,12 @@
|
||||||
/*jshint maxlen:10000000 */
|
/*jshint maxlen:10000000 */
|
||||||
import {
|
import { NOTIFICATION_TYPES } from "fixtures/concerns/notification-types";
|
||||||
LIKED_CONSOLIDATED_TYPE,
|
|
||||||
REPLIED_TYPE
|
|
||||||
} from "discourse/widgets/concerns/notification-types";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
"/notifications": {
|
"/notifications": {
|
||||||
notifications: [
|
notifications: [
|
||||||
{
|
{
|
||||||
id: 123,
|
id: 123,
|
||||||
notification_type: REPLIED_TYPE,
|
notification_type: NOTIFICATION_TYPES.replied,
|
||||||
read: false,
|
read: false,
|
||||||
post_number: 2,
|
post_number: 2,
|
||||||
topic_id: 1234,
|
topic_id: 1234,
|
||||||
|
@ -18,7 +15,7 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 456,
|
id: 456,
|
||||||
notification_type: LIKED_CONSOLIDATED_TYPE,
|
notification_type: NOTIFICATION_TYPES.liked_consolidated,
|
||||||
read: false,
|
read: false,
|
||||||
data: { display_username: "aquaman", count: "5" }
|
data: { display_username: "aquaman", count: "5" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { LIKED_CONSOLIDATED_TYPE } from "discourse/widgets/concerns/notification-types";
|
import { NOTIFICATION_TYPES } from "fixtures/concerns/notification-types";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
"site.json": {
|
"site.json": {
|
||||||
|
@ -6,21 +6,7 @@ export default {
|
||||||
default_archetype: "regular",
|
default_archetype: "regular",
|
||||||
disabled_plugins: [],
|
disabled_plugins: [],
|
||||||
shared_drafts_category_id: 24,
|
shared_drafts_category_id: 24,
|
||||||
notification_types: {
|
notification_types: NOTIFICATION_TYPES,
|
||||||
mentioned: 1,
|
|
||||||
replied: 2,
|
|
||||||
quoted: 3,
|
|
||||||
edited: 4,
|
|
||||||
liked: 5,
|
|
||||||
private_message: 6,
|
|
||||||
invited_to_private_message: 7,
|
|
||||||
invitee_accepted: 8,
|
|
||||||
posted: 9,
|
|
||||||
moved_post: 10,
|
|
||||||
linked: 11,
|
|
||||||
granted_badge: 12,
|
|
||||||
liked_consolidated: LIKED_CONSOLIDATED_TYPE
|
|
||||||
},
|
|
||||||
post_types: {
|
post_types: {
|
||||||
regular: 1,
|
regular: 1,
|
||||||
moderator_action: 2,
|
moderator_action: 2,
|
||||||
|
|
Loading…
Reference in New Issue