2022-10-21 11:31:25 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
2022-11-28 16:43:35 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2022-10-21 11:31:25 +03:00
|
|
|
|
|
|
|
export default class PostActivityFeed extends Component {
|
2022-11-28 16:43:35 +03:00
|
|
|
@service feature;
|
|
|
|
|
2022-10-21 11:31:25 +03:00
|
|
|
_pageSize = 5;
|
2022-11-28 16:43:35 +03:00
|
|
|
_eventTypes = {
|
|
|
|
sent: this.feature.get('suppressionList')
|
|
|
|
? ['email_sent_event', 'email_delivered_event', 'email_failed_event']
|
|
|
|
: ['email_sent_event'],
|
|
|
|
opened: ['email_opened_event'],
|
|
|
|
clicked: ['aggregated_click_event'],
|
|
|
|
feedback: ['feedback_event'],
|
|
|
|
conversion: ['subscription_event', 'signup_event']
|
|
|
|
};
|
2022-10-21 11:31:25 +03:00
|
|
|
|
|
|
|
get getEventTypes() {
|
2022-11-28 16:43:35 +03:00
|
|
|
return this._eventTypes[this.args.eventType];
|
2022-10-21 11:31:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get pageSize() {
|
|
|
|
return this._pageSize;
|
|
|
|
}
|
|
|
|
|
2022-10-21 19:33:37 +03:00
|
|
|
get eventType() {
|
|
|
|
return this.args.eventType;
|
|
|
|
}
|
|
|
|
|
2022-10-21 11:31:25 +03:00
|
|
|
// 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;
|
|
|
|
}
|
2022-10-25 14:55:03 +03:00
|
|
|
|
|
|
|
@action
|
2022-10-25 18:59:29 +03:00
|
|
|
isPaginationNotNeeded({totalEvents}) {
|
2022-10-25 14:55:03 +03:00
|
|
|
return (totalEvents <= this._pageSize);
|
|
|
|
}
|
2022-10-25 18:59:29 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
areStubsNeeded({totalEvents}) {
|
|
|
|
return totalEvents > this._pageSize || this.args.eventType === 'feedback';
|
|
|
|
}
|
2022-10-21 11:31:25 +03:00
|
|
|
}
|