mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 15:04:00 +08:00
FIX: allow published pages to be added to sidebar (#21687)
Custom sidebar sections should accept publish pages with URL `/pub/*`. Similarly to `/my/activity` links.
This commit is contained in:
parent
5dd89e0b70
commit
2aa5fc927e
|
@ -10,7 +10,11 @@ import { tracked } from "@glimmer/tracking";
|
|||
import { A } from "@ember/array";
|
||||
import { SIDEBAR_SECTION, SIDEBAR_URL } from "discourse/lib/constants";
|
||||
|
||||
const FULL_RELOAD_LINKS_REGEX = [/^\/my\/[a-z_\-\/]+$/, /^\/safe-mode$/];
|
||||
const FULL_RELOAD_LINKS_REGEX = [
|
||||
/^\/my\/[a-z_\-\/]+$/,
|
||||
/^\/pub\/[a-z_\-\/]+$/,
|
||||
/^\/safe-mode$/,
|
||||
];
|
||||
|
||||
class Section {
|
||||
@tracked title;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class SidebarUrl < ActiveRecord::Base
|
||||
enum :segment, { primary: 0, secondary: 1 }, scopes: false, suffix: true
|
||||
|
||||
FULL_RELOAD_LINKS_REGEX = [%r{\A/my/[a-z_\-/]+\z}, %r{\A/safe-mode\z}]
|
||||
FULL_RELOAD_LINKS_REGEX = [%r{\A/my/[a-z_\-/]+\z}, %r{\A/pub/[a-z_\-/]+\z}, %r{\A/safe-mode\z}]
|
||||
MAX_ICON_LENGTH = 40
|
||||
MAX_NAME_LENGTH = 80
|
||||
MAX_VALUE_LENGTH = 200
|
||||
|
|
|
@ -9,6 +9,13 @@ RSpec.describe SidebarUrl do
|
|||
value: "https://www.test.com/discourse-test",
|
||||
).valid?,
|
||||
).to eq(true)
|
||||
expect(
|
||||
SidebarUrl.new(
|
||||
icon: "link",
|
||||
name: "categories",
|
||||
value: "http://#{Discourse.current_hostname}/pub/test",
|
||||
).valid?,
|
||||
).to eq(true)
|
||||
end
|
||||
|
||||
it "sets external flag" do
|
||||
|
|
|
@ -33,23 +33,29 @@ describe "Custom sidebar sections", type: :system, js: true do
|
|||
it "allows the user to create custom section with /my link" do
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
|
||||
sidebar.click_add_section_button
|
||||
|
||||
expect(section_modal).to be_visible
|
||||
expect(section_modal).to have_disabled_save
|
||||
expect(sidebar.custom_section_modal_title).to have_content("Add custom section")
|
||||
|
||||
section_modal.fill_name("My section")
|
||||
|
||||
section_modal.fill_link("My preferences", "/my/preferences")
|
||||
expect(section_modal).to have_enabled_save
|
||||
|
||||
section_modal.save
|
||||
|
||||
expect(sidebar).to have_section("My section")
|
||||
expect(sidebar).to have_section_link("My preferences")
|
||||
end
|
||||
|
||||
it "allows the user to create custom section with /pub link" do
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
|
||||
sidebar.click_add_section_button
|
||||
section_modal.fill_name("My section")
|
||||
section_modal.fill_link("Published Page", "/pub/test")
|
||||
section_modal.save
|
||||
|
||||
expect(sidebar).to have_section("My section")
|
||||
expect(sidebar).to have_section_link("Published Page")
|
||||
end
|
||||
|
||||
it "allows the user to create custom section with external link" do
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
|
|
Loading…
Reference in New Issue
Block a user