FEATURE: Link site setting titles directly to their change log (#11215)

This makes it much easier to check the staff action logs for a specific site setting. A small history icon will appear when hovering over a site setting name. On click, you will be taken to the pre-filtered staff action log for the site setting.
This commit is contained in:
David Taylor 2020-11-12 12:07:36 +00:00 committed by GitHub
parent 6d4711ca10
commit a4441b3984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import Component from "@ember/component";
import BufferedContent from "discourse/mixins/buffered-content"; import BufferedContent from "discourse/mixins/buffered-content";
import SiteSetting from "admin/models/site-setting"; import SiteSetting from "admin/models/site-setting";
import SettingComponent from "admin/mixins/setting-component"; import SettingComponent from "admin/mixins/setting-component";
import { readOnly } from "@ember/object/computed";
export default Component.extend(BufferedContent, SettingComponent, { export default Component.extend(BufferedContent, SettingComponent, {
updateExistingUsers: null, updateExistingUsers: null,
@ -12,4 +13,6 @@ export default Component.extend(BufferedContent, SettingComponent, {
updateExistingUsers: this.updateExistingUsers, updateExistingUsers: this.updateExistingUsers,
}); });
}, },
staffLogFilter: readOnly("setting.staffLogFilter"),
}); });

View File

@ -2,8 +2,21 @@ import I18n from "I18n";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import Setting from "admin/mixins/setting-object"; import Setting from "admin/mixins/setting-object";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
const SiteSetting = EmberObject.extend(Setting, {}); const SiteSetting = EmberObject.extend(Setting, {
@discourseComputed("setting")
staffLogFilter(setting) {
if (!setting) {
return;
}
return JSON.stringify({
subject: setting,
action_name: "change_site_setting",
});
},
});
SiteSetting.reopenClass({ SiteSetting.reopenClass({
findAll() { findAll() {

View File

@ -1,5 +1,16 @@
<div class="setting-label"> <div class="setting-label">
<h3>{{settingName}}</h3> <h3>
{{#if staffLogFilter}}
{{#link-to "adminLogs.staffActionLogs" (query-params filter=staffLogFilter) title=(i18n "admin.settings.history")}}
{{settingName}}
<span class="history-icon">
{{d-icon "history"}}
</span>
{{/link-to}}
{{else}}
{{settingName}}
{{/if}}
</h3>
{{#if defaultIsAvailable}} {{#if defaultIsAvailable}}
<a href onClick={{action "setDefaultValues"}}>{{setting.setDefaultValuesLabel}}</a> <a href onClick={{action "setDefaultValues"}}>{{setting.setDefaultValuesLabel}}</a>
{{/if}} {{/if}}

View File

@ -1,3 +1,4 @@
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
import { exists } from "discourse/tests/helpers/qunit-helpers"; import { exists } from "discourse/tests/helpers/qunit-helpers";
import { fillIn, click, visit, currentURL } from "@ember/test-helpers"; import { fillIn, click, visit, currentURL } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -41,6 +42,16 @@ acceptance("Admin - Site Settings", function (needs) {
assert.ok(exists(".row.setting.upload .undo"), "undo button is present"); assert.ok(exists(".row.setting.upload .undo"), "undo button is present");
}); });
test("links to staff action log", async function (assert) {
await visit("/admin/site_settings");
assert.equal(
queryAll(".row.setting .setting-label h3 a").attr("href"),
"/admin/logs/staff_action_logs?filter=%7B%22subject%22%3A%22title%22%2C%22action_name%22%3A%22change_site_setting%22%7D",
"it links to the staff action log"
);
});
test("changing value updates dirty state", async function (assert) { test("changing value updates dirty state", async function (assert) {
await visit("/admin/site_settings"); await visit("/admin/site_settings");
await fillIn("#setting-filter", " title "); await fillIn("#setting-filter", " title ");

View File

@ -15,6 +15,19 @@
margin-bottom: 6px; margin-bottom: 6px;
} }
} }
h3 {
a:any-link {
color: unset;
}
.history-icon {
opacity: 0;
transition: opacity 0.3s;
color: var(--primary-medium);
}
&:hover .history-icon {
opacity: 1;
}
}
} }
.setting-value { .setting-value {
float: left; float: left;

View File

@ -4767,6 +4767,7 @@ en:
settings: # used by theme and site settings settings: # used by theme and site settings
show_overriden: "Only show overridden" show_overriden: "Only show overridden"
history: "View change history"
reset: "reset" reset: "reset"
none: "none" none: "none"
site_settings: site_settings: