DEV: configurable public sidebar sections (#20303)

Extension of https://github.com/discourse/discourse/pull/20057

Admin can create a public session visible to everyone. An additional checkbox is displayed for staff members.
This commit is contained in:
Krzysztof Kotlarek
2023-02-22 08:55:44 +11:00
committed by GitHub
parent e3ee81aa3c
commit b9d037770c
18 changed files with 350 additions and 17 deletions

View File

@@ -77,6 +77,13 @@ class CurrentUserSerializer < BasicUserSerializer
has_one :user_option, embed: :object, serializer: CurrentUserOptionSerializer
def sidebar_sections
SidebarSection
.where("public OR user_id = ?", object.id)
.order("(public IS TRUE) DESC")
.map { |section| SidebarSectionSerializer.new(section, root: false) }
end
def groups
owned_group_ids = GroupUser.where(user_id: id, owner: true).pluck(:group_id).to_set

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true
class SidebarSectionSerializer < ApplicationSerializer
attributes :id, :title, :links, :slug
attributes :id, :title, :links, :slug, :public
def links
object.sidebar_section_links.map(&:linkable)