FEATURE: allow external links in custom sidebar sections (#20503)

Originally, only Discourse site links were available. After feedback, it was decided to extend this feature to external URLs.

/t/93491
This commit is contained in:
Krzysztof Kotlarek
2023-03-07 11:47:18 +11:00
committed by GitHub
parent b4528b9e27
commit a16ea24461
13 changed files with 153 additions and 31 deletions

View File

@ -54,8 +54,13 @@ RSpec.describe SidebarSectionsController do
params: {
title: "custom section",
links: [
{ icon: "link", name: "categories", value: "/categories" },
{
icon: "link",
name: "categories",
value: "http://#{Discourse.current_hostname}/categories",
},
{ icon: "address-book", name: "tags", value: "/tags" },
{ icon: "external-link-alt", name: "Discourse", value: "https://discourse.org" },
],
}
@ -68,13 +73,19 @@ RSpec.describe SidebarSectionsController do
expect(sidebar_section.user).to eq(user)
expect(sidebar_section.public).to be false
expect(UserHistory.count).to eq(0)
expect(sidebar_section.sidebar_urls.count).to eq(2)
expect(sidebar_section.sidebar_urls.count).to eq(3)
expect(sidebar_section.sidebar_urls.first.icon).to eq("link")
expect(sidebar_section.sidebar_urls.first.name).to eq("categories")
expect(sidebar_section.sidebar_urls.first.value).to eq("/categories")
expect(sidebar_section.sidebar_urls.first.external).to be false
expect(sidebar_section.sidebar_urls.second.icon).to eq("address-book")
expect(sidebar_section.sidebar_urls.second.name).to eq("tags")
expect(sidebar_section.sidebar_urls.second.value).to eq("/tags")
expect(sidebar_section.sidebar_urls.second.external).to be false
expect(sidebar_section.sidebar_urls.third.icon).to eq("external-link-alt")
expect(sidebar_section.sidebar_urls.third.name).to eq("Discourse")
expect(sidebar_section.sidebar_urls.third.value).to eq("https://discourse.org")
expect(sidebar_section.sidebar_urls.third.external).to be true
end
it "does not allow regular user to create public section" do