92ece7b373
refs https://github.com/TryGhost/Team/issues/1277 - renamed `<GhActivityTimeline>` to `<GhMemberActivityEventParser>` and modified so that it yields parsed events rather than directly renders them - makes the component re-usable as it can be used to decorate raw events ready for use in context-specific templates - switches to using a getter to yield the parsed events so that they will update automatically when the `@events` argument changes - updated `<Dashboard::LatestMemberActivity>` to use `<GhMemberActivityEventParser>` and keep the member activity box output local to itself - added integration tests for `<Dashboard::LatestMemberActivity>` - added Mirage setup for member activity event models/serializers/route
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import BaseSerializer from './application';
|
|
|
|
export default BaseSerializer.extend({
|
|
embed: true,
|
|
|
|
keyForCollection() {
|
|
return 'events';
|
|
},
|
|
|
|
include() {
|
|
// these are always embedded but will be moved onto the `data` object in the serializer
|
|
return ['member', 'email'];
|
|
},
|
|
|
|
serialize() {
|
|
const serialized = BaseSerializer.prototype.serialize.call(this, ...arguments);
|
|
|
|
const events = serialized.events.map((serializedEvent) => {
|
|
const data = Object.assign({}, serializedEvent.data, {
|
|
id: serializedEvent.id,
|
|
created_at: serializedEvent.created_at
|
|
});
|
|
|
|
if (serializedEvent.member) {
|
|
data.member = serializedEvent.member;
|
|
data.member_id = serializedEvent.member_id;
|
|
}
|
|
|
|
if (serializedEvent.email) {
|
|
data.email = serializedEvent.email;
|
|
data.email_id = serializedEvent.email_id;
|
|
}
|
|
|
|
return {
|
|
type: serializedEvent.type,
|
|
data
|
|
};
|
|
});
|
|
|
|
return {events};
|
|
}
|
|
});
|