UX: Link post ids in staff action logs to the post

This commit is contained in:
Robin Ward 2018-02-13 15:58:32 -05:00
parent 7348513848
commit 713993d150
3 changed files with 32 additions and 5 deletions

View File

@ -0,0 +1,22 @@
import DiscourseURL from 'discourse/lib/url';
export default Ember.Component.extend({
classNames: ['table', 'staff-actions'],
willDestroyElement() {
this.$().off('click.discourse-staff-logs');
},
didInsertElement() {
this._super();
this.$().on('click.discourse-staff-logs', '[data-link-post-id]', e => {
let postId = $(e.target).attr('data-link-post-id');
this.store.find('post', postId).then(p => {
DiscourseURL.routeTo(p.get('url'));
});
return false;
});
}
});

View File

@ -1,6 +1,7 @@
import { ajax } from 'discourse/lib/ajax';
import AdminUser from 'admin/models/admin-user';
import { escapeExpression } from 'discourse/lib/utilities';
import getUrl from 'discourse-common/lib/get-url';
const StaffActionLog = Discourse.Model.extend({
showFullDetails: false,
@ -10,7 +11,7 @@ const StaffActionLog = Discourse.Model.extend({
}.property('action_name'),
formattedDetails: function() {
var formatted = "";
let formatted = "";
formatted += this.format('email', 'email');
formatted += this.format('admin.logs.ip_address', 'ip_address');
formatted += this.format('admin.logs.topic_id', 'topic_id');
@ -26,9 +27,13 @@ const StaffActionLog = Discourse.Model.extend({
return formatted;
}.property('ip_address', 'email', 'topic_id', 'post_id', 'category_id'),
format: function(label, propertyName) {
format(label, propertyName) {
if (this.get(propertyName)) {
return ('<b>' + I18n.t(label) + ':</b> ' + escapeExpression(this.get(propertyName)) + '<br/>');
let value = escapeExpression(this.get(propertyName));
if (propertyName === 'post_id') {
value = `<a href data-link-post-id="${value}">${value}</a>`;
}
return `<b>${I18n.t(label)}:</b> ${value}<br/>`;
} else {
return '';
}

View File

@ -39,7 +39,7 @@
</div>
<div class="clearfix"></div>
<div class='table staff-actions'>
{{#staff-actions}}
<div class="heading-container">
<div class="col heading first staff_user">{{i18n 'admin.logs.staff_actions.staff_user'}}</div>
<div class="col heading action">{{i18n 'admin.logs.action'}}</div>
@ -86,4 +86,4 @@
{{i18n 'search.no_results'}}
{{/each}}
{{/conditional-loading-spinner}}
</div>
{{/staff-actions}}