+ {{#if this.model.sectionType}}
+
+
{{i18n "sidebar.sections.custom.more_menu"}}
+ {{#each this.activeSecondaryLinks as |link|}}
+
+ {{/each}}
+
+
+ {{#if this.model.sectionType}}
+
+ {{/if}}
+ {{/if}}
+ {{#if (and this.currentUser.staff (not this.model.sectionType))}}
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
index cd32940cfc9..17734586c44 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
@@ -25,6 +25,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
tracked_tags: ["tag1"],
watched_tags: ["tag2"],
watching_first_post_tags: ["tag3"],
+ admin: false,
});
needs.settings({
diff --git a/app/assets/javascripts/discourse/tests/fixtures/session-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/session-fixtures.js
index cd2713b541c..01d015a253d 100644
--- a/app/assets/javascripts/discourse/tests/fixtures/session-fixtures.js
+++ b/app/assets/javascripts/discourse/tests/fixtures/session-fixtures.js
@@ -75,7 +75,7 @@ export default {
},
{
id: 331,
- name: "Info",
+ name: "About",
value: "/about",
icon: "info-circle",
external: false,
diff --git a/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js
index c7c05895436..86225054781 100644
--- a/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js
+++ b/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js
@@ -723,7 +723,7 @@ export default {
},
{
id: 331,
- name: "Info",
+ name: "About",
value: "/about",
icon: "info-circle",
external: false,
diff --git a/app/assets/stylesheets/common/base/sidebar-custom-section.scss b/app/assets/stylesheets/common/base/sidebar-custom-section.scss
index 998ed4e4f7c..d574e47f47f 100644
--- a/app/assets/stylesheets/common/base/sidebar-custom-section.scss
+++ b/app/assets/stylesheets/common/base/sidebar-custom-section.scss
@@ -16,6 +16,10 @@
.sidebar-section-link-prefix.icon {
cursor: move;
}
+ .sidebar-section[data-section-name="community"]
+ .sidebar-section-link-prefix.icon {
+ cursor: pointer;
+ }
a {
-webkit-touch-callout: none !important;
diff --git a/app/assets/stylesheets/common/base/sidebar.scss b/app/assets/stylesheets/common/base/sidebar.scss
index df39a9eb167..f36a70e00e0 100644
--- a/app/assets/stylesheets/common/base/sidebar.scss
+++ b/app/assets/stylesheets/common/base/sidebar.scss
@@ -106,8 +106,21 @@
}
}
}
-
.sidebar-section-form-modal {
+ .draggable {
+ cursor: move;
+ align-self: center;
+ margin-left: auto;
+ margin-right: auto;
+ -webkit-user-drag: element;
+ -khtml-user-drag: element;
+ -moz-user-drag: element;
+ -o-user-drag: element;
+ user-drag: element;
+ }
+ .dragging {
+ opacity: 0.4;
+ }
.modal-inner-container {
width: var(--modal-max-width);
}
@@ -122,17 +135,52 @@
}
.row-wrapper {
display: grid;
- grid-template-columns: auto auto auto 2em;
+ grid-template-columns: 25px 60px auto auto 2em;
gap: 1em;
- margin-top: 1em;
+ padding: 0.5em 1px;
+ -webkit-user-drag: none;
+ -khtml-user-drag: none;
+ -moz-user-drag: none;
+ -o-user-drag: none;
+ user-drag: none;
+ cursor: default;
+
+ &.header {
+ padding-bottom: 0;
+ padding-top: 1em;
+ label {
+ margin-bottom: 0;
+ }
+ .link-url {
+ margin-left: -1em;
+ }
+ }
+
+ &.drag-above {
+ border-top: 1px dotted #666;
+ margin-top: -1px;
+ }
+ &.drag-below {
+ border-bottom: 1px dotted #666;
+ padding-bottom: calc(0.5em - 1px);
+ }
+ .link-icon {
+ grid-column: 1 / span 2;
+ padding-left: calc(25px + 1em);
+ }
+ &.mark-public-wrapper {
+ label {
+ grid-column: 1 / -1;
+ }
+ }
}
.delete-link {
height: 1em;
- align-self: end;
- margin-bottom: 0.75em;
+ align-self: center;
margin-right: 1em;
}
- .btn-flat.add-link {
+ .btn-flat.add-link,
+ .btn-flat.reset-link {
margin-top: 1em;
margin-left: -0.65em;
&:active,
@@ -148,6 +196,9 @@
color: var(--tertiary-hover);
}
}
+ .btn-flat.reset-link {
+ float: right;
+ }
.modal-footer {
display: flex;
justify-content: space-between;
@@ -156,4 +207,13 @@
margin-right: 0;
}
}
+ .select-kit.multi-select .multi-select-header .formatted-selection {
+ display: none;
+ }
+ .modal-inner-container .select-kit {
+ width: 60px;
+ }
+ .select-kit.is-expanded .select-kit-body {
+ width: 220px !important;
+ }
}
diff --git a/app/controllers/sidebar_sections_controller.rb b/app/controllers/sidebar_sections_controller.rb
index a9eea34f3dd..a61af92b7a8 100644
--- a/app/controllers/sidebar_sections_controller.rb
+++ b/app/controllers/sidebar_sections_controller.rb
@@ -59,7 +59,7 @@ class SidebarSectionsController < ApplicationController
Site.clear_anon_cache!
end
- render_serialized(sidebar_section, SidebarSectionSerializer)
+ render_serialized(sidebar_section.reload, SidebarSectionSerializer)
rescue ActiveRecord::RecordInvalid => e
render_json_error(e.record.errors.full_messages.first)
rescue Discourse::InvalidAccess
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 2cbc4c766bd..581b6d68204 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4413,10 +4413,13 @@ en:
save: "Save"
delete: "Delete"
delete_confirm: "Are you sure you want to delete this section?"
+ reset_confirm: "Are you sure you want to reset this section to default?"
public: "Make this section public and visible to everyone"
+ more_menu: "More menu"
links:
add: "Add another link"
delete: "Delete link"
+ reset: "Reset to default"
icon:
label: "Icon"
validation:
@@ -4473,7 +4476,8 @@ en:
configure_defaults: "Configure defaults"
community:
header_link_text: "Community"
- header_action_title: "Create a topic"
+ header_action_create_topic_title: "Create a topic"
+ header_action_edit_section_title: "Edit Community section"
links:
about:
content: "About"
diff --git a/spec/system/custom_sidebar_sections_spec.rb b/spec/system/custom_sidebar_sections_spec.rb
index 33f69c55e39..b2f5356e12b 100644
--- a/spec/system/custom_sidebar_sections_spec.rb
+++ b/spec/system/custom_sidebar_sections_spec.rb
@@ -114,25 +114,17 @@ describe "Custom sidebar sections", type: :system, js: true do
sign_in user
visit("/latest")
- within("[data-section-name='my-section'] .sidebar-section-link-wrapper:nth-child(1)") do
- expect(sidebar).to have_section_link("Sidebar Tags")
- end
-
- within("[data-section-name='my-section'] .sidebar-section-link-wrapper:nth-child(2)") do
- expect(sidebar).to have_section_link("Sidebar Categories")
- end
+ expect(sidebar.primary_section_links("my-section")).to eq(
+ ["Sidebar Tags", "Sidebar Categories"],
+ )
tags_link = find(".sidebar-section-link[data-link-name='Sidebar Tags']")
categories_link = find(".sidebar-section-link[data-link-name='Sidebar Categories']")
tags_link.drag_to(categories_link, html5: true, delay: 0.4)
- within("[data-section-name='my-section'] .sidebar-section-link-wrapper:nth-child(1)") do
- expect(sidebar).to have_section_link("Sidebar Categories")
- end
-
- within("[data-section-name='my-section'] .sidebar-section-link-wrapper:nth-child(2)") do
- expect(sidebar).to have_section_link("Sidebar Tags")
- end
+ expect(sidebar.primary_section_links("my-section")).to eq(
+ ["Sidebar Categories", "Sidebar Tags"],
+ )
end
it "does not allow the user to edit public section" do
@@ -201,6 +193,29 @@ describe "Custom sidebar sections", type: :system, js: true do
expect(sidebar).to have_no_section("Edited public section")
end
+ it "allows admin to edit community section and reset to default" do
+ sign_in admin
+ visit("/latest")
+
+ sidebar.edit_custom_section("Community")
+ section_modal.fill_name("Edited community section")
+ section_modal.everything_link.drag_to(section_modal.review_link, delay: 0.4)
+ section_modal.save
+
+ expect(sidebar).to have_section("Edited community section")
+ expect(sidebar.primary_section_links("edited-community-section")).to eq(
+ ["My Posts", "Everything", "Admin", "More"],
+ )
+
+ sidebar.edit_custom_section("Edited community section")
+ section_modal.reset
+
+ expect(sidebar).to have_section("Community")
+ expect(sidebar.primary_section_links("community")).to eq(
+ ["Everything", "My Posts", "Admin", "More"],
+ )
+ end
+
it "shows anonymous public sections" do
sidebar_section = Fabricate(:sidebar_section, title: "Public section", public: true)
sidebar_url_1 = Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags")
diff --git a/spec/system/page_objects/components/sidebar.rb b/spec/system/page_objects/components/sidebar.rb
index 87e2056030d..a8b944ba8ef 100644
--- a/spec/system/page_objects/components/sidebar.rb
+++ b/spec/system/page_objects/components/sidebar.rb
@@ -63,6 +63,10 @@ module PageObjects
find(SIDEBAR_WRAPPER_SELECTOR).has_no_button?(name)
end
+ def primary_section_links(slug)
+ all("[data-section-name='#{slug}'] .sidebar-section-link-wrapper").map(&:text)
+ end
+
private
def section_link_present?(name, href: nil, active: false, present:)
diff --git a/spec/system/page_objects/components/sidebar_header_dropdown.rb b/spec/system/page_objects/components/sidebar_header_dropdown.rb
index d07cbc669c4..e855bcbcbb9 100644
--- a/spec/system/page_objects/components/sidebar_header_dropdown.rb
+++ b/spec/system/page_objects/components/sidebar_header_dropdown.rb
@@ -25,7 +25,7 @@ module PageObjects
def click_community_header_button
page.click_button(
- I18n.t("js.sidebar.sections.community.header_action_title"),
+ I18n.t("js.sidebar.sections.community.header_action_create_topic_title"),
class: "sidebar-section-header-button",
)
end
diff --git a/spec/system/page_objects/modals/sidebar_section_form.rb b/spec/system/page_objects/modals/sidebar_section_form.rb
index 6b789a7f9a7..37100fd5a07 100644
--- a/spec/system/page_objects/modals/sidebar_section_form.rb
+++ b/spec/system/page_objects/modals/sidebar_section_form.rb
@@ -28,6 +28,11 @@ module PageObjects
find(".dialog-container .btn-primary").click
end
+ def reset
+ find(".reset-link").click
+ find(".dialog-footer .btn-primary").click
+ end
+
def save
find("#save-section").click
end
@@ -39,9 +44,18 @@ module PageObjects
def has_disabled_save?
find_button("Save", disabled: true)
end
+
def has_enabled_save?
find_button("Save", disabled: false)
end
+
+ def everything_link
+ find(".draggable[data-link-name='Everything']")
+ end
+
+ def review_link
+ find(".draggable[data-link-name='Review']")
+ end
end
end
end