From cf650c9349778099e491203a12f080976c5c7d7d Mon Sep 17 00:00:00 2001 From: Levente Balogh Date: Fri, 3 Feb 2023 09:00:30 +0100 Subject: [PATCH] Connections: Fix route-guards (#62771) * fix: use case-sensitive routes for Connections The reason to do this is to have the backend route-guards work properly. (The backend route guards are case-sensitive, thus if the FE would serve the case-insensitive version, then the backend route guards could be bypassed.) * tests: update the tests --- .../features/connections/Connections.test.tsx | 4 +--- .../app/features/connections/Connections.tsx | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/public/app/features/connections/Connections.test.tsx b/public/app/features/connections/Connections.test.tsx index 15c5ee2b2de..b8a6971c725 100644 --- a/public/app/features/connections/Connections.test.tsx +++ b/public/app/features/connections/Connections.test.tsx @@ -103,9 +103,7 @@ describe('Connections', () => { renderPage(ROUTES.ConnectData, store); // We expect not to see the text that would be rendered by the core "Connect data" page - // (Instead we expect to see the default route "Datasources") - expect(await screen.findByText('Datasources')).toBeVisible(); - expect(await screen.findByText('Manage your existing datasource connections')).toBeVisible(); + expect(screen.queryByText('Data sources')).not.toBeInTheDocument(); expect(screen.queryByText('No results matching your query were found.')).not.toBeInTheDocument(); }); }); diff --git a/public/app/features/connections/Connections.tsx b/public/app/features/connections/Connections.tsx index 867cf1bdfd9..fe5bd7ce1d9 100644 --- a/public/app/features/connections/Connections.tsx +++ b/public/app/features/connections/Connections.tsx @@ -29,21 +29,25 @@ export default function Connections() { }} > - } /> + {/* Redirect to "Connect data" by default */} + } /> } /> - - - - - - {!isConnectDataPageOverriden && } + + + + + - {/* Default page */} - + {/* "Connect data" page - we don't register a route in case a plugin already registers a standalone page for it */} + {!isConnectDataPageOverriden && } + + {/* Not found */} + } /> );