mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: move sidebar community section to database (#21166)
* DEV: move sidebar community section to database Before, community section was hard-coded. In the future, we are planning to allow admins to edit it. Therefore, it has to be moved to database to `custom_sections` table. Few steps and simplifications has to be made: - custom section was hidden behind `enable_custom_sidebar_sections` feature flag. It has to be deleted so all forums, see community section; - migration to add `section_type` column to sidebar section to show it is a special type; - migration to add `segment` column to sidebar links to determine if link should be displayed in primary section or in more section; - simplify more section to have one level only (secondary section links are merged); - ensure that links like `everything` are correctly tracking state; - make user an anonymous links position consistence. For example, from now on `faq` link for user and anonymous is visible in more tab; - delete old community-section template.
This commit is contained in:
committed by
GitHub
parent
afc1611be7
commit
709fa24558
@@ -69,7 +69,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
:sidebar_category_ids,
|
||||
:sidebar_list_destination,
|
||||
:sidebar_sections,
|
||||
:custom_sidebar_sections_enabled,
|
||||
:new_new_view_enabled?
|
||||
|
||||
delegate :user_stat, to: :object, private: true
|
||||
@@ -82,7 +81,7 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
.public_sections
|
||||
.or(SidebarSection.where(user_id: object.id))
|
||||
.includes(sidebar_section_links: :linkable)
|
||||
.order("(public IS TRUE) DESC")
|
||||
.order("(section_type IS NOT NULL) DESC, (public IS TRUE) DESC")
|
||||
.map { |section| SidebarSectionSerializer.new(section, root: false) }
|
||||
end
|
||||
|
||||
@@ -301,12 +300,4 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
def include_new_personal_messages_notifications_count?
|
||||
redesigned_user_menu_enabled
|
||||
end
|
||||
|
||||
def custom_sidebar_sections_enabled
|
||||
if SiteSetting.enable_custom_sidebar_sections.present?
|
||||
object.in_any_groups?(SiteSetting.enable_custom_sidebar_sections_map)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SidebarSectionSerializer < ApplicationSerializer
|
||||
attributes :id, :title, :links, :slug, :public
|
||||
attributes :id, :title, :links, :slug, :public, :section_type
|
||||
|
||||
def links
|
||||
object.sidebar_section_links.map { |link| SidebarUrlSerializer.new(link.linkable, root: false) }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SidebarUrlSerializer < ApplicationSerializer
|
||||
attributes :id, :name, :value, :icon, :external
|
||||
attributes :id, :name, :value, :icon, :external, :segment
|
||||
|
||||
def external
|
||||
object.external? || object.full_reload?
|
||||
|
||||
@@ -266,6 +266,7 @@ class SiteSerializer < ApplicationSerializer
|
||||
SidebarSection
|
||||
.public_sections
|
||||
.includes(sidebar_section_links: :linkable)
|
||||
.order("(section_type IS NOT NULL) DESC, (public IS TRUE) DESC")
|
||||
.map { |section| SidebarSectionSerializer.new(section, root: false) }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user