]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23758 No longer alter doc link root provided by the server for local builds
authorDavid Cho-Lerat <david.cho-lerat@sonarsource.com>
Tue, 26 Nov 2024 10:47:25 +0000 (11:47 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 26 Nov 2024 20:02:51 +0000 (20:02 +0000)
server/sonar-web/src/main/js/app/components/__tests__/DocumentationRedirect-test.tsx
server/sonar-web/src/main/js/helpers/docs.ts

index 7548030891fb9c4df105da05926a64de91c39fc6..baaf4d89f6cf5250e4cc157b0601a92a8e5fabf1 100644 (file)
@@ -33,15 +33,6 @@ it('should redirect to static doc for specific version', async () => {
   );
 });
 
-it('should redirect to static doc for latest version', async () => {
-  renderDocumentationRedirect('land', '10.0-SNAPSHOT');
-
-  expect(await screen.findByRole('link')).toHaveAttribute(
-    'href',
-    'https://docs.sonarsource.com/sonarqube/latest/land',
-  );
-});
-
 function renderDocumentationRedirect(navigate: string, version?: string) {
   renderAppRoutes(
     `documentation/${navigate}`,
index ac32f8e5005f8ef4459d4f69627078343f93f15b..32460839c66956d439245bc9a126506af43fa494 100644 (file)
@@ -25,19 +25,15 @@ import { DocLink } from './doc-links';
 // This is only meant to be used directly for DocumentationRedirect. For all other uses,
 // please use useDocUrl instead (it forces the use of a catalogued documentation link)
 export function useUncataloguedDocUrl(to?: string) {
-  const { version, documentationUrl: docUrl } = React.useContext(AppStateContext);
+  const { documentationUrl: docUrl } = React.useContext(AppStateContext);
 
   const formatDocUrl = React.useCallback(
     (href: string) => {
-      const isSnapshot = version.indexOf('SNAPSHOT') !== -1;
-
       const path = href.replace(/^\//, '');
 
-      return isSnapshot
-        ? `${docUrl.replace(docUrl.slice(docUrl.lastIndexOf('/')), '/latest')}/${path}`
-        : `${docUrl}/${path}`;
+      return `${docUrl}/${path}`;
     },
-    [docUrl, version],
+    [docUrl],
   );
 
   return to ? formatDocUrl(to) : formatDocUrl;