mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-04 12:44:57 +03:00
3ce7e241a1
- in the event we don't have a specific icon, I've just chosen to show an `info` one for now
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import Helper from '@ember/component/helper';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class ParseAuditLogEvent extends Helper {
|
|
@service store;
|
|
|
|
compute([ev]) {
|
|
const action = getAction(ev);
|
|
const actionIcon = getActionIcon(ev);
|
|
const getActor = () => this.store.findRecord('user', ev.actor_id, {reload: false});
|
|
const getResource = () => this.store.findRecord(ev.resource_type, ev.resource_id, {reload: false});
|
|
|
|
return {
|
|
get actor() {
|
|
return getActor();
|
|
},
|
|
get resource() {
|
|
return getResource();
|
|
},
|
|
actionIcon,
|
|
action,
|
|
original: ev
|
|
};
|
|
}
|
|
}
|
|
|
|
function getActionIcon(ev) {
|
|
switch (ev.event) {
|
|
case 'added':
|
|
return 'add-stroke';
|
|
case 'edited':
|
|
return 'content';
|
|
case 'deleted':
|
|
return 'cross-circle';
|
|
}
|
|
|
|
return 'info';
|
|
}
|
|
|
|
function getAction(ev) {
|
|
return `${ev.event} ${ev.resource_type}`;
|
|
}
|