mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Added support for comment activity feed events
refs https://github.com/TryGhost/Team/issues/1709 - Hides comment events if lab flag is disabled - Hides comment events if comments are disabled
This commit is contained in:
parent
b46a6fb83e
commit
0963da7a2e
@ -1,5 +1,6 @@
|
||||
import Component from '@glimmer/component';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
|
||||
const ALL_EVENT_TYPES = [
|
||||
{event: 'signup_event', icon: 'event-filter-signup', name: 'Signups'},
|
||||
@ -13,11 +14,19 @@ const ALL_EVENT_TYPES = [
|
||||
];
|
||||
|
||||
export default class MembersActivityEventTypeFilter extends Component {
|
||||
@service settings;
|
||||
@service feature;
|
||||
|
||||
get availableEventTypes() {
|
||||
const extended = [...ALL_EVENT_TYPES];
|
||||
if (this.feature.comments && this.settings.get('commentsEnabled') !== 'off') {
|
||||
extended.push({event: 'comment_event', icon: 'event-comment', name: 'Comments'});
|
||||
}
|
||||
|
||||
if (this.args.hiddenEvents?.length) {
|
||||
return ALL_EVENT_TYPES.filter(t => !this.args.hiddenEvents.includes(t.event));
|
||||
return extended.filter(t => !this.args.hiddenEvents.includes(t.event));
|
||||
} else {
|
||||
return ALL_EVENT_TYPES;
|
||||
return extended;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ export const NEWSLETTER_EVENTS = ['newsletter_event'];
|
||||
@classic
|
||||
export default class MembersEventFilter extends Helper {
|
||||
@service settings;
|
||||
@service feature;
|
||||
|
||||
compute(
|
||||
positionalParams,
|
||||
@ -19,6 +20,9 @@ export default class MembersEventFilter extends Helper {
|
||||
if (this.settings.get('editorDefaultEmailRecipients') === 'disabled') {
|
||||
[...EMAIL_EVENTS, ...NEWSLETTER_EVENTS].forEach(type => excludedEventsSet.add(type));
|
||||
}
|
||||
if (!this.feature.comments || this.settings.get('commentsEnabled') === 'off') {
|
||||
excludedEventsSet.add('comment_event');
|
||||
}
|
||||
|
||||
if (excludeEmailEvents) {
|
||||
EMAIL_EVENTS.forEach(type => excludedEventsSet.add(type));
|
||||
|
@ -68,6 +68,10 @@ function getIcon(event) {
|
||||
icon = 'email-delivery-failed';
|
||||
}
|
||||
|
||||
if (event.type === 'comment_event') {
|
||||
icon = 'comment';
|
||||
}
|
||||
|
||||
return 'event-' + icon;
|
||||
}
|
||||
|
||||
@ -123,6 +127,13 @@ function getAction(event) {
|
||||
if (event.type === 'email_failed_event') {
|
||||
return 'failed to receive';
|
||||
}
|
||||
|
||||
if (event.type === 'comment_event') {
|
||||
if (event.data.parent_id) {
|
||||
return 'replied on';
|
||||
}
|
||||
return 'commented on';
|
||||
}
|
||||
}
|
||||
|
||||
function getObject(event, hasMultipleNewsletters) {
|
||||
@ -141,6 +152,18 @@ function getObject(event, hasMultipleNewsletters) {
|
||||
return 'an email';
|
||||
}
|
||||
|
||||
if (event.type === 'subscription_event') {
|
||||
return 'their subscription';
|
||||
}
|
||||
|
||||
if (event.type === 'comment_event') {
|
||||
if (event.data.parent_id) {
|
||||
return 'a comment';
|
||||
}
|
||||
|
||||
return 'a post';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -154,5 +177,12 @@ function getInfo(event) {
|
||||
let symbol = getSymbol(event.data.currency);
|
||||
return `(MRR ${sign}${symbol}${Math.abs(mrrDelta)})`;
|
||||
}
|
||||
|
||||
// TODO: we can include the post title
|
||||
/*if (event.type === 'comment_event') {
|
||||
if (event.data.post) {
|
||||
return event.data.post.title;
|
||||
}
|
||||
}*/
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user