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:
@@ -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;
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user