mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
a605679bfa
closes TryGhost/Team#2143 - All logic for feedback pie chart was spread through multiple files. It would be difficult to scale it. Now it is encapsulated in one file.
55 lines
1.3 KiB
JavaScript
55 lines
1.3 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 {
|
|
_pageSize = 5;
|
|
|
|
get getEventTypes() {
|
|
return eventTypes[this.args.eventType];
|
|
}
|
|
|
|
get pageSize() {
|
|
return this._pageSize;
|
|
}
|
|
|
|
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';
|
|
}
|
|
}
|