FIX: Sidebar hamburger panel dropdown not working for anonymous (#18085)

We were incorrectly trying to render the sidebar sections for a logged
in user.
This commit is contained in:
Alan Guo Xiang Tan 2022-08-25 16:29:06 +08:00 committed by GitHub
parent 0b5a0fd857
commit e9dac86cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 8 deletions

View File

@ -1,9 +1,4 @@
<DSection @pageClass="has-sidebar" @class="sidebar-container" @scrollTop={{false}}>
{{#if this.currentUser}}
<Sidebar::User::Sections @collapsableSections={{true}}/>
{{else}}
<Sidebar::Anonymous::Sections @collapsableSections={{true}}/>
{{/if}}
<Sidebar::Sections @currentUser={{this.currentUser}} @collapsableSections={{true}} />
<Sidebar::Footer />
</DSection>

View File

@ -3,7 +3,7 @@
<div class="panel-body">
<div class="panel-body-contents">
<div class="sidebar-hamburger-dropdown">
<Sidebar::User::Sections @collapsableSections={{false}}/>
<Sidebar::Sections @currentUser={{this.currentUser}} @collapsableSections={{false}} />
<Sidebar::Footer @tagName="" />
</div>
</div>

View File

@ -4,6 +4,7 @@ import { inject as service } from "@ember/service";
export default class SidebarHamburgerDropdown extends Component {
@service appEvents;
@service currentUser;
@action
triggerRenderedAppEvent() {

View File

@ -0,0 +1,5 @@
{{#if @currentUser}}
<Sidebar::User::Sections @collapsableSections={{@collapsableSections}}/>
{{else}}
<Sidebar::Anonymous::Sections @collapsableSections={{@collapsableSections}}/>
{{/if}}

View File

@ -0,0 +1,3 @@
import templateOnly from "@ember/component/template-only";
export default templateOnly();

View File

@ -1,6 +1,6 @@
import { test } from "qunit";
import { visit } from "@ember/test-helpers";
import { click, visit } from "@ember/test-helpers";
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
@ -28,6 +28,18 @@ acceptance("Sidebar - Anonymous User", function (needs) {
"toggle button for anonymous user"
);
});
test("sidebar hamburger panel dropdown when sidebar has been disabled", async function (assert) {
this.siteSettings.enable_sidebar = false;
await visit("/");
await click(".hamburger-dropdown");
assert.ok(
exists(".sidebar-hamburger-dropdown .sidebar-sections-anonymous"),
"sidebar hamburger panel dropdown renders anonymous sidebar sections"
);
});
});
acceptance("Sidebar - Anonymous User - Login Required", function (needs) {