mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 09:05:45 -06:00
* Connections: redirects to data sources If Data sources page is the only child of Your connections, then the NavLandingPage doesn't really make sense. * DataSourcesList: do not show add button twice If there are no data sources configured, then the DataSourcesList page shows a large CTA to add a data source. Therefore, the add new data source button in the header is redundant, let's remove it from there in this case. * DataSources: redirect to Connections after delete The primary place of the DataSourceList page is under Connections, provided that the `dataConnectionsConsole` feature is turned on. Therefore, let's redirect there after deleting a data source.
55 lines
2.3 KiB
TypeScript
55 lines
2.3 KiB
TypeScript
import * as React from 'react';
|
|
import { Redirect, 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,
|
|
DataSourceDashboardsPage,
|
|
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']);
|
|
|
|
const YourConnectionsPage =
|
|
navIndex['connections-your-connections'].children && navIndex['connections-your-connections'].children?.length > 1
|
|
? () => <NavLandingPage navId="connections-your-connections" />
|
|
: () => <Redirect to={ROUTES.DataSources} />;
|
|
|
|
return (
|
|
<DataSourcesRoutesContext.Provider
|
|
value={{
|
|
New: ROUTES.DataSourcesNew,
|
|
List: ROUTES.DataSources,
|
|
Edit: ROUTES.DataSourcesEdit,
|
|
Dashboards: ROUTES.DataSourcesDashboards,
|
|
}}
|
|
>
|
|
<Switch>
|
|
{/* Redirect to "Connect data" by default */}
|
|
<Route exact sensitive path={ROUTES.Base} component={() => <Redirect to={ROUTES.ConnectData} />} />
|
|
<Route exact sensitive path={ROUTES.YourConnections} component={YourConnectionsPage} />
|
|
<Route exact sensitive path={ROUTES.DataSources} component={DataSourcesListPage} />
|
|
<Route exact sensitive path={ROUTES.DataSourcesDetails} component={DataSourceDetailsPage} />
|
|
<Route exact sensitive path={ROUTES.DataSourcesNew} component={NewDataSourcePage} />
|
|
<Route exact sensitive path={ROUTES.DataSourcesEdit} component={EditDataSourcePage} />
|
|
<Route exact sensitive path={ROUTES.DataSourcesDashboards} component={DataSourceDashboardsPage} />
|
|
|
|
{/* "Connect data" page - we don't register a route in case a plugin already registers a standalone page for it */}
|
|
{!isConnectDataPageOverriden && <Route exact sensitive path={ROUTES.ConnectData} component={ConnectDataPage} />}
|
|
|
|
{/* Not found */}
|
|
<Route component={() => <Redirect to="/notfound" />} />
|
|
</Switch>
|
|
</DataSourcesRoutesContext.Provider>
|
|
);
|
|
}
|