UX: Link post ids in staff action logs to the post
This commit is contained in:
parent
7348513848
commit
713993d150
|
@ -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;
|
||||
});
|
||||
}
|
||||
});
|
|
@ -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 '';
|
||||
}
|
||||
|
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in New Issue