From e2a27c9fd88a739ac00f16b8e52372fd71288e18 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Wed, 18 Oct 2023 13:09:19 -0400 Subject: [PATCH 1/2] Only include what's needed in mainContext.data.reusables (#44508) --- components/context/MainContext.tsx | 64 +++++++++++-------- src/versions/components/DeprecationBanner.tsx | 12 +++- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/components/context/MainContext.tsx b/components/context/MainContext.tsx index 7c965675f2..4da423841d 100644 --- a/components/context/MainContext.tsx +++ b/components/context/MainContext.tsx @@ -55,19 +55,22 @@ export type ProductTreeNode = { childPages: Array } +export type EnterpriseDeprecation = { + version_was_deprecated: string + version_will_be_deprecated: string + deprecation_details: string + isOldestReleaseDeprecated?: boolean +} + +type DataReusables = { + enterprise_deprecation?: EnterpriseDeprecation + policies: { + translation: string + } +} type DataT = { ui: Record - reusables: { - enterprise_deprecation: { - version_was_deprecated: string - version_will_be_deprecated: string - deprecation_details: string - isOldestReleaseDeprecated?: boolean - } - policies: { - translation: string - } - } + reusables: DataReusables variables: { release_candidate: { version: string } } @@ -141,6 +144,27 @@ export const getMainContext = async (req: any, res: any): Promise const includeFullProductTree = documentType === 'product' const includeSidebarTree = documentType !== 'homepage' + const reusables: DataReusables = { + policies: { + translation: req.context.getDottedData('reusables.policies.translation'), + }, + } + // To know whether we need this key, we need to match this + // with the business logic in `DeprecationBanner.tsx` which is as follows: + if (req.context.currentVersion.includes(req.context.enterpriseServerReleases.oldestSupported)) { + reusables.enterprise_deprecation = { + version_was_deprecated: req.context.getDottedData( + 'reusables.enterprise_deprecation.version_was_deprecated', + ), + version_will_be_deprecated: req.context.getDottedData( + 'reusables.enterprise_deprecation.version_will_be_deprecated', + ), + deprecation_details: req.context.getDottedData( + 'reusables.enterprise_deprecation.deprecation_details', + ), + } + } + return { breadcrumbs: req.context.breadcrumbs || {}, communityRedirect: req.context.page?.communityRedirect || {}, @@ -151,22 +175,8 @@ export const getMainContext = async (req: any, res: any): Promise data: { ui: req.context.site.data.ui, - reusables: { - enterprise_deprecation: { - version_was_deprecated: req.context.getDottedData( - 'reusables.enterprise_deprecation.version_was_deprecated', - ), - version_will_be_deprecated: req.context.getDottedData( - 'reusables.enterprise_deprecation.version_will_be_deprecated', - ), - deprecation_details: req.context.getDottedData( - 'reusables.enterprise_deprecation.deprecation_details', - ), - }, - policies: { - translation: req.context.getDottedData('reusables.policies.translation'), - }, - }, + reusables, + variables: { release_candidate: { version: req.context.getDottedData('variables.release_candidate.version') || null, diff --git a/src/versions/components/DeprecationBanner.tsx b/src/versions/components/DeprecationBanner.tsx index 2631d2b585..0034bd7e56 100644 --- a/src/versions/components/DeprecationBanner.tsx +++ b/src/versions/components/DeprecationBanner.tsx @@ -1,3 +1,4 @@ +import type { EnterpriseDeprecation } from 'components/context/MainContext' import { useMainContext } from 'components/context/MainContext' import { useVersion } from 'src/versions/components/useVersion' import { Flash } from '@primer/react' @@ -13,9 +14,14 @@ export const DeprecationBanner = () => { return null } + // Have to "trick" TypeScript here because by default, this is an + // optional key. But because we're confident with the JS business + // logic in MainContext.tsx, we can safely assume that this key + // is present. + const enterpriseDeprecation = data.reusables.enterprise_deprecation as EnterpriseDeprecation const message = enterpriseServerReleases.isOldestReleaseDeprecated - ? data.reusables.enterprise_deprecation.version_was_deprecated - : data.reusables.enterprise_deprecation.version_will_be_deprecated + ? enterpriseDeprecation.version_was_deprecated + : enterpriseDeprecation.version_will_be_deprecated return (
{ {' '}

From 40849575dcd9f5a8473e6960944dbf0e75ccd6c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 17:11:28 +0000 Subject: [PATCH 2/2] Bump lint-staged from 14.0.1 to 15.0.1 (#44607) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Grace Park --- package-lock.json | 92 +++++++++++++++++++++++++++-------------------- package.json | 2 +- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a3056505f..6df1b205f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -130,7 +130,7 @@ "jest-slow-test-reporter": "^1.0.0", "json-schema-merge-allof": "^0.8.1", "kill-port": "2.0.1", - "lint-staged": "^14.0.1", + "lint-staged": "^15.0.1", "markdownlint": "^0.28.2", "markdownlint-rule-helpers": "^0.19.0", "markdownlint-rule-search-replace": "^1.2.0", @@ -4225,9 +4225,9 @@ } }, "node_modules/commander": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.0.0.tgz", - "integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", "dev": true, "engines": { "node": ">=16" @@ -9223,62 +9223,74 @@ } }, "node_modules/lint-staged": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-14.0.1.tgz", - "integrity": "sha512-Mw0cL6HXnHN1ag0mN/Dg4g6sr8uf8sn98w2Oc1ECtFto9tvRF7nkXGJRbx8gPlHyoR0pLyBr2lQHbWwmUHe1Sw==", + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.0.1.tgz", + "integrity": "sha512-2IU5OWmCaxch0X0+IBF4/v7sutpB+F3qoXbro43pYjQTOo5wumckjxoxn47pQBqqBsCWrD5HnI2uG/zJA7isew==", "dev": true, "dependencies": { "chalk": "5.3.0", - "commander": "11.0.0", + "commander": "11.1.0", "debug": "4.3.4", - "execa": "7.2.0", + "execa": "8.0.1", "lilconfig": "2.1.0", - "listr2": "6.6.1", + "listr2": "7.0.1", "micromatch": "4.0.5", "pidtree": "0.6.0", "string-argv": "0.3.2", - "yaml": "2.3.1" + "yaml": "2.3.2" }, "bin": { "lint-staged": "bin/lint-staged.js" }, "engines": { - "node": "^16.14.0 || >=18.0.0" + "node": ">=18.12.0" }, "funding": { "url": "https://opencollective.com/lint-staged" } }, "node_modules/lint-staged/node_modules/execa": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", - "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", "dev": true, "dependencies": { "cross-spawn": "^7.0.3", - "get-stream": "^6.0.1", - "human-signals": "^4.3.0", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", "is-stream": "^3.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^5.1.0", "onetime": "^6.0.0", - "signal-exit": "^3.0.7", + "signal-exit": "^4.1.0", "strip-final-newline": "^3.0.0" }, "engines": { - "node": "^14.18.0 || ^16.14.0 || >=18.0.0" + "node": ">=16.17" }, "funding": { "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/lint-staged/node_modules/human-signals": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", - "integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==", + "node_modules/lint-staged/node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", "dev": true, "engines": { - "node": ">=14.18.0" + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lint-staged/node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "dev": true, + "engines": { + "node": ">=16.17.0" } }, "node_modules/lint-staged/node_modules/is-stream": { @@ -9347,6 +9359,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lint-staged/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/lint-staged/node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -9386,9 +9410,9 @@ } }, "node_modules/listr2": { - "version": "6.6.1", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-6.6.1.tgz", - "integrity": "sha512-+rAXGHh0fkEWdXBmX+L6mmfmXmXvDGEKzkjxO+8mP3+nI/r/CWznVBvsibXdxda9Zz0OW2e2ikphN3OwCT/jSg==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-7.0.1.tgz", + "integrity": "sha512-nz+7hwgbDp8eWNoDgzdl4hA/xDSLrNRzPu1TLgOYs6l5Y+Ma6zVWWy9Oyt9TQFONwKoSPoka3H50D3vD5EuNwg==", "dev": true, "dependencies": { "cli-truncate": "^3.1.0", @@ -9400,14 +9424,6 @@ }, "engines": { "node": ">=16.0.0" - }, - "peerDependencies": { - "enquirer": ">= 2.3.0 < 3" - }, - "peerDependenciesMeta": { - "enquirer": { - "optional": true - } } }, "node_modules/listr2/node_modules/ansi-styles": { @@ -15452,9 +15468,9 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", "dev": true, "engines": { "node": ">= 14" diff --git a/package.json b/package.json index dd4187d63c..6826324b81 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,7 @@ "jest-slow-test-reporter": "^1.0.0", "json-schema-merge-allof": "^0.8.1", "kill-port": "2.0.1", - "lint-staged": "^14.0.1", + "lint-staged": "^15.0.1", "markdownlint": "^0.28.2", "markdownlint-rule-helpers": "^0.19.0", "markdownlint-rule-search-replace": "^1.2.0",