ExploreMetrics: Use redirect to route traffic to metrics drilldown app (#100098)

* fix: drilldown app redirect

* chore: make copilot review happy, I guess 🤷
This commit is contained in:
Nick Richmond
2025-02-05 06:09:16 -05:00
committed by GitHub
parent f51571db5d
commit 39a6d2e586
2 changed files with 22 additions and 2 deletions
@@ -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 <Navigate replace to={newPath} />;
};
export default RedirectToDrilldownApp;
+5 -2
View File
@@ -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,