grafana/public/app/features/connections/Connections.tsx
mikkancso e4d4eacd36
Connections: Render a landing page for pages without actual content (#60369)
* render a landing page for pages without actual content

To be consistent with other pages in Grafana

* update tests
2022-12-16 11:00:35 +01:00

49 lines
1.8 KiB
TypeScript

import * as React from 'react';
import { Route, Switch } from 'react-router-dom';
import { NavLandingPage } from 'app/core/components/AppChrome/NavLandingPage';
import { DataSourcesRoutesContext } from 'app/features/datasources/state';
import { StoreState, useSelector } from 'app/types';
import { ROUTES } from './constants';
import {
ConnectDataPage,
DataSourceDetailsPage,
DataSourcesListPage,
EditDataSourcePage,
NewDataSourcePage,
} from './pages';
export default function Connections() {
const navIndex = useSelector((state: StoreState) => state.navIndex);
const isConnectDataPageOverriden = Boolean(navIndex['standalone-plugin-page-/connections/connect-data']);
return (
<DataSourcesRoutesContext.Provider
value={{
New: ROUTES.DataSourcesNew,
List: ROUTES.DataSources,
Edit: ROUTES.DataSourcesEdit,
Dashboards: ROUTES.DataSourcesDashboards,
}}
>
<Switch>
<Route exact path={ROUTES.Base} component={() => <NavLandingPage navId="connections" />} />
<Route
exact
path={ROUTES.YourConnections}
component={() => <NavLandingPage navId="connections-your-connections" />}
/>
<Route exact path={ROUTES.DataSources} component={DataSourcesListPage} />
<Route exact path={ROUTES.DataSourcesDetails} component={DataSourceDetailsPage} />
<Route exact path={ROUTES.DataSourcesNew} component={NewDataSourcePage} />
<Route exact path={ROUTES.DataSourcesEdit} component={EditDataSourcePage} />
{!isConnectDataPageOverriden && <Route path={ROUTES.ConnectData} component={ConnectDataPage} />}
{/* Default page */}
<Route component={DataSourcesListPage} />
</Switch>
</DataSourcesRoutesContext.Provider>
);
}