DEV: Introduce SiteSetting to enable/disable Sidebar. (#17662)
This commit removes the ability to enable/disable the Sidebar on a per user basis and introduces a site wide setting. For testing purposes, sidebar can be enabled/disabled via the `enable_sidebar=1` or `enable_sidebar=0` query param.
This commit is contained in:
parent
83f4e45664
commit
3bd5f2d411
|
@ -368,7 +368,7 @@ const SiteHeaderComponent = MountWidget.extend(
|
|||
return {
|
||||
topic: this._topic,
|
||||
canSignUp: this.canSignUp,
|
||||
sidebarDocked: this.sidebarDocked,
|
||||
sidebarEnabled: this.sidebarEnabled,
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -5,11 +5,14 @@ import { inject as service } from "@ember/service";
|
|||
import { action } from "@ember/object";
|
||||
|
||||
export default Controller.extend({
|
||||
queryParams: ["enable_sidebar"],
|
||||
|
||||
showTop: true,
|
||||
showFooter: false,
|
||||
router: service(),
|
||||
showSidebar: null,
|
||||
hideSidebarKey: "sidebar-hidden",
|
||||
enable_sidebar: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
@ -42,6 +45,19 @@ export default Controller.extend({
|
|||
document.querySelector("body").classList.remove("sidebar-animate");
|
||||
},
|
||||
|
||||
@discourseComputed("enable_sidebar", "siteSettings.enable_sidebar")
|
||||
sidebarEnabled(sidebarQueryParamOverride, enableSidebar) {
|
||||
if (sidebarQueryParamOverride === "1") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sidebarQueryParamOverride === "0") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return enableSidebar;
|
||||
},
|
||||
|
||||
@action
|
||||
toggleSidebar() {
|
||||
// enables CSS transitions, but not on did-insert
|
||||
|
@ -52,10 +68,6 @@ export default Controller.extend({
|
|||
this.toggleProperty("showSidebar");
|
||||
|
||||
if (this.site.desktopView) {
|
||||
this.appEvents.trigger("header:keyboard-trigger", {
|
||||
type: "hamburger",
|
||||
});
|
||||
|
||||
if (this.showSidebar) {
|
||||
this.keyValueStore.removeItem(this.hideSidebarKey);
|
||||
} else {
|
||||
|
|
|
@ -58,7 +58,6 @@ export default Controller.extend({
|
|||
"skip_new_user_tips",
|
||||
"color_scheme_id",
|
||||
"dark_scheme_id",
|
||||
"enable_experimental_sidebar",
|
||||
];
|
||||
|
||||
if (makeThemeDefault) {
|
||||
|
|
|
@ -106,7 +106,6 @@ let userOptionFields = [
|
|||
"skip_new_user_tips",
|
||||
"default_calendar",
|
||||
"bookmark_auto_delete_preference",
|
||||
"enable_experimental_sidebar",
|
||||
];
|
||||
|
||||
export function addSaveableUserOptionField(fieldName) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
@toggleMobileView={{route-action "toggleMobileView"}}
|
||||
@toggleAnonymous={{route-action "toggleAnonymous"}}
|
||||
@logout={{route-action "logout"}}
|
||||
@sidebarDocked={{and this.currentUser.experimental_sidebar_enabled this.showSidebar this.site.desktopView}}
|
||||
@sidebarEnabled={{this.sidebarEnabled}}
|
||||
@toggleSidebar={{action "toggleSidebar"}} />
|
||||
|
||||
<SoftwareUpdatePrompt />
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
<div class="sidebar-wrapper">
|
||||
{{!-- empty div allows for animation --}}
|
||||
{{#if (and this.currentUser.experimental_sidebar_enabled this.showSidebar)}}
|
||||
{{#if (and this.siteSettings.enable_experimental_sidebar_hamburger this.sidebarEnabled this.showSidebar)}}
|
||||
<Sidebar @toggleSidebar={{action "toggleSidebar"}}/>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -18,13 +18,6 @@
|
|||
@title="keyboard_shortcuts_help.title"
|
||||
@icon="keyboard"
|
||||
@class="sidebar-footer-actions-button sidebar-footer-actions-keyboard-shortcuts" />
|
||||
|
||||
{{#if (and this.site.desktopView (not @sidebarDocked))}}
|
||||
<DButton
|
||||
@action={{@toggleSidebar}}
|
||||
@icon="thumbtack"
|
||||
@class="sidebar-footer-actions-button sidebar-footer-actions-dock-toggle"/>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="panel-body-content">
|
||||
<div class="sidebar-hamburger-dropdown">
|
||||
<Sidebar::Sections @collapsableSections={{false}}/>
|
||||
<Sidebar::Footer @toggleSidebar={{route-action "toggleSidebar"}} @sidebarDocked={{@sidebarDocked}} @tagName="" />
|
||||
<Sidebar::Footer @toggleSidebar={{route-action "toggleSidebar"}} @tagName="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
</LinkTo>
|
||||
</li>
|
||||
|
||||
{{#if this.siteSettings.enable_experimental_sidebar}}
|
||||
{{#if this.siteSettings.enable_experimental_sidebar_hamburger}}
|
||||
<li class="indent nav-sidebar">
|
||||
<LinkTo @route="preferences.sidebar">
|
||||
{{i18n "user.preferences_nav.sidebar"}}
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
<div class="control-group preferences-sidebar-options">
|
||||
<legend class="control-label">{{i18n "user.experimental_sidebar.options"}}</legend>
|
||||
|
||||
<PreferenceCheckbox
|
||||
@labelKey="user.experimental_sidebar.enable"
|
||||
@checked={{this.model.user_option.enable_experimental_sidebar}}
|
||||
@class="preferences-sidebar-enable-checkbox" />
|
||||
</div>
|
||||
|
||||
{{#if this.model.experimental_sidebar_enabled}}
|
||||
<div class="control-group preferences-sidebar-categories">
|
||||
<legend class="control-label">{{i18n "user.experimental_sidebar.categories_section"}}</legend>
|
||||
|
||||
|
@ -44,6 +34,5 @@
|
|||
<div class="instructions">{{i18n "user.experimental_sidebar.tags_section_instruction"}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
<SaveControls @model={{this.model}} @action={{action "save"}} @saved={{this.saved}} />
|
||||
|
|
|
@ -337,15 +337,12 @@ createWidget("revamped-hamburger-menu-wrapper", {
|
|||
return { "data-click-outside": true };
|
||||
},
|
||||
|
||||
html(attrs) {
|
||||
html() {
|
||||
return [
|
||||
new RenderGlimmer(
|
||||
this,
|
||||
"div.widget-component-connector",
|
||||
hbs`<Sidebar::HamburgerDropdown @sidebarDocked={{@data.sidebarDocked}} />`,
|
||||
{
|
||||
sidebarDocked: attrs.sidebarDocked,
|
||||
}
|
||||
hbs`<Sidebar::HamburgerDropdown />`
|
||||
),
|
||||
];
|
||||
},
|
||||
|
@ -426,12 +423,10 @@ export default createWidget("header", {
|
|||
})
|
||||
);
|
||||
} else if (state.hamburgerVisible) {
|
||||
if (this.currentUser?.experimental_sidebar_enabled) {
|
||||
panels.push(
|
||||
this.attach("revamped-hamburger-menu-wrapper", {
|
||||
sidebarDocked: attrs.sidebarDocked,
|
||||
})
|
||||
);
|
||||
if (this.siteSettings.enable_experimental_sidebar_hamburger) {
|
||||
if (!attrs.sidebarEnabled) {
|
||||
panels.push(this.attach("revamped-hamburger-menu-wrapper", {}));
|
||||
}
|
||||
} else {
|
||||
panels.push(this.attach("hamburger-menu"));
|
||||
}
|
||||
|
@ -547,8 +542,8 @@ export default createWidget("header", {
|
|||
|
||||
toggleHamburger() {
|
||||
if (
|
||||
this.currentUser?.experimental_sidebar_enabled &&
|
||||
this.site.mobileView
|
||||
this.siteSettings.enable_experimental_sidebar_hamburger &&
|
||||
(this.attrs.sidebarEnabled || this.site.mobileView)
|
||||
) {
|
||||
this.sendWidgetAction("toggleSidebar");
|
||||
} else {
|
||||
|
|
|
@ -10,8 +10,6 @@ import {
|
|||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
import { undockSidebar } from "discourse/tests/helpers/sidebar-helpers";
|
||||
|
||||
import Site from "discourse/models/site";
|
||||
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
|
||||
import categoryFixture from "discourse/tests/fixtures/category-fixtures";
|
||||
|
@ -22,9 +20,11 @@ acceptance(
|
|||
function (needs) {
|
||||
needs.settings({
|
||||
suppress_uncategorized_badge: true,
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.user({ experimental_sidebar_enabled: true });
|
||||
needs.user();
|
||||
|
||||
test("uncategorized category is not shown", async function (assert) {
|
||||
const categories = Site.current().categories;
|
||||
|
@ -56,12 +56,13 @@ acceptance(
|
|||
|
||||
acceptance("Sidebar - Categories Section", function (needs) {
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
sidebar_category_ids: [],
|
||||
sidebar_tag_names: [],
|
||||
});
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
suppress_uncategorized_badge: false,
|
||||
});
|
||||
|
||||
|
@ -397,10 +398,10 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
topicTrackingState.stateChangeCallbacks
|
||||
).length;
|
||||
|
||||
await undockSidebar();
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.strictEqual(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||
assert.ok(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length <
|
||||
initialCallbackCount
|
||||
);
|
||||
});
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
publishToMessageBus,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { undockSidebar } from "discourse/tests/helpers/sidebar-helpers";
|
||||
import topicFixtures from "discourse/tests/fixtures/discovery-fixtures";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
|
@ -18,12 +17,16 @@ import { NotificationLevels } from "discourse/lib/notification-levels";
|
|||
|
||||
acceptance("Sidebar - Community Section", function (needs) {
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
tracked_tags: ["tag1"],
|
||||
watched_tags: ["tag2"],
|
||||
watching_first_post_tags: ["tag3"],
|
||||
});
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/new.json", () => {
|
||||
return helper.response(cloneJSON(topicFixtures["/latest.json"]));
|
||||
|
@ -753,10 +756,10 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
topicTrackingState.stateChangeCallbacks
|
||||
).length;
|
||||
|
||||
await undockSidebar();
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.strictEqual(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||
assert.ok(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length <
|
||||
initialCallbackCount
|
||||
);
|
||||
});
|
||||
|
|
|
@ -14,11 +14,11 @@ import { NotificationLevels } from "discourse/lib/notification-levels";
|
|||
acceptance(
|
||||
"Sidebar - Messages Section - enable_personal_messages disabled",
|
||||
function (needs) {
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
});
|
||||
needs.user();
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
enable_personal_messages: false,
|
||||
});
|
||||
|
||||
|
@ -36,8 +36,11 @@ acceptance(
|
|||
acceptance(
|
||||
"Sidebar - Messages Section - enable_personal_messages enabled",
|
||||
function (needs) {
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
needs.user();
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
|
|
|
@ -3,7 +3,13 @@ import { click, visit } from "@ember/test-helpers";
|
|||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Sidebar - Mobile - User with sidebar enabled", function (needs) {
|
||||
needs.user({ experimental_sidebar_enabled: true });
|
||||
needs.user();
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.mobileView();
|
||||
|
||||
test("hidden by default", async function (assert) {
|
||||
|
@ -17,11 +23,6 @@ acceptance("Sidebar - Mobile - User with sidebar enabled", function (needs) {
|
|||
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.notOk(
|
||||
exists(".sidebar-footer-actions-dock-toggle"),
|
||||
"button to dock sidebar is not displayed"
|
||||
);
|
||||
|
||||
assert.ok(exists(".sidebar-container"), "sidebar is displayed");
|
||||
|
||||
await click("#main-outlet");
|
||||
|
|
|
@ -10,10 +10,14 @@ import {
|
|||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { resetSidebarSection } from "discourse/lib/sidebar/custom-sections";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
import { undockSidebar } from "discourse/tests/helpers/sidebar-helpers";
|
||||
|
||||
acceptance("Sidebar - Plugin API", function (needs) {
|
||||
needs.user({ experimental_sidebar_enabled: true });
|
||||
needs.user();
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.hooks.afterEach(() => {
|
||||
resetSidebarSection();
|
||||
|
@ -339,7 +343,7 @@ acceptance("Sidebar - Plugin API", function (needs) {
|
|||
"displays hover button with correct title"
|
||||
);
|
||||
|
||||
await undockSidebar();
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.strictEqual(
|
||||
linkDestroy,
|
||||
|
|
|
@ -9,16 +9,17 @@ import {
|
|||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { undockSidebar } from "discourse/tests/helpers/sidebar-helpers";
|
||||
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
|
||||
acceptance("Sidebar - Tags section - tagging disabled", function (needs) {
|
||||
needs.settings({
|
||||
tagging_enabled: false,
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.user({ experimental_sidebar_enabled: true });
|
||||
needs.user();
|
||||
|
||||
test("tags section is not shown", async function (assert) {
|
||||
await visit("/");
|
||||
|
@ -33,10 +34,11 @@ acceptance("Sidebar - Tags section - tagging disabled", function (needs) {
|
|||
acceptance("Sidebar - Tags section", function (needs) {
|
||||
needs.settings({
|
||||
tagging_enabled: true,
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
tracked_tags: ["tag1"],
|
||||
watched_tags: ["tag2", "tag3"],
|
||||
watching_first_post_tags: [],
|
||||
|
@ -324,10 +326,10 @@ acceptance("Sidebar - Tags section", function (needs) {
|
|||
topicTrackingState.stateChangeCallbacks
|
||||
).length;
|
||||
|
||||
await undockSidebar();
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.strictEqual(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||
assert.ok(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length <
|
||||
initialCallbackCount
|
||||
);
|
||||
});
|
||||
|
|
|
@ -7,7 +7,6 @@ import {
|
|||
exists,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { undockSidebar } from "discourse/tests/helpers/sidebar-helpers";
|
||||
|
||||
acceptance("Sidebar - Anon User", function () {
|
||||
// Don't show sidebar for anon user until we know what we want to display
|
||||
|
@ -23,23 +22,81 @@ acceptance("Sidebar - Anon User", function () {
|
|||
});
|
||||
});
|
||||
|
||||
acceptance("Sidebar - User with sidebar disabled", function (needs) {
|
||||
needs.user({ experimental_sidebar_enabled: false });
|
||||
acceptance(
|
||||
"Sidebar - Experimental sidebar and hamburger setting disabled",
|
||||
function (needs) {
|
||||
needs.user();
|
||||
|
||||
test("sidebar is not displayed", async function (assert) {
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: false,
|
||||
});
|
||||
|
||||
test("clicking header hamburger icon displays old hamburger drodown", async function (assert) {
|
||||
await visit("/");
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.ok(
|
||||
!document.body.classList.contains("has-sidebar-page"),
|
||||
"does not add sidebar utility class to body"
|
||||
assert.ok(exists(".menu-container-general-links"));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
assert.ok(!exists(".sidebar-container"));
|
||||
});
|
||||
acceptance(
|
||||
"Sidebar - Experimental sidebar and hamburger setting enabled - Sidebar disabled",
|
||||
function (needs) {
|
||||
needs.user();
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: false,
|
||||
});
|
||||
|
||||
acceptance("Sidebar - User with sidebar enabled", function (needs) {
|
||||
needs.user({ experimental_sidebar_enabled: true });
|
||||
test("showing and hiding sidebar", async function (assert) {
|
||||
await visit("/");
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.ok(
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"displays the sidebar dropdown"
|
||||
);
|
||||
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.notOk(
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"hides the sidebar dropdown"
|
||||
);
|
||||
});
|
||||
|
||||
test("'enable_sidebar' query param override to enable sidebar", async function (assert) {
|
||||
await visit("/?enable_sidebar=1");
|
||||
|
||||
assert.ok(exists(".sidebar-container"), "sidebar is displayed");
|
||||
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.notOk(
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"does not display the sidebar dropdown"
|
||||
);
|
||||
|
||||
assert.notOk(exists(".sidebar-container"), "sidebar is hidden");
|
||||
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.ok(exists(".sidebar-container"), "sidebar is displayed");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
acceptance(
|
||||
"Sidebar - Experimental sidebar and hamburger setting enabled - Sidebar enabled",
|
||||
function (needs) {
|
||||
needs.user();
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
});
|
||||
|
||||
test("navigating to about route using sidebar", async function (assert) {
|
||||
await visit("/");
|
||||
|
@ -77,7 +134,7 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
|
|||
assert.notOk(exists(".sidebar-footer-link-admin"));
|
||||
});
|
||||
|
||||
test("undocking and docking sidebar", async function (assert) {
|
||||
test("showing and hiding sidebar", async function (assert) {
|
||||
await visit("/");
|
||||
|
||||
assert.ok(
|
||||
|
@ -85,9 +142,12 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
|
|||
"adds sidebar utility class to body"
|
||||
);
|
||||
|
||||
assert.ok(exists(".sidebar-container"), "displays the sidebar by default");
|
||||
assert.ok(
|
||||
exists(".sidebar-container"),
|
||||
"displays the sidebar by default"
|
||||
);
|
||||
|
||||
await undockSidebar();
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.ok(
|
||||
!document.body.classList.contains("has-sidebar-page"),
|
||||
|
@ -96,33 +156,29 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {
|
|||
|
||||
assert.ok(!exists(".sidebar-container"), "hides the sidebar");
|
||||
|
||||
assert.ok(
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"displays the sidebar in hamburger dropdown automatically after undocking"
|
||||
);
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
await click("button.sidebar-footer-actions-dock-toggle");
|
||||
assert.ok(exists(".sidebar-container"), "displays the sidebar");
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
exists(".sidebar-container"),
|
||||
"displays the sidebar after docking"
|
||||
);
|
||||
test("'enable_sidebar' query param override to disable sidebar", async function (assert) {
|
||||
await visit("/?enable_sidebar=0");
|
||||
|
||||
assert.notOk(
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"hides the sidebar in hamburger dropdown automatically after docking"
|
||||
);
|
||||
assert.notOk(exists(".sidebar-container"), "sidebar is not displayed");
|
||||
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.ok(
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"displays the sidebar in hamburger dropdown even when sidebar is docked"
|
||||
"displays the sidebar dropdown"
|
||||
);
|
||||
|
||||
await click(".hamburger-dropdown");
|
||||
|
||||
assert.notOk(
|
||||
exists(".sidebar-hamburger-dropdown .sidebar-footer-actions-dock-toggle"),
|
||||
"does not display sidebar dock toggle in hamburger dropdown when sidebar is docked"
|
||||
exists(".sidebar-hamburger-dropdown"),
|
||||
"hides the sidebar dropdown"
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -9,31 +9,15 @@ import {
|
|||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
acceptance("User Preferences - Sidebar - Tagging Disabled", function (needs) {
|
||||
needs.settings({
|
||||
tagging_enabled: false,
|
||||
});
|
||||
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
sidebar_category_ids: [],
|
||||
});
|
||||
|
||||
test("user should not see tag chooser", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences/sidebar");
|
||||
|
||||
assert.ok(!exists(".tag-chooser"), "tag chooser is not displayed");
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("User Preferences - Sidebar", function (needs) {
|
||||
needs.user({
|
||||
experimental_sidebar_enabled: true,
|
||||
sidebar_category_ids: [],
|
||||
sidebar_tag_names: [],
|
||||
});
|
||||
|
||||
needs.settings({
|
||||
enable_experimental_sidebar_hamburger: true,
|
||||
enable_sidebar: true,
|
||||
tagging_enabled: true,
|
||||
});
|
||||
|
||||
|
@ -60,6 +44,14 @@ acceptance("User Preferences - Sidebar", function (needs) {
|
|||
});
|
||||
});
|
||||
|
||||
test("user should not see tag chooser when tagging is disabled", async function (assert) {
|
||||
this.siteSettings.tagging_enabled = false;
|
||||
|
||||
await visit("/u/eviltrout/preferences/sidebar");
|
||||
|
||||
assert.ok(!exists(".tag-chooser"), "tag chooser is not displayed");
|
||||
});
|
||||
|
||||
test("user encountering error when adding categories to sidebar", async function (assert) {
|
||||
updateCurrentUser({ sidebar_category_ids: [6] });
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import { click } from "@ember/test-helpers";
|
||||
|
||||
export async function undockSidebar() {
|
||||
await click("button.sidebar-footer-actions-dock-toggle");
|
||||
}
|
|
@ -53,15 +53,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.has-sidebar-page {
|
||||
.sidebar-footer-actions-dock-toggle {
|
||||
.d-icon {
|
||||
transform: rotate(180deg);
|
||||
top: -0.1em; // optical alignment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-footer-wrapper {
|
||||
background: var(--primary-very-low);
|
||||
.desktop-view & {
|
||||
|
|
|
@ -1824,7 +1824,7 @@ class UsersController < ApplicationController
|
|||
permitted.concat UserUpdater::TAG_NAMES.keys
|
||||
permitted << UserUpdater::NOTIFICATION_SCHEDULE_ATTRS
|
||||
|
||||
if current_user&.user_option&.enable_experimental_sidebar
|
||||
if SiteSetting.enable_experimental_sidebar_hamburger
|
||||
if params.has_key?(:sidebar_category_ids) && params[:sidebar_category_ids].blank?
|
||||
params[:sidebar_category_ids] = []
|
||||
end
|
||||
|
|
|
@ -277,7 +277,7 @@ class TopicTrackingState
|
|||
end
|
||||
|
||||
def self.include_tags_in_report?
|
||||
SiteSetting.tagging_enabled && (@include_tags_in_report || SiteSetting.enable_experimental_sidebar)
|
||||
SiteSetting.tagging_enabled && (@include_tags_in_report || SiteSetting.enable_experimental_sidebar_hamburger)
|
||||
end
|
||||
|
||||
def self.include_tags_in_report=(v)
|
||||
|
|
|
@ -71,7 +71,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||
:default_calendar,
|
||||
:bookmark_auto_delete_preference,
|
||||
:pending_posts_count,
|
||||
:experimental_sidebar_enabled,
|
||||
:status,
|
||||
:sidebar_category_ids,
|
||||
:sidebar_tag_names,
|
||||
|
@ -309,20 +308,12 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||
Draft.has_topic_draft(object)
|
||||
end
|
||||
|
||||
def experimental_sidebar_enabled
|
||||
object.user_option.enable_experimental_sidebar
|
||||
end
|
||||
|
||||
def include_experimental_sidebar_enabled?
|
||||
SiteSetting.enable_experimental_sidebar
|
||||
end
|
||||
|
||||
def sidebar_category_ids
|
||||
object.category_sidebar_section_links.pluck(:linkable_id)
|
||||
end
|
||||
|
||||
def include_sidebar_category_ids?
|
||||
include_experimental_sidebar_enabled? && object.user_option.enable_experimental_sidebar
|
||||
SiteSetting.enable_experimental_sidebar_hamburger
|
||||
end
|
||||
|
||||
def sidebar_tag_names
|
||||
|
|
|
@ -34,8 +34,7 @@ class UserOptionSerializer < ApplicationSerializer
|
|||
:timezone,
|
||||
:skip_new_user_tips,
|
||||
:default_calendar,
|
||||
:oldest_search_log_date,
|
||||
:enable_experimental_sidebar
|
||||
:oldest_search_log_date
|
||||
|
||||
def auto_track_topics_after_msecs
|
||||
object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs
|
||||
|
@ -52,9 +51,4 @@ class UserOptionSerializer < ApplicationSerializer
|
|||
def theme_ids
|
||||
object.theme_ids.presence || [SiteSetting.default_theme_id]
|
||||
end
|
||||
|
||||
def include_enable_experimental_sidebar?
|
||||
SiteSetting.enable_experimental_sidebar
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -47,8 +47,7 @@ class UserUpdater
|
|||
:title_count_mode,
|
||||
:timezone,
|
||||
:skip_new_user_tips,
|
||||
:default_calendar,
|
||||
:enable_experimental_sidebar
|
||||
:default_calendar
|
||||
]
|
||||
|
||||
NOTIFICATION_SCHEDULE_ATTRS = -> {
|
||||
|
|
|
@ -1985,7 +1985,11 @@ developer:
|
|||
enable_safe_mode:
|
||||
default: true
|
||||
client: true
|
||||
enable_experimental_sidebar:
|
||||
enable_experimental_sidebar_hamburger:
|
||||
default: false
|
||||
client: true
|
||||
hidden: true
|
||||
enable_sidebar:
|
||||
default: false
|
||||
client: true
|
||||
hidden: true
|
||||
|
|
|
@ -593,13 +593,13 @@ describe TopicTrackingState do
|
|||
)
|
||||
end
|
||||
|
||||
it "includes tags when SiteSetting.enable_experimental_sidebar is true" do
|
||||
it "includes tags when SiteSetting.enable_experimental_sidebar_hamburger is true" do
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
row = report[0]
|
||||
expect(row.respond_to?(:tags)).to eq(false)
|
||||
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = true
|
||||
|
||||
report = TopicTrackingState.report(user)
|
||||
expect(report.length).to eq(1)
|
||||
|
|
|
@ -2300,20 +2300,7 @@ describe UsersController do
|
|||
|
||||
context 'experimental sidebar' do
|
||||
before do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
user.user_option.update!(enable_experimental_sidebar: true)
|
||||
end
|
||||
|
||||
it "should allow user to update UserOption#enable_experimental_sidebar" do
|
||||
put "/u/#{user.username}.json", params: { enable_experimental_sidebar: 'false' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.reload.user_option.enable_experimental_sidebar).to eq(false)
|
||||
|
||||
put "/u/#{user.username}.json", params: { enable_experimental_sidebar: 'true' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.reload.user_option.enable_experimental_sidebar).to eq(true)
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = true
|
||||
end
|
||||
|
||||
it 'does not remove category or tag sidebar section links when params are not present' do
|
||||
|
@ -3979,23 +3966,6 @@ describe UsersController do
|
|||
expect(topic_post_count[topic.id.to_s]).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it "includes UserOption#enable_experimental_sidebar when SiteSetting.enable_experimental_sidebar is true" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
user1.user_option.update!(enable_experimental_sidebar: true)
|
||||
|
||||
get "/u/#{user1.username}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["user"]["user_option"]["enable_experimental_sidebar"]).to eq(true)
|
||||
end
|
||||
|
||||
it "does not include UserOption#enable_experimental_sidebar when SiteSetting.enable_experimental_sidebar is false" do
|
||||
get "/u/#{user1.username}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["user"]["user_option"]["enable_experimental_sidebar"]).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
it "should be able to view a user" do
|
||||
|
|
|
@ -224,8 +224,8 @@ RSpec.describe CurrentUserSerializer do
|
|||
fab!(:tag_sidebar_section_link) { Fabricate(:tag_sidebar_section_link, user: user) }
|
||||
fab!(:tag_sidebar_section_link_2) { Fabricate(:tag_sidebar_section_link, user: user) }
|
||||
|
||||
it "is not included when SiteSeting.enable_experimental_sidebar is false" do
|
||||
SiteSetting.enable_experimental_sidebar = false
|
||||
it "is not included when SiteSeting.enable_experimental_sidebar_hamburger is false" do
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = false
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
|
@ -233,7 +233,7 @@ RSpec.describe CurrentUserSerializer do
|
|||
end
|
||||
|
||||
it "is not included when SiteSeting.tagging_enabled is false" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = true
|
||||
SiteSetting.tagging_enabled = false
|
||||
|
||||
json = serializer.as_json
|
||||
|
@ -241,20 +241,18 @@ RSpec.describe CurrentUserSerializer do
|
|||
expect(json[:sidebar_tag_names]).to eq(nil)
|
||||
end
|
||||
|
||||
it "is not included when experimental sidebar has not been enabled by user" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
it "is not included when experimental sidebar has not been enabled" do
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = false
|
||||
SiteSetting.tagging_enabled = true
|
||||
user.user_option.update!(enable_experimental_sidebar: false)
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:sidebar_tag_names]).to eq(nil)
|
||||
end
|
||||
|
||||
it "is present when experimental sidebar has been enabled by user" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
it "is present when experimental sidebar has been enabled" do
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = true
|
||||
SiteSetting.tagging_enabled = true
|
||||
user.user_option.update!(enable_experimental_sidebar: true)
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
|
@ -269,26 +267,24 @@ RSpec.describe CurrentUserSerializer do
|
|||
fab!(:category_sidebar_section_link) { Fabricate(:category_sidebar_section_link, user: user) }
|
||||
fab!(:category_sidebar_section_link_2) { Fabricate(:category_sidebar_section_link, user: user) }
|
||||
|
||||
it "is not included when SiteSeting.enable_experimental_sidebar is false" do
|
||||
SiteSetting.enable_experimental_sidebar = false
|
||||
it "is not included when SiteSeting.enable_experimental_sidebar_hamburger is false" do
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = false
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:sidebar_category_ids]).to eq(nil)
|
||||
end
|
||||
|
||||
it "is not included when experimental sidebar has not been enabled by user" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
user.user_option.update!(enable_experimental_sidebar: false)
|
||||
it "is not included when experimental sidebar has not been enabled" do
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = false
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:sidebar_category_ids]).to eq(nil)
|
||||
end
|
||||
|
||||
it "is present when experimental sidebar has been enabled by user" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
user.user_option.update!(enable_experimental_sidebar: true)
|
||||
it "is present when experimental sidebar has been enabled" do
|
||||
SiteSetting.enable_experimental_sidebar_hamburger = true
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
|
|
Loading…
Reference in New Issue