mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FEATURE: include themes and components keywords to the admin sidebar (#26708)
Include themes and component keywords to make the filter more accurate.
This commit is contained in:

committed by
GitHub

parent
c791346088
commit
0cd4d7ddd1
@ -20,9 +20,13 @@ export default class AdminSidebarStateManager extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.keywords[link_name].navigation = keywords.map((keyword) =>
|
this.keywords[link_name].navigation = [
|
||||||
keyword.toLowerCase()
|
...new Set(
|
||||||
);
|
this.keywords[link_name].navigation.concat(
|
||||||
|
keywords.map((keyword) => keyword.toLowerCase())
|
||||||
|
)
|
||||||
|
),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get navConfig() {
|
get navConfig() {
|
||||||
|
@ -255,6 +255,7 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
|
|||||||
const siteSettings = getOwnerWithFallback(this).lookup(
|
const siteSettings = getOwnerWithFallback(this).lookup(
|
||||||
"service:site-settings"
|
"service:site-settings"
|
||||||
);
|
);
|
||||||
|
const store = getOwnerWithFallback(this).lookup("service:store");
|
||||||
const router = getOwnerWithFallback(this).lookup("service:router");
|
const router = getOwnerWithFallback(this).lookup("service:router");
|
||||||
const session = getOwnerWithFallback(this).lookup("service:session");
|
const session = getOwnerWithFallback(this).lookup("service:session");
|
||||||
if (!currentUser.use_admin_sidebar) {
|
if (!currentUser.use_admin_sidebar) {
|
||||||
@ -269,13 +270,30 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
|
|||||||
const navMap = savedConfig || ADMIN_NAV_MAP;
|
const navMap = savedConfig || ADMIN_NAV_MAP;
|
||||||
|
|
||||||
if (!session.get("safe_mode")) {
|
if (!session.get("safe_mode")) {
|
||||||
navMap.findBy("name", "plugins").links.push(...pluginAdminRouteLinks());
|
const pluginLinks = navMap.findBy("name", "plugins").links;
|
||||||
|
pluginAdminRouteLinks().forEach((pluginLink) => {
|
||||||
|
if (!pluginLinks.mapBy("name").includes(pluginLink.name)) {
|
||||||
|
pluginLinks.push(pluginLink);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.adminSidebarStateManager.setLinkKeywords(
|
this.adminSidebarStateManager.setLinkKeywords(
|
||||||
"admin_installed_plugins",
|
"admin_installed_plugins",
|
||||||
installedPluginsLinkKeywords()
|
installedPluginsLinkKeywords()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store.findAll("theme").then((themes) => {
|
||||||
|
this.adminSidebarStateManager.setLinkKeywords(
|
||||||
|
"admin_themes",
|
||||||
|
themes.content.rejectBy("component").mapBy("name")
|
||||||
|
);
|
||||||
|
this.adminSidebarStateManager.setLinkKeywords(
|
||||||
|
"admin_components",
|
||||||
|
themes.content.filterBy("component").mapBy("name")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
if (siteSettings.experimental_form_templates) {
|
if (siteSettings.experimental_form_templates) {
|
||||||
navMap.findBy("name", "appearance").links.push({
|
navMap.findBy("name", "appearance").links.push({
|
||||||
name: "admin_customize_form_templates",
|
name: "admin_customize_form_templates",
|
||||||
|
@ -160,6 +160,24 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
|
|||||||
expect(links.map(&:text)).to eq(["Installed"])
|
expect(links.map(&:text)).to eq(["Installed"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "accepts components and themes keywords for filter" do
|
||||||
|
Fabricate(:theme, name: "Air theme", component: false)
|
||||||
|
Fabricate(:theme, name: "Kanban", component: true)
|
||||||
|
|
||||||
|
visit("/admin")
|
||||||
|
sidebar.toggle_all_sections
|
||||||
|
|
||||||
|
filter.filter("air")
|
||||||
|
links = page.all(".sidebar-section-link-content-text")
|
||||||
|
expect(links.count).to eq(1)
|
||||||
|
expect(links.map(&:text)).to eq(["Themes"])
|
||||||
|
|
||||||
|
filter.filter("kanban")
|
||||||
|
links = page.all(".sidebar-section-link-content-text")
|
||||||
|
expect(links.count).to eq(1)
|
||||||
|
expect(links.map(&:text)).to eq(["Components"])
|
||||||
|
end
|
||||||
|
|
||||||
it "does not show the button to customize sidebar sections, that is only supported in the main panel" do
|
it "does not show the button to customize sidebar sections, that is only supported in the main panel" do
|
||||||
visit("/")
|
visit("/")
|
||||||
expect(sidebar).to have_add_section_button
|
expect(sidebar).to have_add_section_button
|
||||||
|
Reference in New Issue
Block a user