UX: when admin is deleted, make it clear in staff action logs when records belong to a deleted user and show their username in the details
This commit is contained in:
parent
98aaad6675
commit
dc1e7bb645
|
@ -32,7 +32,7 @@
|
|||
{{else}}
|
||||
{{i18n "admin.logs.staff_actions.filter"}} {{combo-box content=userHistoryActions value=filterActionId none="admin.logs.staff_actions.all"}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{d-button action="exportStaffActionLogs" label="admin.export_csv.button_text" icon="download"}}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
@ -57,8 +57,14 @@
|
|||
<tr class='admin-list-item'>
|
||||
<td class="staff-users">
|
||||
<div class="staff-user">
|
||||
{{#link-to 'adminUser' item.acting_user}}{{avatar item.acting_user imageSize="tiny"}}{{/link-to}}
|
||||
<a {{action "filterByStaffUser" item.acting_user}}>{{item.acting_user.username}}</a>
|
||||
{{#if item.acting_user}}
|
||||
{{#link-to 'adminUser' item.acting_user}}{{avatar item.acting_user imageSize="tiny"}}{{/link-to}}
|
||||
<a {{action "filterByStaffUser" item.acting_user}}>{{item.acting_user.username}}</a>
|
||||
{{else}}
|
||||
<span class="deleted-user" title="{{i18n 'admin.user.deleted'}}">
|
||||
{{d-icon "trash-o"}}
|
||||
</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="col value action">
|
||||
|
|
|
@ -163,6 +163,9 @@
|
|||
a:first-of-type {
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
.deleted-user {
|
||||
font-size: $font-up-2;
|
||||
}
|
||||
}
|
||||
.created_at {
|
||||
text-align: center;
|
||||
|
|
|
@ -49,6 +49,17 @@ class UserDestroyer
|
|||
post_action.remove_act!(Discourse.system_user)
|
||||
end
|
||||
|
||||
# Add info about the user to staff action logs
|
||||
UserHistory.staff_action_records(
|
||||
Discourse.system_user, acting_user: user.username
|
||||
).each do |log|
|
||||
log.details ||= ''
|
||||
log.details = (log.details.split("\n") +
|
||||
["user_id: #{user.id}", "username: #{user.username}"]
|
||||
).join("\n")
|
||||
log.save!
|
||||
end
|
||||
|
||||
# keep track of emails used
|
||||
user_emails = user.user_emails.pluck(:email)
|
||||
|
||||
|
|
|
@ -360,6 +360,28 @@ describe UserDestroyer do
|
|||
}.to change { User.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'user has staff action logs' do
|
||||
before do
|
||||
logger = StaffActionLogger.new(user)
|
||||
logger.log_site_setting_change(
|
||||
'site_description',
|
||||
'Our friendly community',
|
||||
'My favourite community'
|
||||
)
|
||||
end
|
||||
|
||||
it "should keep the staff action log and add the username" do
|
||||
username = user.username
|
||||
log = UserHistory.staff_action_records(
|
||||
Discourse.system_user,
|
||||
acting_user: username
|
||||
).to_a[0]
|
||||
UserDestroyer.new(admin).destroy(user, delete_posts: true)
|
||||
log.reload
|
||||
expect(log.details).to include(username)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue