make sure AppRoot is lazily loaded (#54954)

This commit is contained in:
Ashley Harrison 2022-09-09 16:09:34 +01:00 committed by GitHub
parent 1a285d2d0e
commit 4866898529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,6 @@ import { getRoutes as getDataConnectionsRoutes } from 'app/features/data-connect
import { DATASOURCES_ROUTES } from 'app/features/datasources/constants';
import { getLiveRoutes } from 'app/features/live/pages/routes';
import { getRoutes as getPluginCatalogRoutes } from 'app/features/plugins/admin/routes';
import AppRootPage from 'app/features/plugins/components/AppRootPage';
import { getProfileRoutes } from 'app/features/profile/routes';
import { ServiceAccountPage } from 'app/features/serviceaccounts/ServiceAccountPage';
import { AccessControlAction, DashboardRoutes } from 'app/types';
@ -39,11 +38,14 @@ export function getAppRoutes(): RouteDescriptor[] {
component: (props) => {
const hasRoot = pluginHasRootPage(props.match.params.pluginId, config.bootData.navTree);
const hasQueryParams = Object.keys(props.queryParams).length > 0;
return hasRoot || hasQueryParams ? (
<AppRootPage {...props} />
) : (
<NavLandingPage navId={`plugin-page-${props.match.params.pluginId}`} />
);
if (hasRoot || hasQueryParams) {
const AppRootPage = SafeDynamicImport(
() => import(/* webpackChunkName: "AppRootPage" */ 'app/features/plugins/components/AppRootPage')
);
return <AppRootPage {...props} />;
} else {
return <NavLandingPage navId={`plugin-page-${props.match.params.pluginId}`} />;
}
},
},
]