mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
FIX: Don't link to notifications without URLs
This commit is contained in:
@ -14,6 +14,11 @@ export default Ember.Component.extend({
|
|||||||
var notification = this.get('notification'),
|
var notification = this.get('notification'),
|
||||||
text = I18n.t(this.get('scope'), Em.getProperties(notification, 'description', 'username'));
|
text = I18n.t(this.get('scope'), Em.getProperties(notification, 'description', 'username'));
|
||||||
|
|
||||||
|
var url = notification.get('url');
|
||||||
|
if (url) {
|
||||||
buffer.push('<a href="' + notification.get('url') + '">' + text + '</a>');
|
buffer.push('<a href="' + notification.get('url') + '">' + text + '</a>');
|
||||||
|
} else {
|
||||||
|
buffer.push(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -10,13 +10,13 @@ export default Discourse.Controller.extend({
|
|||||||
topic: null,
|
topic: null,
|
||||||
showExtraInfo: null,
|
showExtraInfo: null,
|
||||||
notifications: null,
|
notifications: null,
|
||||||
loading_notifications: null,
|
loadingNotifications: false,
|
||||||
|
|
||||||
showStarButton: function() {
|
showStarButton: function() {
|
||||||
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
|
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
|
||||||
}.property('topic.isPrivateMessage'),
|
}.property('topic.isPrivateMessage'),
|
||||||
|
|
||||||
resetCachedNotifications: function(){
|
_resetCachedNotifications: function(){
|
||||||
// a bit hacky, but if we have no focus, hide notifications first
|
// a bit hacky, but if we have no focus, hide notifications first
|
||||||
var visible = $("#notifications-dropdown").is(":visible");
|
var visible = $("#notifications-dropdown").is(":visible");
|
||||||
|
|
||||||
@ -36,18 +36,16 @@ export default Discourse.Controller.extend({
|
|||||||
|
|
||||||
refreshNotifications: function(){
|
refreshNotifications: function(){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
if (self.get("loadingNotifications")) { return; }
|
||||||
|
|
||||||
if(self.get("loading_notifications")){return;}
|
self.set("loadingNotifications", true);
|
||||||
|
|
||||||
self.set("loading_notifications", true);
|
|
||||||
Discourse.ajax("/notifications").then(function(result) {
|
Discourse.ajax("/notifications").then(function(result) {
|
||||||
self.set('currentUser.unread_notifications', 0);
|
|
||||||
self.setProperties({
|
self.setProperties({
|
||||||
notifications: result,
|
'currentUser.unread_notifications': 0,
|
||||||
loading_notifications: false
|
notifications: result
|
||||||
});
|
});
|
||||||
}, function(){
|
}).finally(function(){
|
||||||
self.set("loading_notifications", false);
|
self.set("loadingNotifications", false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -17,15 +17,18 @@ export default Discourse.ObjectController.extend({
|
|||||||
if (badgeId) {
|
if (badgeId) {
|
||||||
var badgeName = this.safe("data.badge_name");
|
var badgeName = this.safe("data.badge_name");
|
||||||
return '/badges/' + badgeId + '/' + badgeName.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase();
|
return '/badges/' + badgeId + '/' + badgeName.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase();
|
||||||
} else {
|
|
||||||
return Discourse.Utilities.postUrl(this.safe("slug"), this.safe("topic_id"), this.safe("post_number"));
|
|
||||||
}
|
}
|
||||||
}.property("data.@{badge_id, badge_name}", "slug", "topic_id", "post_number"),
|
|
||||||
|
var topicId = this.safe('topic_id');
|
||||||
|
if (topicId) {
|
||||||
|
return Discourse.Utilities.postUrl(this.safe("slug"), topicId, this.safe("post_number"));
|
||||||
|
}
|
||||||
|
}.property("data.{badge_id, badge_name}", "slug", "topic_id", "post_number"),
|
||||||
|
|
||||||
description: function () {
|
description: function () {
|
||||||
var badgeName = this.safe("data.badge_name");
|
var badgeName = this.safe("data.badge_name");
|
||||||
if (badgeName) { return badgeName; }
|
if (badgeName) { return badgeName; }
|
||||||
return this.blank("data.topic_title") ? "" : this.safe("data.topic_title");
|
return this.blank("data.topic_title") ? "" : this.safe("data.topic_title");
|
||||||
}.property("data.@{badge_name, topic_title}")
|
}.property("data.{badge_name, topic_title}")
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
||||||
needs: ['header'],
|
needs: ['header'],
|
||||||
itemController: "notification"
|
loadingNotifications: Em.computed.alias('controllers.header.loadingNotifications')
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<section class="d-dropdown" id="notifications-dropdown">
|
<section class="d-dropdown" id="notifications-dropdown">
|
||||||
{{#unless controllers.header.loading_notifications}}
|
{{#unless loadingNotifications}}
|
||||||
{{#if content}}
|
{{#if content}}
|
||||||
<ul>
|
<ul>
|
||||||
{{#each}}
|
{{#each itemController="notification"}}
|
||||||
{{notification-item notification=this scope=scope}}
|
{{notification-item notification=this scope=scope}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<li class="read last">
|
<li class="read last">
|
||||||
|
@ -5,7 +5,3 @@ moduleFor('controller:notifications', 'controller:notifications', {
|
|||||||
test("mixes in HasCurrentUser", function() {
|
test("mixes in HasCurrentUser", function() {
|
||||||
ok(Discourse.HasCurrentUser.detect(this.subject()));
|
ok(Discourse.HasCurrentUser.detect(this.subject()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("by default uses NotificationController as its item controller", function() {
|
|
||||||
equal(this.subject().get("itemController"), "notification");
|
|
||||||
});
|
|
||||||
|
Reference in New Issue
Block a user