mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Connections: Make "Connect data" a section title (#61144)
* Wip * Fix: change tests to cater for the new scenario * feat(Connections): redirect to "Your connections / Datasources" if cannot admin plugins
This commit is contained in:
@@ -41,13 +41,14 @@ describe('Connections', () => {
|
||||
(contextSrv.hasPermission as jest.Mock) = jest.fn().mockReturnValue(true);
|
||||
});
|
||||
|
||||
test('shows a landing page by default', async () => {
|
||||
test('shows the "Connect data" page by default', async () => {
|
||||
renderPage();
|
||||
|
||||
expect(await screen.findByRole('link', { name: 'Your connections' })).toBeVisible();
|
||||
expect(await screen.findByText('Manage your existing connections')).toBeVisible();
|
||||
// Data sources group
|
||||
expect(await screen.findByText('Data sources')).toBeVisible();
|
||||
|
||||
expect(await screen.findByRole('link', { name: 'Connect data' })).toBeVisible();
|
||||
// Heading
|
||||
expect(await screen.findByText('Connect data')).toBeVisible();
|
||||
expect(await screen.findByText('Browse and create new connections')).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import { Redirect, Route, Switch } from 'react-router-dom';
|
||||
|
||||
import { NavLandingPage } from 'app/core/components/AppChrome/NavLandingPage';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import { DataSourcesRoutesContext } from 'app/features/datasources/state';
|
||||
import { StoreState, useSelector } from 'app/types';
|
||||
import { AccessControlAction, StoreState, useSelector } from 'app/types';
|
||||
|
||||
import { ROUTES } from './constants';
|
||||
import {
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
export default function Connections() {
|
||||
const navIndex = useSelector((state: StoreState) => state.navIndex);
|
||||
const isConnectDataPageOverriden = Boolean(navIndex['standalone-plugin-page-/connections/connect-data']);
|
||||
const canAdminPlugins = contextSrv.hasPermission(AccessControlAction.PluginsInstall);
|
||||
|
||||
return (
|
||||
<DataSourcesRoutesContext.Provider
|
||||
@@ -28,7 +30,17 @@ export default function Connections() {
|
||||
}}
|
||||
>
|
||||
<Switch>
|
||||
<Route exact path={ROUTES.Base} component={() => <NavLandingPage navId="connections" />} />
|
||||
<Route
|
||||
exact
|
||||
path={ROUTES.Base}
|
||||
component={() => {
|
||||
if (canAdminPlugins) {
|
||||
return <Redirect to={ROUTES.ConnectData} />;
|
||||
}
|
||||
|
||||
return <Redirect to={ROUTES.DataSources} />;
|
||||
}}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={ROUTES.YourConnections}
|
||||
|
||||
Reference in New Issue
Block a user