Deduplicate some code for the notifications drop down
This commit is contained in:
parent
9fac7c6107
commit
2d47f144f5
|
@ -1,16 +1,15 @@
|
||||||
import NotificationsButton from 'discourse/components/notifications-button';
|
import MountWidget from 'discourse/components/mount-widget';
|
||||||
|
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
export default NotificationsButton.extend({
|
export default MountWidget.extend({
|
||||||
longDescription: Em.computed.alias('topic.details.notificationReasonText'),
|
widget: 'topic-notifications-button',
|
||||||
hidden: Em.computed.alias('topic.deleted'),
|
|
||||||
notificationLevel: Em.computed.alias('topic.details.notification_level'),
|
|
||||||
i18nPrefix: 'topic.notifications',
|
|
||||||
|
|
||||||
i18nPostfix: function() {
|
buildArgs() {
|
||||||
return this.get('topic.isPrivateMessage') ? '_pm' : '';
|
return { topic: this.get('topic'), appendReason: true, showFullTitle: true };
|
||||||
}.property('topic.isPrivateMessage'),
|
},
|
||||||
|
|
||||||
clicked(id) {
|
@observes('topic.details.notification_level')
|
||||||
this.get('topic.details').updateNotifications(id);
|
_triggerRerender() {
|
||||||
|
this.queueRerender();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,20 +39,37 @@ export default createWidget('topic-notifications-button', {
|
||||||
|
|
||||||
buttonFor(level) {
|
buttonFor(level) {
|
||||||
const details = buttonDetails(level);
|
const details = buttonDetails(level);
|
||||||
return this.attach('button', {
|
|
||||||
className: `btn no-text`,
|
const button = {
|
||||||
|
className: `btn`,
|
||||||
|
label: null,
|
||||||
icon: details.icon,
|
icon: details.icon,
|
||||||
action: 'toggleDropdown',
|
action: 'toggleDropdown',
|
||||||
iconClass: details.key
|
iconClass: details.key
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (this.attrs.showFullTitle) {
|
||||||
|
button.label = `topic.notifications.${details.key}.title`;
|
||||||
|
} else {
|
||||||
|
button.className = 'btn no-text notifications-dropdown';
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.attach('button', button);
|
||||||
},
|
},
|
||||||
|
|
||||||
html(attrs, state) {
|
html(attrs, state) {
|
||||||
const result = [ this.buttonFor(attrs.topic.get('details.notification_level')) ];
|
const details = attrs.topic.get('details');
|
||||||
|
const result = [ this.buttonFor(details.get('notification_level')) ];
|
||||||
|
|
||||||
if (state.expanded) {
|
if (state.expanded) {
|
||||||
result.push(h('ul.dropdown-menu', all.map(l => this.attach('notification-option', l))));
|
result.push(h('ul.dropdown-menu', all.map(l => this.attach('notification-option', l))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attrs.appendReason) {
|
||||||
|
result.push(h('p', details.get('notificationReasonText')));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
//= require ./discourse/views/button
|
//= require ./discourse/views/button
|
||||||
//= require ./discourse/components/dropdown-button
|
//= require ./discourse/components/dropdown-button
|
||||||
//= require ./discourse/components/notifications-button
|
//= require ./discourse/components/notifications-button
|
||||||
//= require ./discourse/components/topic-notifications-button
|
|
||||||
//= require ./discourse/lib/link-mentions
|
//= require ./discourse/lib/link-mentions
|
||||||
//= require ./discourse/components/site-header
|
//= require ./discourse/components/site-header
|
||||||
//= require ./discourse/lib/utilities
|
//= require ./discourse/lib/utilities
|
||||||
|
|
|
@ -436,6 +436,9 @@ a.star {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
.fa-bookmark.bookmarked { color: $tertiary; }
|
.fa-bookmark.bookmarked { color: $tertiary; }
|
||||||
}
|
}
|
||||||
|
.notification-options p {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#suggested-topics {
|
#suggested-topics {
|
||||||
|
|
|
@ -240,3 +240,4 @@ and (max-width : 485px) {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue