From 72be2a7edbc9720d66b02c6b14bc86ab3ba9b8a2 Mon Sep 17 00:00:00 2001 From: Heat Hamilton Date: Wed, 11 Sep 2024 16:47:27 -0400 Subject: [PATCH 1/3] Add version selector back to release notes page --- .../__tests__/is-release-notes-page.test.ts | 60 ------------------- src/lib/docs/is-release-notes-page.ts | 11 ---- src/views/docs-view/server.ts | 9 +-- 3 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 src/lib/__tests__/is-release-notes-page.test.ts delete mode 100644 src/lib/docs/is-release-notes-page.ts diff --git a/src/lib/__tests__/is-release-notes-page.test.ts b/src/lib/__tests__/is-release-notes-page.test.ts deleted file mode 100644 index 15c7a57d7f..0000000000 --- a/src/lib/__tests__/is-release-notes-page.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -import { isReleaseNotesPage } from 'lib/docs/is-release-notes-page' - -describe('isReleaseNotesPage', () => { - it('returns true for valid release notes page paths', () => { - const validPaths = [ - '/releases/2022/v220601-1', - '/releases/2021/v210601-2', - '/release-notes/1.2.3', - '/release-notes/2.0.x', - '/release-notes/v2.0.x', - '/boundary/docs/release-notes/v0_15_0', - '/vault/docs/release-notes/1.13.0', - ] - - validPaths.forEach((path) => { - expect(isReleaseNotesPage(path)).toBe(true) - }) - }) - - it('returns false for invalid release notes page paths', () => { - const invalidPaths = [ - '/releases/2022/v220601', - '/releases/2021/v210601', - '/release-notes/1.2', - '/release-notes/2.0', - '/release-notes/2.x', - '/releases/2022/v220601-', - '/releases/2021/v210601-', - '/release-notes/1.2.', - '/release-notes/2.0.', - '/release-notes/2.x.', - '/releases/2022/v220601-1234-5678', - '/releases/2021/v210601-5678-1234', - '/release-notes/1.2.3.4', - '/release-notes/2.0.x.y', - ] - invalidPaths.forEach((path) => { - expect(isReleaseNotesPage(path)).toBe(false) - }) - }) - - it('returns false for non-release notes page paths', () => { - const nonReleaseNotesPaths = [ - '/releases', - '/getting-started', - '/enterprise/v202401-1/migrate', - '/enterprise/v202401-1/releases', - '/waypoint/reference/config', - '/vault/install', - ] - nonReleaseNotesPaths.forEach((path) => { - expect(isReleaseNotesPage(path)).toBe(false) - }) - }) -}) diff --git a/src/lib/docs/is-release-notes-page.ts b/src/lib/docs/is-release-notes-page.ts deleted file mode 100644 index e3c50dfab3..0000000000 --- a/src/lib/docs/is-release-notes-page.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: MPL-2.0 - */ - -// Hide the version selector on TFE release notes page, e.g. /terraform/enterprise// or /vault/docs/release-notes/1.13.0 -export const isReleaseNotesPage = (path: string) => - /(\/releases\/\d{4}\/(v\d{6}-\d{1}))$/i.test(path) || - /\/release-notes\/(v\d+[.|_]|(\d+[.|_]))\d+[.|_]([0-9]|x)$/i.test(path) - ? true - : false diff --git a/src/views/docs-view/server.ts b/src/views/docs-view/server.ts index 84424c41ed..9cb353e693 100644 --- a/src/views/docs-view/server.ts +++ b/src/views/docs-view/server.ts @@ -43,7 +43,6 @@ import { getDeployPreviewLoader } from './utils/get-deploy-preview-loader' import { getCustomLayout } from './utils/get-custom-layout' import type { DocsViewPropOptions } from './utils/get-root-docs-path-generation-functions' import { DocsViewProps } from './types' -import { isReleaseNotesPage } from 'lib/docs/is-release-notes-page' /** * Returns static generation functions which can be exported from a page to fetch docs data @@ -305,7 +304,7 @@ export function getStaticGenerationFunctions< }) /** - * Figure out if a specific docs version is being viewed + * Figure out of a specific docs version is being viewed */ let indexOfVersionPathPart let versionPathPart @@ -453,11 +452,7 @@ export function getStaticGenerationFunctions< }, projectName: projectName || null, versions: - !hideVersionSelector && - !isReleaseNotesPage(currentPathUnderProduct) && // toggle version dropdown - hasMeaningfulVersions - ? validVersions - : null, + !hideVersionSelector && hasMeaningfulVersions ? validVersions : null, } return { From bb8fc42397d0af35b5022a3e8dd630b106187319 Mon Sep 17 00:00:00 2001 From: Heat Hamilton Date: Wed, 11 Sep 2024 17:09:50 -0400 Subject: [PATCH 2/3] Fix typo --- src/views/docs-view/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/docs-view/server.ts b/src/views/docs-view/server.ts index 9cb353e693..67adf88f18 100644 --- a/src/views/docs-view/server.ts +++ b/src/views/docs-view/server.ts @@ -304,7 +304,7 @@ export function getStaticGenerationFunctions< }) /** - * Figure out of a specific docs version is being viewed + * Figure out if a specific docs version is being viewed */ let indexOfVersionPathPart let versionPathPart From e6cea9ddc5fad73e9c8aa97bb2976941a398e231 Mon Sep 17 00:00:00 2001 From: Heat Hamilton Date: Wed, 11 Sep 2024 17:11:03 -0400 Subject: [PATCH 3/3] Fix typo --- src/views/docs-view/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/docs-view/server.ts b/src/views/docs-view/server.ts index 67adf88f18..b60f05a9f2 100644 --- a/src/views/docs-view/server.ts +++ b/src/views/docs-view/server.ts @@ -452,7 +452,7 @@ export function getStaticGenerationFunctions< }, projectName: projectName || null, versions: - !hideVersionSelector && hasMeaningfulVersions ? validVersions : null, + !hideVersionSelector && hasMeaningfulVersions ? versions : null, } return {