Connections: Update datasource details url (#60521)

update datasource details url

My ultimate goal is to make the cloud-onboarding plugin link to
datasource details page inside Connections.
I tried to do that, so that it linked to
`/connections/connect-data/datasources/:id`, but it didn't work. Details
below:

We have a problem with the datasources details page url:
If the plugin is not present, then the
`/connections/connect-data/datasources/:id` url is finely served by Grafana.
However, when the plugin is present, we register a Route entry like this:
`<Route exact=false path='/connections/connect-data' component={AppPlugin} />`
And this entry will be higher in the routes list than the datasources Route.
This means that every path under `/connections/connect-data` will be served
by the plugin. That's why exact is false. Otherwise the plugin couldn't
serve integrations details at `connect-data/infrastructure/:id`.
So `exact=false` is needed.

What can we do?
1. Put Grafana's Connection routes higher in the list of routes.
2. Find a different URL for datasources details page

Unfortunately, we can't do 1., because:
Routes roughly look like this (in this order):
- exact: false, path: connections/connect-data, component: AppPlugin
- exact: false, path: connections/your-connections/infrastructure,
    component: AppPlugin
- exact: false, path: connections, component: Connections
So if a request comes for `/connections` or `/connections/your-connections`
or `/connections/your-connections/datasources`, it will be served by
Connections.

Therefore, we can't really put the route for Connections higher in the list
of routes, because then it will match all routes beginning with
`/connections`, and the plugin's routes will have no effect.

So the only alternative left is to find another path :/

Since we set the DataSourceDetailsPage's navId explicitly to
`connections-connect-data`, the breadcrumbs will continue to show the
data source page as a child item of the Connect Data page :)
This commit is contained in:
mikkancso 2023-01-03 13:57:16 +01:00 committed by GitHub
parent b1573104d4
commit 899b035087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,5 +15,5 @@ export const ROUTES = {
// Connect Data
ConnectData: `/${ROUTE_BASE_ID}/connect-data`,
DataSourcesDetails: `/${ROUTE_BASE_ID}/connect-data/datasources/:id`,
DataSourcesDetails: `/${ROUTE_BASE_ID}/datasources/:id`,
} as const;