mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
b916300ceb
fixes https://github.com/TryGhost/Team/issues/2175 - New event type `aggregated_click_event` that is disabled by default in all the existing activity feeds - This returns click events, but only the first click events for each member/post combination. - It includes the total count of unique link clicks for that member on that post combination - Had to resort to some custom knex queries to make this work easily - Requires `@tryghost/bookshelf-pagination@0.1.31`, included in `@tryghost/bookshelf-plugins@0.6.1` (this fixes an issue with custom selects breaking the total count query of pages) - Went a bit overboard with the pagination tests to cover as much unknown edge cases as possible
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
|
|
const eventTypes = {
|
|
sent: ['email_sent_event'],
|
|
opened: ['email_opened_event'],
|
|
clicked: ['aggregated_click_event'],
|
|
feedback: ['feedback_event'],
|
|
conversion: ['subscription_event', 'signup_event']
|
|
};
|
|
|
|
export default class PostActivityFeed extends Component {
|
|
tooltipNode = null;
|
|
_pageSize = 5;
|
|
|
|
get getEventTypes() {
|
|
return eventTypes[this.args.eventType];
|
|
}
|
|
|
|
get pageSize() {
|
|
return this._pageSize;
|
|
}
|
|
|
|
@action
|
|
onTooltipInsert(node) {
|
|
this.tooltipNode = node;
|
|
}
|
|
|
|
@action
|
|
onMouseleave() {
|
|
this.tooltipNode.style.opacity = '0';
|
|
this.tooltipNode.style.position = 'fixed';
|
|
this.tooltipNode.style.left = '2000';
|
|
}
|
|
|
|
get eventType() {
|
|
return this.args.eventType;
|
|
}
|
|
|
|
// calculate amount of empty rows which require to keep table height the same for each tab/page
|
|
@action
|
|
getAmountOfStubs({data}) {
|
|
const stubs = this._pageSize - data.length;
|
|
|
|
return new Array(stubs).fill(1);
|
|
}
|
|
|
|
@action
|
|
isPreviousButtonDisabled({hasReachedStart, isLoading}) {
|
|
return hasReachedStart || isLoading;
|
|
}
|
|
|
|
@action
|
|
isNextButtonDisabled({hasReachedEnd, isLoading}) {
|
|
return hasReachedEnd || isLoading;
|
|
}
|
|
|
|
@action
|
|
isPaginationNotNeeded({totalEvents}) {
|
|
return (totalEvents <= this._pageSize);
|
|
}
|
|
|
|
@action
|
|
areStubsNeeded({totalEvents}) {
|
|
return totalEvents > this._pageSize || this.args.eventType === 'feedback';
|
|
}
|
|
}
|