FIX: hide sidebar toggle button when no sidebar (#18068)
When sidebar is not available (for example for anonymous user for sites which requires log in), toggle button should be hidden as well.
This commit is contained in:
parent
6771673a1b
commit
7a58bd8827
|
@ -18,8 +18,7 @@ export default Controller.extend({
|
|||
init() {
|
||||
this._super(...arguments);
|
||||
this.showSidebar =
|
||||
(this.currentUser || !this.siteSettings.login_required) &&
|
||||
!this.keyValueStore.getItem(HIDE_SIDEBAR_KEY);
|
||||
this.canDisplaySidebar && !this.keyValueStore.getItem(HIDE_SIDEBAR_KEY);
|
||||
},
|
||||
|
||||
@discourseComputed
|
||||
|
@ -31,6 +30,11 @@ export default Controller.extend({
|
|||
);
|
||||
},
|
||||
|
||||
@discourseComputed
|
||||
canDisplaySidebar() {
|
||||
return this.currentUser || !this.siteSettings.login_required;
|
||||
},
|
||||
|
||||
@discourseComputed
|
||||
loginRequired() {
|
||||
return this.siteSettings.login_required && !this.currentUser;
|
||||
|
@ -60,9 +64,18 @@ export default Controller.extend({
|
|||
@discourseComputed(
|
||||
"enable_sidebar",
|
||||
"siteSettings.enable_sidebar",
|
||||
"router.currentRouteName"
|
||||
"router.currentRouteName",
|
||||
"canDisplaySidebar"
|
||||
)
|
||||
sidebarEnabled(sidebarQueryParamOverride, enableSidebar, currentRouteName) {
|
||||
sidebarEnabled(
|
||||
sidebarQueryParamOverride,
|
||||
enableSidebar,
|
||||
currentRouteName,
|
||||
canDisplaySidebar
|
||||
) {
|
||||
if (!canDisplaySidebar) {
|
||||
return false;
|
||||
}
|
||||
if (sidebarQueryParamOverride === "1") {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,11 @@ acceptance("Sidebar - Anonymous User", function (needs) {
|
|||
exists(".sidebar-container"),
|
||||
"sidebar exists for anonymous user"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(".header-sidebar-toggle"),
|
||||
"toggle button for anonymous user"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -32,12 +37,17 @@ acceptance("Sidebar - Anonymous User - Login Required", function (needs) {
|
|||
login_required: true,
|
||||
});
|
||||
|
||||
test("sidebar is hidden", async function (assert) {
|
||||
test("sidebar and toggle button is hidden", async function (assert) {
|
||||
await visit("/");
|
||||
|
||||
assert.ok(
|
||||
!exists(".sidebar-container"),
|
||||
"sidebar is hidden for anonymous user"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
!exists(".header-sidebar-toggle"),
|
||||
"toggle button is hidden for anonymous user"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue