discourse/app/assets/javascripts/admin/addon/routes/admin-users-list-show.js
Martin Brennan dbcefcf85e
FEATURE: Show additional filter links in admin sidebar for no results (#26672)
When the user sees no results in their admin sidebar query,
we are adding two additional links:

* "Search site settings" - Navigates to the site settings page
  with the filter prefilled in the search
* "Admin user list" - Navigates to the user list with the filter
  prefilled in the username search

This will bridge the gap until we have a full admin-wide search.

Also make admin site setting search param refresh on filter changes

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-04-19 10:55:17 +10:00

34 lines
1.0 KiB
JavaScript

import DiscourseRoute from "discourse/routes/discourse";
export default class AdminUsersListShowRoute extends DiscourseRoute {
queryParams = {
order: { refreshModel: true },
asc: { refreshModel: true },
username: { refreshModel: true },
};
// TODO: this has been introduced to fix a bug in admin-users-list-show
// loading AdminUser model multiple times without refactoring the controller
beforeModel(transition) {
const routeName = "adminUsersList.show";
if (transition.targetName === routeName) {
const params = transition.routeInfos.find(
(a) => a.name === routeName
).params;
const controller = this.controllerFor(routeName);
if (controller) {
controller.setProperties({
order: transition.to.queryParams.order,
asc: transition.to.queryParams.asc,
listFilter: transition.to.queryParams.username,
query: params.filter,
refreshing: false,
});
controller.resetFilters();
}
}
}
}