mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
DEV: Display Sidebar template for anonymous user (#17962)
Setup the stage for the sidebar which will be shown to anonymous users.
This commit is contained in:
parent
42c64abe15
commit
0f0ea75a21
@ -5,6 +5,7 @@ import { inject as service } from "@ember/service";
|
|||||||
export default class Sidebar extends Component {
|
export default class Sidebar extends Component {
|
||||||
@service appEvents;
|
@service appEvents;
|
||||||
@service site;
|
@service site;
|
||||||
|
@service currentUser;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
<div class="sidebar-sections sidebar-sections-anonymous">
|
||||||
|
{{!-- add sections for anonymous user --}}
|
||||||
|
</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
import Component from "@glimmer/component";
|
||||||
|
|
||||||
|
export default class SidebarAnonymousSectuons extends Component {}
|
@ -0,0 +1,12 @@
|
|||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
|
export default class SidebarFooter extends Component {
|
||||||
|
@service site;
|
||||||
|
@service siteSettings;
|
||||||
|
|
||||||
|
get capabilities() {
|
||||||
|
return getOwner(this).lookup("capabilities:main");
|
||||||
|
}
|
||||||
|
}
|
@ -17,11 +17,7 @@ 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.site.mobileView &&
|
|
||||||
!this.keyValueStore.getItem(HIDE_SIDEBAR_KEY);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<DSection @pageClass="has-sidebar" @class="sidebar-container" @scrollTop={{false}}>
|
<DSection @pageClass="has-sidebar" @class="sidebar-container" @scrollTop={{false}}>
|
||||||
<div class="sidebar-scroll-wrap">
|
<div class="sidebar-scroll-wrap">
|
||||||
<Sidebar::Sections @collapsableSections={{true}}/>
|
{{#if this.currentUser}}
|
||||||
<Sidebar::Footer @tagName=""/>
|
<Sidebar::Sections @collapsableSections={{true}}/>
|
||||||
|
<Sidebar::Footer />
|
||||||
|
{{else}}
|
||||||
|
<Sidebar::AnonymousSections />
|
||||||
|
<Sidebar::Footer />
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</DSection>
|
</DSection>
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
import { test } from "qunit";
|
||||||
|
|
||||||
|
import { visit } from "@ember/test-helpers";
|
||||||
|
|
||||||
|
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
|
acceptance("Sidebar - Anonymous User", function (needs) {
|
||||||
|
needs.settings({
|
||||||
|
enable_experimental_sidebar_hamburger: true,
|
||||||
|
enable_sidebar: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
test("sidebar is displayed", async function (assert) {
|
||||||
|
await visit("/");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
document.body.classList.contains("has-sidebar-page"),
|
||||||
|
"adds sidebar utility class to body"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".sidebar-container"),
|
||||||
|
"sidebar exists for anonymouse user"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
@ -4,20 +4,6 @@ import { test } from "qunit";
|
|||||||
import { click, visit } from "@ember/test-helpers";
|
import { click, visit } from "@ember/test-helpers";
|
||||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
acceptance("Sidebar - Anon User", function () {
|
|
||||||
// Don't show sidebar for anon user until we know what we want to display
|
|
||||||
test("sidebar is not displayed", async function (assert) {
|
|
||||||
await visit("/");
|
|
||||||
|
|
||||||
assert.ok(
|
|
||||||
!document.body.classList.contains("has-sidebar-page"),
|
|
||||||
"does not add sidebar utility class to body"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.ok(!exists(".sidebar-container"));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
acceptance(
|
acceptance(
|
||||||
"Sidebar - Experimental sidebar and hamburger setting disabled",
|
"Sidebar - Experimental sidebar and hamburger setting disabled",
|
||||||
function (needs) {
|
function (needs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user