FIX: force refresh staff action logs when transitioning from site settings (#12096)

This commit is contained in:
Arpit Jalan 2021-02-17 00:18:39 +05:30 committed by GitHub
parent fa3eb1f7fc
commit 94036a6f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View File

@ -7,6 +7,14 @@ export default DiscourseRoute.extend({
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") {
return EmberObject.create(JSON.parse(decodeURIComponent(value)));
@ -27,13 +35,6 @@ export default DiscourseRoute.extend({
return this._super(value, urlKey, defaultValueType);
},
activate() {
const controller = this.controllerFor("admin-logs-staff-action-logs");
if (controller.filters === null) {
controller.resetFilters();
}
},
// TODO: make this automatic using an `{{outlet}}`
renderTemplate() {
this.render("admin/templates/logs/staff-action-logs", {

View File

@ -2,7 +2,7 @@
<h3>
{{#if staffLogFilter}}
{{settingName}}
{{#link-to "adminLogs.staffActionLogs" (query-params filters=staffLogFilter) title=(i18n "admin.settings.history")}}
{{#link-to "adminLogs.staffActionLogs" (query-params filters=staffLogFilter force_refresh=true) title=(i18n "admin.settings.history")}}
<span class="history-icon">
{{d-icon "history"}}
</span>

View File

@ -56,7 +56,7 @@ acceptance("Admin - Site Settings", function (needs) {
assert.equal(
queryAll(".row.setting .setting-label h3 a").attr("href"),
"/admin/logs/staff_action_logs?filters=%7B%22subject%22%3A%22title%22%2C%22action_name%22%3A%22change_site_setting%22%7D",
"/admin/logs/staff_action_logs?filters=%7B%22subject%22%3A%22title%22%2C%22action_name%22%3A%22change_site_setting%22%7D&force_refresh=true",
"it links to the staff action log"
);
});