DEV: Reorganize user and anonymous sidebar files into respective folders (#18039)

This commit does not change any functionality
This commit is contained in:
Alan Guo Xiang Tan 2022-08-23 13:17:59 +08:00 committed by GitHub
parent 60685e6984
commit 2bcad12848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 77 additions and 74 deletions

View File

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

View File

@ -1,3 +0,0 @@
import Component from "@glimmer/component";
export default class SidebarAnonymousSectuons extends Component {}

View File

@ -0,0 +1,3 @@
import Component from "@glimmer/component";
export default class SidebarAnonymousSections extends Component {}

View File

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

View File

@ -5,9 +5,9 @@ import { inject as service } from "@ember/service";
import { action } from "@ember/object";
import Component from "@glimmer/component";
import CategorySectionLink from "discourse/lib/sidebar/categories-section/category-section-link";
import CategorySectionLink from "discourse/lib/sidebar/user/categories-section/category-section-link";
export default class SidebarCategoriesSection extends Component {
export default class SidebarUserCategoriesSection extends Component {
@service router;
@service topicTrackingState;
@service currentUser;

View File

@ -5,15 +5,15 @@ import PermissionType from "discourse/models/permission-type";
import {
customSectionLinks,
secondaryCustomSectionLinks,
} from "discourse/lib/sidebar/custom-community-section-links";
import EverythingSectionLink from "discourse/lib/sidebar/community-section/everything-section-link";
import TrackedSectionLink from "discourse/lib/sidebar/community-section/tracked-section-link";
import MyPostsSectionLink from "discourse/lib/sidebar/community-section/my-posts-section-link";
import GroupsSectionLink from "discourse/lib/sidebar/community-section/groups-section-link";
import UsersSectionLink from "discourse/lib/sidebar/community-section/users-section-link";
import AboutSectionLink from "discourse/lib/sidebar/community-section/about-section-link";
import FAQSectionLink from "discourse/lib/sidebar/community-section/faq-section-link";
import AdminSectionLink from "discourse/lib/sidebar/community-section/admin-section-link";
} from "discourse/lib/sidebar/user/custom-community-section-links";
import EverythingSectionLink from "discourse/lib/sidebar/user/community-section/everything-section-link";
import TrackedSectionLink from "discourse/lib/sidebar/user/community-section/tracked-section-link";
import MyPostsSectionLink from "discourse/lib/sidebar/user/community-section/my-posts-section-link";
import GroupsSectionLink from "discourse/lib/sidebar/user/community-section/groups-section-link";
import UsersSectionLink from "discourse/lib/sidebar/user/community-section/users-section-link";
import AboutSectionLink from "discourse/lib/sidebar/user/community-section/about-section-link";
import FAQSectionLink from "discourse/lib/sidebar/user/community-section/faq-section-link";
import AdminSectionLink from "discourse/lib/sidebar/user/community-section/admin-section-link";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";
@ -30,7 +30,7 @@ const ADMIN_MAIN_SECTION_LINKS = [AdminSectionLink];
const MORE_SECTION_LINKS = [GroupsSectionLink, UsersSectionLink];
const MORE_SECONDARY_SECTION_LINKS = [AboutSectionLink, FAQSectionLink];
export default class SidebarCommunitySection extends Component {
export default class SidebarUserCommunitySection extends Component {
@service router;
@service topicTrackingState;
@service currentUser;

View File

@ -3,8 +3,8 @@ import { cached } from "@glimmer/tracking";
import { getOwner } from "discourse-common/lib/get-owner";
import Component from "@glimmer/component";
import { bind } from "discourse-common/utils/decorators";
import GroupMessageSectionLink from "discourse/lib/sidebar/messages-section/group-message-section-link";
import PersonalMessageSectionLink from "discourse/lib/sidebar/messages-section/personal-message-section-link";
import GroupMessageSectionLink from "discourse/lib/sidebar/user/messages-section/group-message-section-link";
import PersonalMessageSectionLink from "discourse/lib/sidebar/user/messages-section/personal-message-section-link";
import { inject as service } from "@ember/service";
export const INBOX = "inbox";
@ -23,7 +23,7 @@ export const PERSONAL_MESSAGES_INBOX_FILTERS = [
export const GROUP_MESSAGES_INBOX_FILTERS = [INBOX, NEW, UNREAD, ARCHIVE];
export default class SidebarMessagesSection extends Component {
export default class SidebarUserMessagesSection extends Component {
@service appEvents;
@service pmTopicTrackingState;
@service currentUser;

View File

@ -1,13 +1,13 @@
<div class="sidebar-sections">
<Sidebar::CommunitySection @collapsable={{@collapsableSections}}/>
<Sidebar::CategoriesSection @collapsable={{@collapsableSections}}/>
<Sidebar::User::CommunitySection @collapsable={{@collapsableSections}}/>
<Sidebar::User::CategoriesSection @collapsable={{@collapsableSections}}/>
{{#if this.siteSettings.tagging_enabled}}
<Sidebar::TagsSection @collapsable={{@collapsableSections}}/>
<Sidebar::User::TagsSection @collapsable={{@collapsableSections}}/>
{{/if}}
{{#if this.siteSettings.enable_personal_messages}}
<Sidebar::MessagesSection @collapsable={{@collapsableSections}}/>
<Sidebar::User::MessagesSection @collapsable={{@collapsableSections}}/>
{{/if}}
{{#each this.customSections as |customSection|}}

View File

@ -1,9 +1,9 @@
import Component from "@glimmer/component";
import { customSections as sidebarCustomSections } from "discourse/lib/sidebar/custom-sections";
import { customSections as sidebarCustomSections } from "discourse/lib/sidebar/user/custom-sections";
import { getOwner, setOwner } from "@ember/application";
import { inject as service } from "@ember/service";
export default class SidebarSections extends Component {
export default class SidebarUserSections extends Component {
@service siteSettings;
@service currentUser;

View File

@ -5,10 +5,10 @@ import Component from "@glimmer/component";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";
import TagSectionLink from "discourse/lib/sidebar/tags-section/tag-section-link";
import PMTagSectionLink from "discourse/lib/sidebar/tags-section/pm-tag-section-link";
import TagSectionLink from "discourse/lib/sidebar/user/tags-section/tag-section-link";
import PMTagSectionLink from "discourse/lib/sidebar/user/tags-section/pm-tag-section-link";
export default class SidebarTagsSection extends Component {
export default class SidebarUserTagsSection extends Component {
@service router;
@service topicTrackingState;
@service pmTopicTrackingState;

View File

@ -95,8 +95,8 @@ import {
import { CUSTOM_USER_SEARCH_OPTIONS } from "select-kit/components/user-chooser";
import { downloadCalendar } from "discourse/lib/download-calendar";
import { consolePrefix } from "discourse/lib/source-identifier";
import { addSectionLink as addCustomCommunitySectionLink } from "discourse/lib/sidebar/custom-community-section-links";
import { addSidebarSection } from "discourse/lib/sidebar/custom-sections";
import { addSectionLink as addCustomCommunitySectionLink } from "discourse/lib/sidebar/user/custom-community-section-links";
import { addSidebarSection } from "discourse/lib/sidebar/user/custom-sections";
import DiscourseURL from "discourse/lib/url";
import { registerNotificationTypeRenderer } from "discourse/lib/notification-types-manager";
import { registerUserMenuTab } from "discourse/lib/user-menu/tab";
@ -1674,7 +1674,7 @@ class PluginApi {
/**
* EXPERIMENTAL. Do not use.
* Support for adding a navigation link to Sidebar Community section under the "More..." links drawer by returning a
* class which extends from the BaseSectionLink class interface. See `lib/sidebar/community-section/base-section-link.js`
* class which extends from the BaseSectionLink class interface. See `lib/sidebar/user/community-section/base-section-link.js`
* for documentation on the BaseSectionLink class interface.
*
* ```
@ -1733,7 +1733,7 @@ class PluginApi {
/**
* EXPERIMENTAL. Do not use.
* Support for adding a Sidebar section by returning a class which extends from the BaseCustomSidebarSection
* class interface. See `lib/sidebar/base-custom-sidebar-section.js` for documentation on the BaseCustomSidebarSection class
* class interface. See `lib/sidebar/user/base-custom-sidebar-section.js` for documentation on the BaseCustomSidebarSection class
* interface.
*
* ```

View File

@ -1,6 +1,6 @@
import I18n from "I18n";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export default class AboutSectionLink extends BaseSectionLink {
get name() {

View File

@ -1,6 +1,6 @@
import I18n from "I18n";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export default class AdminSectionLink extends BaseSectionLink {
get name() {

View File

@ -2,7 +2,7 @@ import I18n from "I18n";
import { tracked } from "@glimmer/tracking";
import { bind } from "discourse-common/utils/decorators";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export default class EverythingSectionLink extends BaseSectionLink {
@tracked totalUnread = 0;

View File

@ -1,6 +1,6 @@
import I18n from "I18n";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export default class FAQSectionLink extends BaseSectionLink {
get name() {

View File

@ -1,6 +1,6 @@
import I18n from "I18n";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export default class GroupsSectionLink extends BaseSectionLink {
get name() {

View File

@ -1,7 +1,7 @@
import I18n from "I18n";
import { tracked } from "@glimmer/tracking";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
const USER_DRAFTS_CHANGED_EVENT = "user-drafts:changed";

View File

@ -2,7 +2,7 @@ import I18n from "I18n";
import { tracked } from "@glimmer/tracking";
import { bind } from "discourse-common/utils/decorators";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
import { isTrackedTopic } from "discourse/lib/topic-list-tracked-filter";
export default class TrackedSectionLink extends BaseSectionLink {

View File

@ -1,6 +1,6 @@
import I18n from "I18n";
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export default class UsersSectionLink extends BaseSectionLink {
get name() {

View File

@ -1,4 +1,4 @@
import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";
import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link";
export let customSectionLinks = [];
export let secondaryCustomSectionLinks = [];

View File

@ -1,5 +1,5 @@
import BaseCustomSidebarSection from "discourse/lib/sidebar/base-custom-sidebar-section";
import BaseCustomSidebarSectionLink from "discourse/lib/sidebar/base-custom-sidebar-section-link";
import BaseCustomSidebarSection from "discourse/lib/sidebar/user/base-custom-sidebar-section";
import BaseCustomSidebarSectionLink from "discourse/lib/sidebar/user/base-custom-sidebar-section-link";
export const customSections = [];

View File

@ -1,7 +1,7 @@
import I18n from "I18n";
import { capitalize } from "@ember/string";
import MessageSectionLink from "discourse/lib/sidebar/messages-section/message-section-link";
import MessageSectionLink from "discourse/lib/sidebar/user/messages-section/message-section-link";
export default class GroupMessageSectionLink extends MessageSectionLink {
routeNames = new Set([

View File

@ -4,7 +4,7 @@ import {
INBOX,
NEW,
UNREAD,
} from "discourse/components/sidebar/messages-section";
} from "discourse/components/sidebar/user/messages-section";
export default class MessageSectionLink {
@tracked shouldDisplay = this._isInbox;

View File

@ -1,6 +1,6 @@
import I18n from "I18n";
import MessageSectionLink from "discourse/lib/sidebar/messages-section/message-section-link";
import MessageSectionLink from "discourse/lib/sidebar/user/messages-section/message-section-link";
export default class PersonalMessageSectionLink extends MessageSectionLink {
routeNames = new Set([

View File

@ -9,7 +9,7 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { withPluginApi } from "discourse/lib/plugin-api";
import { resetSidebarSection } from "discourse/lib/sidebar/custom-sections";
import { resetSidebarSection } from "discourse/lib/sidebar/user/custom-sections";
import { bind } from "discourse-common/utils/decorators";
acceptance("Sidebar - Plugin API", function (needs) {

View File

@ -17,7 +17,7 @@ import categoryFixture from "discourse/tests/fixtures/category-fixtures";
import { cloneJSON } from "discourse-common/lib/object";
acceptance(
"Sidebar - Categories Section - suppress_uncategorized_badge enabled",
"Sidebar - Logged on user - Categories Section - suppress_uncategorized_badge enabled",
function (needs) {
needs.settings({
suppress_uncategorized_badge: true,
@ -55,7 +55,7 @@ acceptance(
}
);
acceptance("Sidebar - Categories Section", function (needs) {
acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
needs.user({
sidebar_category_ids: [],
sidebar_tags: [],

View File

@ -21,7 +21,7 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import Site from "discourse/models/site";
import { NotificationLevels } from "discourse/lib/notification-levels";
acceptance("Sidebar - Community Section", function (needs) {
acceptance("Sidebar - Logged on user - Community Section", function (needs) {
needs.user({
tracked_tags: ["tag1"],
watched_tags: ["tag2"],

View File

@ -12,7 +12,7 @@ import {
import { NotificationLevels } from "discourse/lib/notification-levels";
acceptance(
"Sidebar - Messages Section - enable_personal_messages disabled",
"Sidebar - Logged on user - Messages Section - enable_personal_messages disabled",
function (needs) {
needs.user();
@ -34,7 +34,7 @@ acceptance(
);
acceptance(
"Sidebar - Messages Section - enable_personal_messages enabled",
"Sidebar - Logged on user - Messages Section - enable_personal_messages enabled",
function (needs) {
needs.user();

View File

@ -13,26 +13,29 @@ import {
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,
});
acceptance(
"Sidebar - Logged on user - Tags section - tagging disabled",
function (needs) {
needs.settings({
tagging_enabled: false,
enable_experimental_sidebar_hamburger: true,
enable_sidebar: true,
});
needs.user();
needs.user();
test("tags section is not shown", async function (assert) {
await visit("/");
test("tags section is not shown", async function (assert) {
await visit("/");
assert.ok(
!exists(".sidebar-section-tags"),
"does not display the tags section"
);
});
});
assert.ok(
!exists(".sidebar-section-tags"),
"does not display the tags section"
);
});
}
);
acceptance("Sidebar - Tags section", function (needs) {
acceptance("Sidebar - Logged on user - Tags section", function (needs) {
needs.settings({
tagging_enabled: true,
enable_experimental_sidebar_hamburger: true,

View File

@ -5,7 +5,7 @@ import { click, visit } from "@ember/test-helpers";
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
acceptance(
"Sidebar - Experimental sidebar and hamburger setting disabled",
"Sidebar - Logged on user - Experimental sidebar and hamburger setting disabled",
function (needs) {
needs.user();
@ -23,7 +23,7 @@ acceptance(
);
acceptance(
"Sidebar - Experimental sidebar and hamburger setting enabled - Sidebar disabled",
"Sidebar - Logged on user - Experimental sidebar and hamburger setting enabled - Sidebar disabled",
function (needs) {
needs.user();

View File

@ -62,7 +62,7 @@ import {
setTestPresence,
} from "discourse/lib/user-presence";
import PreloadStore from "discourse/lib/preload-store";
import { resetDefaultSectionLinks as resetTopicsSectionLinks } from "discourse/lib/sidebar/custom-community-section-links";
import { resetDefaultSectionLinks as resetTopicsSectionLinks } from "discourse/lib/sidebar/user/custom-community-section-links";
import {
clearBlockDecorateCallbacks,
clearTagDecorateCallbacks,
@ -71,7 +71,7 @@ import {
import { clearTagsHtmlCallbacks } from "discourse/lib/render-tags";
import { clearToolbarCallbacks } from "discourse/components/d-editor";
import { clearExtraHeaderIcons } from "discourse/widgets/header";
import { resetSidebarSection } from "discourse/lib/sidebar/custom-sections";
import { resetSidebarSection } from "discourse/lib/sidebar/user/custom-sections";
import { resetNotificationTypeRenderers } from "discourse/lib/notification-types-manager";
import { resetUserMenuTabs } from "discourse/lib/user-menu/tab";