A platform for community discussion. Free, open, simple.
DEV: Do not always include software update HTML in DOM (#13291)
Penar Musaraj6759e5e39693
diff --git a/app/assets/javascripts/discourse/app/components/software-update-prompt.js b/app/assets/javascripts/discourse/app/components/software-update-prompt.jsindex 73424b6513c..b8a864f0db8 100644--- a/app/assets/javascripts/discourse/app/components/software-update-prompt.js+++ b/app/assets/javascripts/discourse/app/components/software-update-prompt.js@@ -9,6 +9,7 @@ export default Component.extend({tagName: "",showPrompt: false,+ animatePrompt: false,_timeoutHandler: null,@discourseComputed@@ -29,18 +30,34 @@ export default Component.extend({if (!this._timeoutHandler && this.session.requiresRefresh) {if (isTesting()) {- this.set("showPrompt", true);+ this.updatePromptState(true);} else {// Since we can do this transparently for people browsing the forum// hold back the message 24 hours.this._timeoutHandler = later(() => {- this.set("showPrompt", true);+ this.updatePromptState(true);}, 1000 * 60 * 24 * 60);}}});},+ updatePromptState(value) {+ // when adding the message, we inject the HTML then add the animation+ // when dismissing, things need to happen in the opposite order+ const firstProp = value ? "showPrompt" : "animatePrompt",+ secondProp = value ? "animatePrompt" : "showPrompt";++ this.set(firstProp, value);+ if (isTesting()) {+ this.set(secondProp, value);+ } else {+ later(() => {+ this.set(secondProp, value);+ }, 500);+ }+ },+@actionrefreshPage() {document.location.reload();@@ -48,7 +65,7 @@ export default Component.extend({@actiondismiss() {- this.set("showPrompt", false);+ this.updatePromptState(false);},@on("willDestroyElement")diff --git a/app/assets/javascripts/discourse/app/templates/application.hbs b/app/assets/javascripts/discourse/app/templates/application.hbsindex 8b3ecd788e2..9296b8b8b9c 100644--- a/app/assets/javascripts/discourse/app/templates/application.hbs+++ b/app/assets/javascripts/discourse/app/templates/application.hbs@@ -8,7 +8,7 @@toggleMobileView=(route-action "toggleMobileView")toggleAnonymous=(route-action "toggleAnonymous")logout=(route-action "logout")}}- {{software-update-prompt id="software-update-prompt"}}+ {{software-update-prompt}}{{plugin-outlet name="below-site-header" tagName="" args=(hash currentPath=router._router.currentPath)}}diff --git a/app/assets/javascripts/discourse/app/templates/components/software-update-prompt.hbs b/app/assets/javascripts/discourse/app/templates/components/software-update-prompt.hbsindex db9627812ef..7e844730abc 100644--- a/app/assets/javascripts/discourse/app/templates/components/software-update-prompt.hbs+++ b/app/assets/javascripts/discourse/app/templates/components/software-update-prompt.hbs@@ -1,9 +1,10 @@-<div class="software-update-prompt {{if showPrompt "require-software-refresh"}}">- <div class="wrap">- <div class="update-prompt-main-content" aria-live="polite">- <span role="button" onclick={{action "refreshPage"}} class="update-prompt-message">{{d-icon "redo"}} {{html-safe (i18n "software_update_prompt.message")}}</span>- <span class="update-prompt-dismiss"><span aria-label={{i18n "software_update_prompt.dismiss"}} role="button" onclick={{action "dismiss"}}>{{d-icon "times"}}</span></span>+{{#if showPrompt}}+ <div class="software-update-prompt{{if animatePrompt " require-software-refresh"}}">+ <div class="wrap">+ <div class="update-prompt-main-content" aria-live="polite">+ <span role="button" onclick={{action "refreshPage"}} class="update-prompt-message">{{d-icon "redo"}} {{html-safe (i18n "software_update_prompt.message")}}</span>+ <span class="update-prompt-dismiss"><span aria-label={{i18n "software_update_prompt.dismiss"}} role="button" onclick={{action "dismiss"}}>{{d-icon "times"}}</span></span>+ </div></div></div>-</div>-+{{/if}}diff --git a/app/assets/javascripts/discourse/tests/integration/widgets/software-update-prompt-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/software-update-prompt-test.jsindex 59059a28bbe..dec9287d47f 100644--- a/app/assets/javascripts/discourse/tests/integration/widgets/software-update-prompt-test.js+++ b/app/assets/javascripts/discourse/tests/integration/widgets/software-update-prompt-test.js@@ -21,8 +21,7 @@ discourseModule(test(assert) {assert.ok(- queryAll("div.software-update-prompt.require-software-refresh")- .length === 0,+ queryAll("div.software-update-prompt").length === 0,"it does not have the class to show the prompt");diff --git a/app/assets/stylesheets/common/software-update-prompt.scss b/app/assets/stylesheets/common/software-update-prompt.scssindex 4da4fc47481..d2fbdbe91f3 100644--- a/app/assets/stylesheets/common/software-update-prompt.scss+++ b/app/assets/stylesheets/common/software-update-prompt.scss@@ -6,8 +6,8 @@background-color: var(--tertiary-low);color: var(--tertiary);max-height: 0;- visibility: hidden;- transition: max-height 1s;+ overflow: hidden;+ transition: max-height 0.3s;box-shadow: shadow("header");z-index: z("header") - 10;@@ -48,10 +48,9 @@}&.require-software-refresh {- visibility: visible;- overflow: hidden;max-height: 300px;margin-left: auto;margin-right: auto;+ transition: max-height 0.75s;}}