[v10.0.x] Connections: Redirect from outdated URLs (#73570)
Connections: Redirect from outdated URLs (#73278)
Connections: redirect from outdated URLs
(cherry picked from commit 88cdc38afa)
Co-authored-by: mikkancso <miklos.tolnai@grafana.com>
This commit is contained in:
co-authored by
mikkancso
parent
76ae8351bd
commit
08c545cf3b
@@ -1,5 +1,5 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Redirect, Route, Switch } from 'react-router-dom';
|
import { Redirect, Route, Switch, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import { DataSourcesRoutesContext } from 'app/features/datasources/state';
|
import { DataSourcesRoutesContext } from 'app/features/datasources/state';
|
||||||
import { StoreState, useSelector } from 'app/types';
|
import { StoreState, useSelector } from 'app/types';
|
||||||
@@ -14,6 +14,18 @@ import {
|
|||||||
NewDataSourcePage,
|
NewDataSourcePage,
|
||||||
} from './pages';
|
} from './pages';
|
||||||
|
|
||||||
|
function RedirectToAddNewConnection() {
|
||||||
|
const { search } = useLocation();
|
||||||
|
return (
|
||||||
|
<Redirect
|
||||||
|
to={{
|
||||||
|
pathname: ROUTES.AddNewConnection,
|
||||||
|
search,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default function Connections() {
|
export default function Connections() {
|
||||||
const navIndex = useSelector((state: StoreState) => state.navIndex);
|
const navIndex = useSelector((state: StoreState) => state.navIndex);
|
||||||
const isAddNewConnectionPageOverridden = Boolean(navIndex['standalone-plugin-page-/connections/add-new-connection']);
|
const isAddNewConnectionPageOverridden = Boolean(navIndex['standalone-plugin-page-/connections/add-new-connection']);
|
||||||
@@ -41,6 +53,11 @@ export default function Connections() {
|
|||||||
<Route exact sensitive path={ROUTES.AddNewConnection} component={AddNewConnectionPage} />
|
<Route exact sensitive path={ROUTES.AddNewConnection} component={AddNewConnectionPage} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Redirect from earlier routes to updated routes */}
|
||||||
|
<Route exact path={ROUTES.ConnectDataOutdated} component={RedirectToAddNewConnection} />
|
||||||
|
<Redirect from={`${ROUTES.Base}/your-connections/:page`} to={`${ROUTES.Base}/:page`} />
|
||||||
|
<Redirect from={ROUTES.YourConnectionsOutdated} to={ROUTES.DataSources} />
|
||||||
|
|
||||||
{/* Not found */}
|
{/* Not found */}
|
||||||
<Route component={() => <Redirect to="/notfound" />} />
|
<Route component={() => <Redirect to="/notfound" />} />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -13,4 +13,8 @@ export const ROUTES = {
|
|||||||
// Add new connection
|
// Add new connection
|
||||||
AddNewConnection: `/${ROUTE_BASE_ID}/add-new-connection`,
|
AddNewConnection: `/${ROUTE_BASE_ID}/add-new-connection`,
|
||||||
DataSourcesDetails: `/${ROUTE_BASE_ID}/datasources/:id`,
|
DataSourcesDetails: `/${ROUTE_BASE_ID}/datasources/:id`,
|
||||||
|
|
||||||
|
// Outdated
|
||||||
|
ConnectDataOutdated: `/${ROUTE_BASE_ID}/connect-data`,
|
||||||
|
YourConnectionsOutdated: `/${ROUTE_BASE_ID}/your-connections`,
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
Reference in New Issue
Block a user