diff --git a/pkg/services/navtree/navtreeimpl/navtree.go b/pkg/services/navtree/navtreeimpl/navtree.go index d738b496ddd..f77e85e1d28 100644 --- a/pkg/services/navtree/navtreeimpl/navtree.go +++ b/pkg/services/navtree/navtreeimpl/navtree.go @@ -569,6 +569,19 @@ func (s *ServiceImpl) buildDataConnectionsNavLink(c *models.ReqContext) *navtree baseUrl := s.cfg.AppSubURL + "/connections" + // Connect data + // FIXME: while we don't have a permissions for listing plugins the legacy check has to stay as a default + if plugins.ReqCanAdminPlugins(s.cfg)(c) || hasAccess(plugins.ReqCanAdminPlugins(s.cfg), plugins.AdminAccessEvaluator) { + children = append(children, &navtree.NavLink{ + Id: "connections-connect-data", + Text: "Connect data", + SubTitle: "Browse and create new connections", + IsSection: true, + Url: s.cfg.AppSubURL + "/connections/connect-data", + Children: []*navtree.NavLink{}, + }) + } + if hasAccess(ac.ReqOrgAdmin, datasources.ConfigurationPageAccess) { // Your connections children = append(children, &navtree.NavLink{ @@ -586,18 +599,6 @@ func (s *ServiceImpl) buildDataConnectionsNavLink(c *models.ReqContext) *navtree }) } - // Connect data - // FIXME: while we don't have a permissions for listing plugins the legacy check has to stay as a default - if plugins.ReqCanAdminPlugins(s.cfg)(c) || hasAccess(plugins.ReqCanAdminPlugins(s.cfg), plugins.AdminAccessEvaluator) { - children = append(children, &navtree.NavLink{ - Id: "connections-connect-data", - Text: "Connect data", - SubTitle: "Browse and create new connections", - Url: s.cfg.AppSubURL + "/connections/connect-data", - Children: []*navtree.NavLink{}, - }) - } - if len(children) > 0 { // Connections (main) navLink = &navtree.NavLink{ diff --git a/public/app/features/connections/Connections.test.tsx b/public/app/features/connections/Connections.test.tsx index a6298686483..6877f010b6d 100644 --- a/public/app/features/connections/Connections.test.tsx +++ b/public/app/features/connections/Connections.test.tsx @@ -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(); }); diff --git a/public/app/features/connections/Connections.tsx b/public/app/features/connections/Connections.tsx index 184d0fa799f..b2f4c682d57 100644 --- a/public/app/features/connections/Connections.tsx +++ b/public/app/features/connections/Connections.tsx @@ -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 ( - } /> + { + if (canAdminPlugins) { + return ; + } + + return ; + }} + />