A platform for community discussion. Free, open, simple.
FIX: Restore staff log filtering and pagination feedback (#45144)
Alan Guo Xiang Tan9fbb5ad924a2
diff --git a/app/assets/stylesheets/admin/staff_logs.scss b/app/assets/stylesheets/admin/staff_logs.scssindex 673276e1e76..026436b0613 100644--- a/app/assets/stylesheets/admin/staff_logs.scss+++ b/app/assets/stylesheets/admin/staff_logs.scss@@ -136,6 +136,17 @@}}+.staff-user__filter {+ min-width: 0;+ max-width: 20ch;+ text-align: start;++ .d-button-label {+ @include ellipsis;+ display: block;+ }+}+.staff-action-logs-controls {display: flex;align-items: baseline;@@ -184,10 +195,20 @@display: flex;flex-wrap: wrap;gap: var(--space-2);+ max-width: 100%;.btn {gap: var(--space-2);- text-align: left;+ max-width: 100%;+ overflow-wrap: anywhere;+ text-align: start;+ white-space: normal;+ }++ .staff-action-logs-filters__staff-user .d-button-label {+ @include ellipsis;+ max-width: 24ch;+ min-width: 0;}}diff --git a/frontend/discourse/admin/controllers/admin-logs/staff-action-logs.js b/frontend/discourse/admin/controllers/admin-logs/staff-action-logs.jsindex 8e81dc252c7..e0526c64773 100644--- a/frontend/discourse/admin/controllers/admin-logs/staff-action-logs.js+++ b/frontend/discourse/admin/controllers/admin-logs/staff-action-logs.js@@ -152,7 +152,9 @@ export default class AdminLogsStaffActionLogsController extends Controller {@actionloadMore() {- this.model.loadMore();+ if (!this.initialModelLoading) {+ this.model.loadMore();+ }}@actiondiff --git a/frontend/discourse/admin/templates/admin-logs/staff-action-logs.gjs b/frontend/discourse/admin/templates/admin-logs/staff-action-logs.gjsindex 17a60404f8b..113696f04d8 100644--- a/frontend/discourse/admin/templates/admin-logs/staff-action-logs.gjs+++ b/frontend/discourse/admin/templates/admin-logs/staff-action-logs.gjs@@ -37,7 +37,7 @@ export default <template>{{/if}}{{#if @controller.filters.acting_user}}<DButton- class="filter btn-default"+ class="filter btn-default staff-action-logs-filters__staff-user"@action={{fn @controller.clearFilter "acting_user"}}@suffixIcon="xmark"@translatedLabel={{concat@@ -45,6 +45,7 @@ export default <template>": "@controller.filters.acting_user}}+ @translatedTitle={{@controller.filters.acting_user}}/>{{/if}}{{#if @controller.filters.target_user}}@@ -129,8 +130,17 @@ export default <template>{{#if item.acting_user}}<LinkTo @model={{item.acting_user}} @route="adminUser">{{dAvatar item.acting_user imageSize="tiny"}}- {{item.acting_user.username}}</LinkTo>+ <DButton+ class="staff-user__filter"+ @action={{fn+ @controller.filterByStaffUser+ item.acting_user+ }}+ @display="link"+ @translatedLabel={{item.acting_user.username}}+ @translatedTitle={{item.acting_user.username}}+ />{{else}}<spanclass="deleted-user"@@ -210,13 +220,12 @@ export default <template>{{/each}}</tbody></table>- {{else if @controller.model.loadingMore}}- <DConditionalLoadingSpinner- @condition={{@controller.model.loadingMore}}- />- {{else}}+ {{else if (not @controller.model.loadingMore)}}{{i18n "search.no_results"}}{{/if}}+ <DConditionalLoadingSpinner+ @condition={{@controller.model.loadingMore}}+ /></DLoadMore></StaffActions></template>diff --git a/spec/system/admin_staff_action_logs_spec.rb b/spec/system/admin_staff_action_logs_spec.rbindex 4cace8948c6..788aa6a406a 100644--- a/spec/system/admin_staff_action_logs_spec.rb+++ b/spec/system/admin_staff_action_logs_spec.rb@@ -151,7 +151,10 @@ describe "Admin staff action logs" doexpect(staff_action_logs_page.log_row(history)).to have_css(".context", text: payload)end- it "can filter by type of action" do+ it "can filter by type of action and staff user" do+ history_1.update!(acting_user: current_user)+ other_history = Fabricate(:site_setting_change_history)+visit "/admin/logs/staff_action_logs"expect(staff_action_logs_page).to have_log_row(history_1)@@ -169,6 +172,25 @@ describe "Admin staff action logs" doexpect(staff_action_logs_page).to have_no_log_row(history_2)expect(staff_action_logs_page).to have_no_log_row(history_3)+ expect(staff_action_logs_page).to have_log_row(other_history)++ staff_action_logs_page.filter_by_staff_user(current_user)++ expect(staff_action_logs_page).to have_staff_user_filter(current_user)+ expect(staff_action_logs_page).to have_log_row(history_1)+ expect(staff_action_logs_page).to have_no_log_row(other_history)++ page.refresh++ expect(staff_action_logs_page).to have_staff_user_filter(current_user)+ expect(staff_action_logs_page).to have_log_row(history_1)+ expect(staff_action_logs_page).to have_no_log_row(other_history)++ staff_action_logs_page.clear_staff_user_filter(current_user)++ expect(staff_action_logs_page).to have_log_row(other_history)+ expect(staff_action_logs_page).to have_no_log_row(history_2)+staff_action_logs_page.clear_filterstaff_action_logs_page.filter_by_action(:update_flag)diff --git a/spec/system/page_objects/pages/admin_staff_action_logs.rb b/spec/system/page_objects/pages/admin_staff_action_logs.rbindex 9bc679dbf2d..6b356fbc0c6 100644--- a/spec/system/page_objects/pages/admin_staff_action_logs.rb+++ b/spec/system/page_objects/pages/admin_staff_action_logs.rb@@ -49,6 +49,18 @@ module PageObjectsfind(".clear-filters").clickend+ def filter_by_staff_user(user)+ find(".staff-logs .staff-user button", text: user.username, match: :first).click+ end++ def has_staff_user_filter?(user)+ has_button?(staff_user_filter_label(user))+ end++ def clear_staff_user_filter(user)+ click_button(staff_user_filter_label(user))+ end+def click_export_buttonfind(".export-staff-action-logs").clickend@@ -60,6 +72,12 @@ module PageObjectsdef fill_date_filter_to(date)find(".d-date-time-input.to .d-date-input input").set(date)end++ private++ def staff_user_filter_label(user)+ "#{I18n.t("admin_js.admin.logs.staff_actions.staff_user")}: #{user.username}"+ endendendend