FIX: show hide bootstrap mode notice in real time (#17981)

This commit is contained in:
Arpit Jalan 2022-08-18 17:09:33 +05:30 committed by GitHub
parent be1b202fd6
commit a252bbf3e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -34,12 +34,15 @@ export default Controller.extend({
return this.siteSettings.login_required && !this.currentUser; return this.siteSettings.login_required && !this.currentUser;
}, },
@discourseComputed @discourseComputed(
showBootstrapModeNotice() { "siteSettings.bootstrap_mode_enabled",
"router.currentRouteName"
)
showBootstrapModeNotice(bootstrapModeEnabled, currentRouteName) {
return ( return (
this.currentUser?.get("staff") && this.currentUser?.get("staff") &&
this.siteSettings.bootstrap_mode_enabled && bootstrapModeEnabled &&
!this.router.currentRouteName.startsWith("wizard") !currentRouteName.startsWith("wizard")
); );
}, },

View File

@ -1,6 +1,7 @@
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { click, currentURL, visit } from "@ember/test-helpers"; import { click, currentURL, settled, visit } from "@ember/test-helpers";
import { set } from "@ember/object";
acceptance("Bootstrap Mode Notice", function (needs) { acceptance("Bootstrap Mode Notice", function (needs) {
needs.user(); needs.user();
@ -34,5 +35,13 @@ acceptance("Bootstrap Mode Notice", function (needs) {
"/wizard/steps/hello-world", "/wizard/steps/hello-world",
"it transitions to the wizard page" "it transitions to the wizard page"
); );
await visit("/");
set(this.siteSettings, "bootstrap_mode_enabled", false);
await settled();
assert.ok(
!exists(".bootstrap-mode-notice"),
"removes the notice when bootstrap mode is disabled"
);
}); });
}); });