FIX: hide sidebar for anonymous when login required ()

Recently anonymous sidebar was introduced, but it should be hidden when site requires users to authenticate.
This commit is contained in:
Krzysztof Kotlarek 2022-08-24 10:04:10 +10:00 committed by GitHub
parent 9ff13cee14
commit 6fb3610f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions
app/assets/javascripts/discourse
app/controllers
tests/acceptance

@ -17,7 +17,9 @@ export default Controller.extend({
init() { init() {
this._super(...arguments); this._super(...arguments);
this.showSidebar = !this.keyValueStore.getItem(HIDE_SIDEBAR_KEY); this.showSidebar =
(this.currentUser || !this.siteSettings.login_required) &&
!this.keyValueStore.getItem(HIDE_SIDEBAR_KEY);
}, },
@discourseComputed @discourseComputed

@ -20,7 +20,24 @@ acceptance("Sidebar - Anonymous User", function (needs) {
assert.ok( assert.ok(
exists(".sidebar-container"), exists(".sidebar-container"),
"sidebar exists for anonymouse user" "sidebar exists for anonymous user"
);
});
});
acceptance("Sidebar - Anonymous User - Login Required", function (needs) {
needs.settings({
enable_experimental_sidebar_hamburger: true,
enable_sidebar: true,
login_required: true,
});
test("sidebar is hidden", async function (assert) {
await visit("/");
assert.ok(
!exists(".sidebar-container"),
"sidebar is hidden for anonymous user"
); );
}); });
}); });