mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FEATURE: add a button on admin user page that links to action log
This commit is contained in:
parent
b19dfba497
commit
046cbad10b
@ -8,7 +8,6 @@ export default Discourse.Route.extend({
|
||||
|
||||
setupController: function(controller) {
|
||||
controller.resetFilters();
|
||||
controller.refresh();
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -28,6 +28,13 @@ export default Discourse.Route.extend({
|
||||
showSuspendModal(model) {
|
||||
showModal('admin-suspend-user', { model, admin: true });
|
||||
this.controllerFor('modal').set('modalClass', 'suspend-user-modal');
|
||||
},
|
||||
|
||||
viewActionLogs(username) {
|
||||
const controller = this.controllerFor('adminLogs.staffActionLogs')
|
||||
this.transitionTo('adminLogs.staffActionLogs').then(() => {
|
||||
controller._changeFilters({ acting_user: username });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -7,6 +7,9 @@
|
||||
{{i18n 'admin.user.show_public_profile'}}
|
||||
{{/link-to}}
|
||||
{{/if}}
|
||||
{{#if model.can_view_action_logs}}
|
||||
{{d-button action="viewActionLogs" actionParam=model.username icon="list-alt" label="admin.user.action_logs"}}
|
||||
{{/if}}
|
||||
{{#if model.active}}
|
||||
{{#if model.can_impersonate}}
|
||||
{{d-button class="btn-danger" action="impersonate" icon="crosshairs" label="admin.impersonate.title" title="admin.impersonate.help"}}
|
||||
|
@ -22,7 +22,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
||||
:warnings_received_count,
|
||||
:user_fields,
|
||||
:bounce_score,
|
||||
:reset_bounce_score_after
|
||||
:reset_bounce_score_after,
|
||||
:can_view_action_logs
|
||||
|
||||
has_one :approved_by, serializer: BasicUserSerializer, embed: :objects
|
||||
has_one :api_key, serializer: ApiKeySerializer, embed: :objects
|
||||
@ -86,4 +87,8 @@ class AdminDetailedUserSerializer < AdminUserSerializer
|
||||
object.user_stat.reset_bounce_score_after
|
||||
end
|
||||
|
||||
def can_view_action_logs
|
||||
scope.can_view_action_logs?(object)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3053,6 +3053,7 @@ en:
|
||||
refresh_browsers_message: "Message sent to all clients!"
|
||||
show_public_profile: "Show Public Profile"
|
||||
impersonate: 'Impersonate'
|
||||
action_logs: "Action Logs"
|
||||
ip_lookup: "IP Lookup"
|
||||
log_out: "Log Out"
|
||||
logged_out: "User was logged out on all devices"
|
||||
|
@ -158,6 +158,10 @@ class Guardian
|
||||
# make it impossible to be the same user.
|
||||
end
|
||||
|
||||
def can_view_action_logs?(target)
|
||||
is_staff? && target && target.staff?
|
||||
end
|
||||
|
||||
# Can we approve it?
|
||||
def can_approve?(target)
|
||||
is_staff? && target && not(target.approved?)
|
||||
|
@ -281,6 +281,24 @@ describe Guardian do
|
||||
end
|
||||
end
|
||||
|
||||
describe "can_view_action_logs?" do
|
||||
it 'is false for non-staff acting user' do
|
||||
expect(Guardian.new(user).can_view_action_logs?(moderator)).to be_falsey
|
||||
end
|
||||
|
||||
it 'is false without a target user' do
|
||||
expect(Guardian.new(moderator).can_view_action_logs?(nil)).to be_falsey
|
||||
end
|
||||
|
||||
it 'is false for non-staff target user' do
|
||||
expect(Guardian.new(moderator).can_view_action_logs?(user)).to be_falsey
|
||||
end
|
||||
|
||||
it 'is true for staff target user' do
|
||||
expect(Guardian.new(moderator).can_view_action_logs?(admin)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe 'can_invite_to_forum?' do
|
||||
let(:user) { Fabricate.build(:user) }
|
||||
let(:moderator) { Fabricate.build(:moderator) }
|
||||
|
Loading…
Reference in New Issue
Block a user