diff --git a/public/app/features/trails/RedirectToDrilldownApp.tsx b/public/app/features/trails/RedirectToDrilldownApp.tsx new file mode 100644 index 00000000000..0a4ff04e8d7 --- /dev/null +++ b/public/app/features/trails/RedirectToDrilldownApp.tsx @@ -0,0 +1,17 @@ +import { Navigate, useLocation, useParams } from 'react-router-dom-v5-compat'; + +import { getRouteForAppPlugin } from 'app/features/plugins/routes'; + +/** + * Navigate to the drilldown app with the remaining path parameters and search params + */ +const RedirectToDrilldownApp = () => { + const { '*': remainingPath } = useParams(); + const location = useLocation(); + const appPath = getRouteForAppPlugin('grafana-metricsdrilldown-app').path.replaceAll('*', ''); + const newPath = `${appPath}${remainingPath}${location.search}`; + + return ; +}; + +export default RedirectToDrilldownApp; diff --git a/public/app/routes/routes.tsx b/public/app/routes/routes.tsx index ddadc2f40b7..839eb62ad85 100644 --- a/public/app/routes/routes.tsx +++ b/public/app/routes/routes.tsx @@ -15,7 +15,7 @@ import { getRoutes as getDataConnectionsRoutes } from 'app/features/connections/ import { DATASOURCES_ROUTES } from 'app/features/datasources/constants'; import { ConfigureIRM } from 'app/features/gops/configuration-tracker/components/ConfigureIRM'; import { getRoutes as getPluginCatalogRoutes } from 'app/features/plugins/admin/routes'; -import { getAppPluginRoutes, getRouteForAppPlugin } from 'app/features/plugins/routes'; +import { getAppPluginRoutes } from 'app/features/plugins/routes'; import { getProfileRoutes } from 'app/features/profile/routes'; import { AccessControlAction, DashboardRoutes } from 'app/types'; @@ -518,7 +518,10 @@ export function getAppRoutes(): RouteDescriptor[] { roles: () => contextSrv.evaluatePermission([AccessControlAction.DataSourcesExplore]), ...(config.featureToggles.exploreMetricsUseExternalAppPlugin ? { - component: getRouteForAppPlugin('grafana-metricsdrilldown-app').component, + component: SafeDynamicImport( + () => + import(/* webpackChunkName: "MetricsDrilldownRedirect"*/ 'app/features/trails/RedirectToDrilldownApp') + ), } : { chromeless: false,