mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 16:23:44 +08:00
125903f682
011ba5b9
slightly changed the way the staff-action-log route is activated. It's now possible for `deserializeQueryParam` to be called with a null value, so we need to deal with that case.
This route is currently untested - we'll follow-up with another commit to add some.
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import DiscourseRoute from "discourse/routes/discourse";
|
|
import EmberObject, { action } from "@ember/object";
|
|
import { inject as service } from "@ember/service";
|
|
|
|
export default class AdminLogsStaffActionLogsRoute extends DiscourseRoute {
|
|
@service router;
|
|
|
|
queryParams = {
|
|
filters: { refreshModel: true },
|
|
};
|
|
|
|
beforeModel(transition) {
|
|
const params = transition.to.queryParams;
|
|
const controller = this.controllerFor("admin-logs-staff-action-logs");
|
|
if (controller.filters === null || params.force_refresh) {
|
|
controller.resetFilters();
|
|
}
|
|
}
|
|
|
|
deserializeQueryParam(value, urlKey, defaultValueType) {
|
|
if (urlKey === "filters" && value) {
|
|
return EmberObject.create(JSON.parse(decodeURIComponent(value)));
|
|
}
|
|
|
|
return super.deserializeQueryParam(value, urlKey, defaultValueType);
|
|
}
|
|
|
|
serializeQueryParam(value, urlKey, defaultValueType) {
|
|
if (urlKey === "filters") {
|
|
if (value && Object.keys(value).length > 0) {
|
|
return JSON.stringify(value);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return super.serializeQueryParam(value, urlKey, defaultValueType);
|
|
}
|
|
|
|
@action
|
|
onFiltersChange(filters) {
|
|
this.router.transitionTo("adminLogs.staffActionLogs", {
|
|
queryParams: { filters },
|
|
});
|
|
}
|
|
}
|