DEV: Remove findBy usage in admin-sidebar (#27813)

We prefer not to use these Ember array extensions anymore
This commit is contained in:
Martin Brennan 2024-07-10 11:58:52 +10:00 committed by GitHub
parent eca4ed8f80
commit 54fba2005f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) =>