From a252bbf3e8acdc8e3cc0ef005044f9ecb028281a Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 18 Aug 2022 17:09:33 +0530 Subject: [PATCH] FIX: show hide bootstrap mode notice in real time (#17981) --- .../discourse/app/controllers/application.js | 11 +++++++---- .../tests/acceptance/bootstrap-mode-notice-test.js | 11 ++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/application.js b/app/assets/javascripts/discourse/app/controllers/application.js index 80c07b17b2..a6ef09a7f5 100644 --- a/app/assets/javascripts/discourse/app/controllers/application.js +++ b/app/assets/javascripts/discourse/app/controllers/application.js @@ -34,12 +34,15 @@ export default Controller.extend({ return this.siteSettings.login_required && !this.currentUser; }, - @discourseComputed - showBootstrapModeNotice() { + @discourseComputed( + "siteSettings.bootstrap_mode_enabled", + "router.currentRouteName" + ) + showBootstrapModeNotice(bootstrapModeEnabled, currentRouteName) { return ( this.currentUser?.get("staff") && - this.siteSettings.bootstrap_mode_enabled && - !this.router.currentRouteName.startsWith("wizard") + bootstrapModeEnabled && + !currentRouteName.startsWith("wizard") ); }, diff --git a/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js b/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js index 6bbd39f701..9d8812ccf3 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/bootstrap-mode-notice-test.js @@ -1,6 +1,7 @@ import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; 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) { needs.user(); @@ -34,5 +35,13 @@ acceptance("Bootstrap Mode Notice", function (needs) { "/wizard/steps/hello-world", "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" + ); }); });