mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 20:18:10 +08:00
UX: Link post ids in staff action logs to the post
This commit is contained in:
22
app/assets/javascripts/admin/components/staff-actions.js.es6
Normal file
22
app/assets/javascripts/admin/components/staff-actions.js.es6
Normal 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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -1,6 +1,7 @@
|
|||||||
import { ajax } from 'discourse/lib/ajax';
|
import { ajax } from 'discourse/lib/ajax';
|
||||||
import AdminUser from 'admin/models/admin-user';
|
import AdminUser from 'admin/models/admin-user';
|
||||||
import { escapeExpression } from 'discourse/lib/utilities';
|
import { escapeExpression } from 'discourse/lib/utilities';
|
||||||
|
import getUrl from 'discourse-common/lib/get-url';
|
||||||
|
|
||||||
const StaffActionLog = Discourse.Model.extend({
|
const StaffActionLog = Discourse.Model.extend({
|
||||||
showFullDetails: false,
|
showFullDetails: false,
|
||||||
@ -10,7 +11,7 @@ const StaffActionLog = Discourse.Model.extend({
|
|||||||
}.property('action_name'),
|
}.property('action_name'),
|
||||||
|
|
||||||
formattedDetails: function() {
|
formattedDetails: function() {
|
||||||
var formatted = "";
|
let formatted = "";
|
||||||
formatted += this.format('email', 'email');
|
formatted += this.format('email', 'email');
|
||||||
formatted += this.format('admin.logs.ip_address', 'ip_address');
|
formatted += this.format('admin.logs.ip_address', 'ip_address');
|
||||||
formatted += this.format('admin.logs.topic_id', 'topic_id');
|
formatted += this.format('admin.logs.topic_id', 'topic_id');
|
||||||
@ -26,9 +27,13 @@ const StaffActionLog = Discourse.Model.extend({
|
|||||||
return formatted;
|
return formatted;
|
||||||
}.property('ip_address', 'email', 'topic_id', 'post_id', 'category_id'),
|
}.property('ip_address', 'email', 'topic_id', 'post_id', 'category_id'),
|
||||||
|
|
||||||
format: function(label, propertyName) {
|
format(label, propertyName) {
|
||||||
if (this.get(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 {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
<div class='table staff-actions'>
|
{{#staff-actions}}
|
||||||
<div class="heading-container">
|
<div class="heading-container">
|
||||||
<div class="col heading first staff_user">{{i18n 'admin.logs.staff_actions.staff_user'}}</div>
|
<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>
|
<div class="col heading action">{{i18n 'admin.logs.action'}}</div>
|
||||||
@ -86,4 +86,4 @@
|
|||||||
{{i18n 'search.no_results'}}
|
{{i18n 'search.no_results'}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/conditional-loading-spinner}}
|
{{/conditional-loading-spinner}}
|
||||||
</div>
|
{{/staff-actions}}
|
||||||
|
Reference in New Issue
Block a user