From ff178641be06e99932800adf5c4ed434e6462d3e Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Fri, 1 Mar 2024 15:36:19 +1300 Subject: [PATCH] fix(help): add versioned doc links to support LTS/STS docs [EE-6780] (#11282) --- .../PageHeader/ContextHelp/ContextHelp.tsx | 23 ++++++++++++++++--- .../PageHeader/HeaderTitle.test.tsx | 15 ++++++++---- .../components/PageHeader/PageHeader.test.tsx | 4 ++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/react/components/PageHeader/ContextHelp/ContextHelp.tsx b/app/react/components/PageHeader/ContextHelp/ContextHelp.tsx index a7626004e..beafd7949 100644 --- a/app/react/components/PageHeader/ContextHelp/ContextHelp.tsx +++ b/app/react/components/PageHeader/ContextHelp/ContextHelp.tsx @@ -2,6 +2,8 @@ import { HelpCircle } from 'lucide-react'; import clsx from 'clsx'; import { useCurrentStateAndParams } from '@uirouter/react'; +import { useSystemVersion } from '@/react/portainer/system/useSystemVersion'; + import headerStyles from '../HeaderTitle.module.css'; import './ContextHelp.css'; @@ -11,7 +13,7 @@ export function ContextHelp() { return (
= 2) { + const version = parts.slice(0, 2).join('.'); + url += `v/${version}/`; + } + } + const { data } = state; if ( data && @@ -44,8 +61,8 @@ function useDocsUrl(): string { 'docs' in data && typeof data.docs === 'string' ) { - return data.docs; + return url + data.docs; } - return ''; + return url; } diff --git a/app/react/components/PageHeader/HeaderTitle.test.tsx b/app/react/components/PageHeader/HeaderTitle.test.tsx index ccc072796..2589d9f8c 100644 --- a/app/react/components/PageHeader/HeaderTitle.test.tsx +++ b/app/react/components/PageHeader/HeaderTitle.test.tsx @@ -1,3 +1,5 @@ +import { QueryClient, QueryClientProvider } from 'react-query'; + import { UserContext } from '@/react/hooks/useUser'; import { UserViewModel } from '@/portainer/models/user'; import { render } from '@/react-tools/test-utils'; @@ -23,14 +25,17 @@ test('should not render without a wrapping HeaderContainer', async () => { test('should display a HeaderTitle', async () => { const username = 'username'; const user = new UserViewModel({ Username: username }); + const queryClient = new QueryClient(); const title = 'title'; const { queryByText } = render( - - - - - + + + + + + + ); const heading = queryByText(title); diff --git a/app/react/components/PageHeader/PageHeader.test.tsx b/app/react/components/PageHeader/PageHeader.test.tsx index 8400c5799..75ae5e25f 100644 --- a/app/react/components/PageHeader/PageHeader.test.tsx +++ b/app/react/components/PageHeader/PageHeader.test.tsx @@ -1,6 +1,6 @@ import { UserContext } from '@/react/hooks/useUser'; import { UserViewModel } from '@/portainer/models/user'; -import { render } from '@/react-tools/test-utils'; +import { renderWithQueryClient } from '@/react-tools/test-utils'; import { PageHeader } from './PageHeader'; @@ -9,7 +9,7 @@ test('should display a PageHeader', async () => { const user = new UserViewModel({ Username: username }); const title = 'title'; - const { queryByText } = render( + const { queryByText } = renderWithQueryClient(