fix: drop legacy control center menu
This commit is contained in:
@@ -48,23 +48,6 @@ function normalizePageMap(pageMap: ComponentRecordType) {
|
||||
) as ComponentRecordType;
|
||||
}
|
||||
|
||||
function normalizeBackendRoute<
|
||||
T extends {
|
||||
component?: string;
|
||||
name?: string;
|
||||
path?: string;
|
||||
query?: unknown;
|
||||
},
|
||||
>(route: T) {
|
||||
if (route.name !== 'ControlCenter') return route;
|
||||
|
||||
const normalized = { ...route };
|
||||
normalized.path = '/ai-platform/agent';
|
||||
normalized.component = 'ai-platform/agent/index';
|
||||
normalized.query = undefined;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function isLightMenuRoute(route: { name?: string }) {
|
||||
return isLightMenuName(route.name);
|
||||
}
|
||||
@@ -84,39 +67,38 @@ function filterAvailableRoutes<
|
||||
): T[] {
|
||||
return routes
|
||||
.map((route) => {
|
||||
const normalizedRoute = normalizeBackendRoute(route);
|
||||
const children = normalizedRoute.children
|
||||
? filterAvailableRoutes(normalizedRoute.children, pageMap, layoutMap)
|
||||
const children = route.children
|
||||
? filterAvailableRoutes(route.children, pageMap, layoutMap)
|
||||
: undefined;
|
||||
const routeAllowed = isLightMenuRoute(normalizedRoute);
|
||||
const routeAllowed = isLightMenuRoute(route);
|
||||
|
||||
if (!routeAllowed && !children?.length) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (
|
||||
!normalizedRoute.component &&
|
||||
normalizedRoute.children &&
|
||||
!route.component &&
|
||||
route.children &&
|
||||
!children?.length
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!routeAllowed && children?.length) {
|
||||
const groupRoute = { ...normalizedRoute, children };
|
||||
const groupRoute = { ...route, children };
|
||||
delete groupRoute.component;
|
||||
return groupRoute;
|
||||
}
|
||||
|
||||
if (!hasPageComponent(normalizedRoute.component, pageMap, layoutMap)) {
|
||||
if (!hasPageComponent(route.component, pageMap, layoutMap)) {
|
||||
if (!children?.length) return undefined;
|
||||
|
||||
const groupRoute = { ...normalizedRoute, children };
|
||||
const groupRoute = { ...route, children };
|
||||
delete groupRoute.component;
|
||||
return groupRoute;
|
||||
}
|
||||
|
||||
return children ? { ...normalizedRoute, children } : normalizedRoute;
|
||||
return children ? { ...route, children } : route;
|
||||
})
|
||||
.filter(Boolean) as T[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user