mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:52:11 +08:00
DEV: Remove findBy usage in admin-sidebar (#27813)
We prefer not to use these Ember array extensions anymore
This commit is contained in:
parent
eca4ed8f80
commit
54fba2005f
|
@ -184,7 +184,9 @@ export function useAdminNavConfig(navMap) {
|
|||
for (const [sectionName, additionalLinks] of Object.entries(
|
||||
additionalAdminSidebarSectionLinks
|
||||
)) {
|
||||
const section = navMap.findBy("name", sectionName);
|
||||
const section = navMap.find(
|
||||
(navSection) => navSection.name === sectionName
|
||||
);
|
||||
if (section && additionalLinks.length) {
|
||||
section.links.push(...additionalLinks);
|
||||
}
|
||||
|
@ -286,7 +288,9 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
|
|||
const navMap = savedConfig || ADMIN_NAV_MAP;
|
||||
|
||||
if (!session.get("safe_mode")) {
|
||||
const pluginLinks = navMap.findBy("name", "plugins").links;
|
||||
const pluginLinks = navMap.find(
|
||||
(section) => section.name === "plugins"
|
||||
).links;
|
||||
pluginAdminRouteLinks().forEach((pluginLink) => {
|
||||
if (!pluginLinks.mapBy("name").includes(pluginLink.name)) {
|
||||
pluginLinks.push(pluginLink);
|
||||
|
@ -311,21 +315,25 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
|
|||
});
|
||||
|
||||
if (siteSettings.experimental_form_templates) {
|
||||
navMap.findBy("name", "appearance").links.push({
|
||||
name: "admin_customize_form_templates",
|
||||
route: "adminCustomizeFormTemplates",
|
||||
label: "admin.form_templates.nav_title",
|
||||
icon: "list",
|
||||
});
|
||||
navMap
|
||||
.find((section) => section.name === "appearance")
|
||||
.links.push({
|
||||
name: "admin_customize_form_templates",
|
||||
route: "adminCustomizeFormTemplates",
|
||||
label: "admin.form_templates.nav_title",
|
||||
icon: "list",
|
||||
});
|
||||
}
|
||||
|
||||
if (currentUser.show_experimental_flags_admin_page) {
|
||||
navMap.findBy("name", "community").links.push({
|
||||
name: "admin_moderation_flags",
|
||||
route: "adminConfig.flags",
|
||||
label: "admin.community.sidebar_link.moderation_flags",
|
||||
icon: "flag",
|
||||
});
|
||||
navMap
|
||||
.find((section) => section.name === "community")
|
||||
.links.push({
|
||||
name: "admin_moderation_flags",
|
||||
route: "adminConfig.flags",
|
||||
label: "admin.community.sidebar_link.moderation_flags",
|
||||
icon: "flag",
|
||||
});
|
||||
}
|
||||
|
||||
navMap.forEach((section) =>
|
||||
|
|
Loading…
Reference in New Issue
Block a user