FIX: Resetting site setting didn't remove "overriden" state

This commit is contained in:
Gerhard Schlager 2018-09-01 02:08:11 +02:00
parent 690908993f
commit 16974df1e9
5 changed files with 114 additions and 6 deletions

View File

@ -84,7 +84,7 @@ export default Ember.Mixin.create({
this.$().on("keydown.setting-enter", ".input-setting-string", function(e) {
if (e.keyCode === 13) {
// enter key
self._save();
self.send("save");
}
});
}.on("didInsertElement"),
@ -122,7 +122,7 @@ export default Ember.Mixin.create({
resetDefault() {
this.set("buffered.value", this.get("setting.default"));
this._save();
this.send("save");
},
toggleSecret() {

View File

@ -13,5 +13,5 @@
{{#if setting.secret}}
{{d-button action="toggleSecret" icon="eye-slash"}}
{{/if}}
{{d-button action="resetDefault" icon="undo" label="admin.settings.reset"}}
{{d-button class="undo" action="resetDefault" icon="undo" label="admin.settings.reset"}}
{{/if}}

View File

@ -2,8 +2,8 @@
<div class='controls'>
{{d-button action="toggleMenu" class="menu-toggle" icon="bars"}}
{{text-field value=filter placeholderKey="type_to_filter" class="no-blur"}}
{{d-button action="clearFilter" label="admin.site_settings.clear_filter"}}
{{text-field id="setting-filter" value=filter placeholderKey="type_to_filter" class="no-blur"}}
{{d-button id="clear-filter" action="clearFilter" label="admin.site_settings.clear_filter"}}
</div>
<div class='search controls'>
<label>

View File

@ -0,0 +1,45 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Site Settings", {
loggedIn: true,
pretend(server, helper) {
server.put("/admin/site_settings/**", () =>
helper.response({ success: "OK" })
);
}
});
QUnit.test("changing value updates dirty state", async assert => {
await visit("/admin/site_settings");
await fillIn("#setting-filter", "title");
assert.equal(count(".row.setting"), 1, "filter returns 1 site setting");
assert.ok(!exists(".row.setting.overridden"), "setting isn't overriden");
await fillIn(".input-setting-string", "Test");
await click("button.cancel");
assert.ok(
!exists(".row.setting.overridden"),
"canceling doesn't mark setting as overriden"
);
await fillIn(".input-setting-string", "Test");
await click("button.ok");
assert.ok(
exists(".row.setting.overridden"),
"saving marks setting as overriden"
);
await click("button.undo");
assert.ok(
!exists(".row.setting.overridden"),
"setting isn't marked as overriden after undo"
);
await fillIn(".input-setting-string", "Test");
await keyEvent(".input-setting-string", "keydown", 13); // enter
assert.ok(
exists(".row.setting.overridden"),
"saving via Enter key marks setting as overriden"
);
});

View File

@ -0,0 +1,63 @@
export default {
"/admin/site_settings": {
site_settings: [
{
setting: "title",
description: "The name of this site, as used in the title tag.",
default: "Discourse",
value: "Discourse",
category: "required",
preview: null,
secret: false,
type: "string"
},
{
setting: "contact_email",
description:
"Email address of key contact responsible for this site. Used for critical notifications, as well as on the /about contact form for urgent matters.",
default: "",
value: "",
category: "required",
preview: null,
secret: false,
type: "email"
},
{
setting: "site_contact_username",
description:
"A valid staff username to send all automated messages from. If left blank the default System account will be used.",
default: "",
value: "",
category: "required",
preview: null,
secret: false,
type: "username"
},
{
setting: "top_menu",
description:
"Determine which items appear in the homepage navigation, and in what order. Example latest|new|unread|categories|top|read|posted|bookmarks",
default: "latest|new|unread|top|categories",
value: "latest|new|unread|top|categories",
category: "basic",
preview: null,
secret: false,
type: "list",
choices: [
"latest",
"new",
"unread",
"top",
"categories",
"read",
"posted",
"bookmarks"
],
list_type: "compact"
}
],
diags: {
last_message_processed: null
}
}
};