fix: drop legacy control center menu
This commit is contained in:
@@ -48,23 +48,6 @@ function normalizePageMap(pageMap: ComponentRecordType) {
|
|||||||
) as 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 }) {
|
function isLightMenuRoute(route: { name?: string }) {
|
||||||
return isLightMenuName(route.name);
|
return isLightMenuName(route.name);
|
||||||
}
|
}
|
||||||
@@ -84,39 +67,38 @@ function filterAvailableRoutes<
|
|||||||
): T[] {
|
): T[] {
|
||||||
return routes
|
return routes
|
||||||
.map((route) => {
|
.map((route) => {
|
||||||
const normalizedRoute = normalizeBackendRoute(route);
|
const children = route.children
|
||||||
const children = normalizedRoute.children
|
? filterAvailableRoutes(route.children, pageMap, layoutMap)
|
||||||
? filterAvailableRoutes(normalizedRoute.children, pageMap, layoutMap)
|
|
||||||
: undefined;
|
: undefined;
|
||||||
const routeAllowed = isLightMenuRoute(normalizedRoute);
|
const routeAllowed = isLightMenuRoute(route);
|
||||||
|
|
||||||
if (!routeAllowed && !children?.length) {
|
if (!routeAllowed && !children?.length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!normalizedRoute.component &&
|
!route.component &&
|
||||||
normalizedRoute.children &&
|
route.children &&
|
||||||
!children?.length
|
!children?.length
|
||||||
) {
|
) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!routeAllowed && children?.length) {
|
if (!routeAllowed && children?.length) {
|
||||||
const groupRoute = { ...normalizedRoute, children };
|
const groupRoute = { ...route, children };
|
||||||
delete groupRoute.component;
|
delete groupRoute.component;
|
||||||
return groupRoute;
|
return groupRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPageComponent(normalizedRoute.component, pageMap, layoutMap)) {
|
if (!hasPageComponent(route.component, pageMap, layoutMap)) {
|
||||||
if (!children?.length) return undefined;
|
if (!children?.length) return undefined;
|
||||||
|
|
||||||
const groupRoute = { ...normalizedRoute, children };
|
const groupRoute = { ...route, children };
|
||||||
delete groupRoute.component;
|
delete groupRoute.component;
|
||||||
return groupRoute;
|
return groupRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
return children ? { ...normalizedRoute, children } : normalizedRoute;
|
return children ? { ...route, children } : route;
|
||||||
})
|
})
|
||||||
.filter(Boolean) as T[];
|
.filter(Boolean) as T[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export const LIGHT_MENU_NAMES = new Set([
|
|||||||
'AIWorkflowRuns',
|
'AIWorkflowRuns',
|
||||||
'AnnouncementList',
|
'AnnouncementList',
|
||||||
'AnnouncementManage',
|
'AnnouncementManage',
|
||||||
'ControlCenter',
|
|
||||||
'KnowledgeBase',
|
'KnowledgeBase',
|
||||||
'SystemManagement',
|
'SystemManagement',
|
||||||
'SystemMenu',
|
'SystemMenu',
|
||||||
|
|||||||
Reference in New Issue
Block a user