FIX: always show filtered site settings

FIX: always show filtered site settings
diff --git a/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6 b/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6
index c2d9620..c2f8c09 100644
--- a/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6
@@ -4,7 +4,7 @@ export default Ember.Controller.extend({
   categoryNameKey: null,
   adminSiteSettings: Ember.inject.controller(),
 
-  @computed("adminSiteSettings.model", "categoryNameKey")
+  @computed("adminSiteSettings.visible", "categoryNameKey")
   category(categories, nameKey) {
     return (categories || []).findBy("nameKey", nameKey);
   },
diff --git a/app/assets/javascripts/admin/controllers/admin-site-settings.js.es6 b/app/assets/javascripts/admin/controllers/admin-site-settings.js.es6
index 5d34c26..85eac47 100644
--- a/app/assets/javascripts/admin/controllers/admin-site-settings.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-site-settings.js.es6
@@ -2,6 +2,8 @@ import debounce from "discourse/lib/debounce";
 
 export default Ember.Controller.extend({
   filter: null,
+  allSiteSettings: Ember.computed.alias("model"),
+  visible: null,
   onlyOverridden: false,
 
   filterContentNow(category) {
@@ -14,7 +16,7 @@ export default Ember.Controller.extend({
     }
 
     if ((!filter || 0 === filter.length) && !this.get("onlyOverridden")) {
-      this.set("model", this.get("allSiteSettings"));
+      this.set("visible", this.get("allSiteSettings"));
       this.transitionToRoute("adminSiteSettings");
       return;
     }
@@ -62,7 +64,7 @@ export default Ember.Controller.extend({
     all.hasMore = matches.length > 30;
     all.count = all.hasMore ? "30+" : matches.length;
 
-    this.set("model", matchesGroupedByCategory);
+    this.set("visible", matchesGroupedByCategory);
     this.transitionToRoute(
       "adminSiteSettingsCategory",
       category || "all_results"
diff --git a/app/assets/javascripts/admin/routes/admin-site-settings-index.js.es6 b/app/assets/javascripts/admin/routes/admin-site-settings-index.js.es6
index 451fe71..ea8f10c 100644
--- a/app/assets/javascripts/admin/routes/admin-site-settings-index.js.es6
+++ b/app/assets/javascripts/admin/routes/admin-site-settings-index.js.es6
@@ -6,7 +6,7 @@ export default Discourse.Route.extend({
   beforeModel() {
     this.replaceWith(
       "adminSiteSettingsCategory",
-      this.modelFor("adminSiteSettings")[0].nameKey
+      this.controllerFor("adminSiteSettings").get("visible")[0].nameKey
     );
   }
 });
diff --git a/app/assets/javascripts/admin/routes/admin-site-settings.js.es6 b/app/assets/javascripts/admin/routes/admin-site-settings.js.es6
index 48418d3..6aecdbd 100644
--- a/app/assets/javascripts/admin/routes/admin-site-settings.js.es6
+++ b/app/assets/javascripts/admin/routes/admin-site-settings.js.es6
@@ -10,9 +10,10 @@ export default Discourse.Route.extend({
   },
 
   afterModel(siteSettings) {
-    this.controllerFor("adminSiteSettings").set(
-      "allSiteSettings",
-      siteSettings
-    );
+    const controller = this.controllerFor("adminSiteSettings");
+
+    if (!controller.get("visible")) {
+      controller.set("visible", siteSettings);
+    }
   }
 });
diff --git a/app/assets/javascripts/admin/templates/site-settings.hbs b/app/assets/javascripts/admin/templates/site-settings.hbs
index 1d1e579..6b7c9a8 100644
--- a/app/assets/javascripts/admin/templates/site-settings.hbs
+++ b/app/assets/javascripts/admin/templates/site-settings.hbs
@@ -15,7 +15,7 @@
 
 <div class="admin-nav pull-left">
   <ul class="nav nav-stacked">
-    {{#each model as |category|}}
+    {{#each visible as |category|}}
       <li class="{{category.nameKey}}">
         {{#link-to 'adminSiteSettingsCategory' category.nameKey class=category.nameKey}}
           {{category.name}}
diff --git a/test/javascripts/acceptance/admin-site-settings-test.js.es6 b/test/javascripts/acceptance/admin-site-settings-test.js.es6
index a4bb84f..9db655f 100644
--- a/test/javascripts/acceptance/admin-site-settings-test.js.es6
+++ b/test/javascripts/acceptance/admin-site-settings-test.js.es6
@@ -54,3 +54,20 @@ QUnit.test("changing value updates dirty state", async assert => {
     "saving via Enter key marks setting as overriden"
   );
 });
+
+QUnit.test(
+  "always shows filtered site settings if a filter is set",
+  async assert => {
+    await visit("/admin/site_settings");
+    await fillIn("#setting-filter", "title");
+    assert.equal(count(".row.setting"), 1);
+
+    // navigate away to the "Dashboard" page
+    await click(".nav.nav-pills li:nth-child(1) a");
+    assert.equal(count(".row.setting"), 0);
+
+    // navigate back to the "Settings" page
+    await click(".nav.nav-pills li:nth-child(2) a");
+    assert.equal(count(".row.setting"), 1);
+  }
+);

GitHub