import { globalSection } from './global' import { pageDisplaySection } from './page-display' import { postListSection } from './post-list' import { permissionsSection } from './permissions' import { usersSection } from './users' import { paymentSection } from './payment' import { shopSection } from './shop' import { forumSection } from './forum' import { extensionsSection } from './extensions' import { themeInfoSection } from './theme-info' import { docsSection } from './docs' import { toolsSection } from './tools' const SECTION_DEFAULT_CHILDREN = { global: 'global-common', 'page-display': 'page-display-header-nav', 'post-list': 'post-list-page', permissions: 'permissions-comment', users: 'users-auth', payment: 'payment-gateway', shop: 'shop-products', forum: 'forum-boards', extensions: 'extensions-ip', tools: 'tools-import-export', 'theme-info': 'theme-info-dashboard', docs: 'docs-dashboard', } function attachSectionDefaultRoute(section) { const defaultChildKey = SECTION_DEFAULT_CHILDREN[section.key] const defaultChild = (section.children || []).find((child) => child.key === defaultChildKey) if (!defaultChild) { return section } return { ...section, defaultRoute: defaultChild.route, } } export const ADMIN_SECTIONS = [ attachSectionDefaultRoute(globalSection), attachSectionDefaultRoute(pageDisplaySection), attachSectionDefaultRoute(postListSection), attachSectionDefaultRoute(permissionsSection), attachSectionDefaultRoute(usersSection), attachSectionDefaultRoute(paymentSection), attachSectionDefaultRoute(shopSection), attachSectionDefaultRoute(forumSection), attachSectionDefaultRoute(extensionsSection), attachSectionDefaultRoute(toolsSection), attachSectionDefaultRoute(themeInfoSection), attachSectionDefaultRoute(docsSection), ] export function getAdminSections() { return ADMIN_SECTIONS } export function getAllAdminPages() { const pages = [] for (const section of ADMIN_SECTIONS) { if (section.placeholder) { pages.push({ sectionKey: section.key, ...section, }) continue } for (const child of section.children || []) { pages.push({ sectionKey: section.key, ...child, }) } } return pages }