Skip to content

Commit fa68b9e

Browse files
authored
Include deprecation banner on all versions that share the oldest deprecation date (#59218)
1 parent 650d266 commit fa68b9e

6 files changed

Lines changed: 33 additions & 4 deletions

File tree

src/app/lib/main-context-adapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function adaptAppRouterContextToMainContext(
4040
oldestSupported: '',
4141
nextDeprecationDate: '',
4242
supported: [],
43+
releasesWithOldestDeprecationDate: [],
4344
},
4445
enterpriseServerVersions: [],
4546
error: '',

src/frame/components/context/MainContext.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type EnterpriseServerReleases = {
8686
oldestSupported: string
8787
nextDeprecationDate: string
8888
supported: Array<string>
89+
releasesWithOldestDeprecationDate: Array<string>
8990
}
9091

9192
export type MainContextT = {
@@ -193,7 +194,11 @@ export const getMainContext = async (req: any, res: any): Promise<MainContextT>
193194

194195
// To know whether we need this key, we need to match this
195196
// with the business logic in `DeprecationBanner.tsx` which is as follows:
196-
if (req.context.currentVersion.includes(req.context.enterpriseServerReleases.oldestSupported)) {
197+
if (
198+
req.context.enterpriseServerReleases.releasesWithOldestDeprecationDate.includes(
199+
req.context.currentRelease,
200+
)
201+
) {
197202
reusables.enterprise_deprecation = {
198203
version_was_deprecated: req.context.getDottedData(
199204
'reusables.enterprise_deprecation.version_was_deprecated',
@@ -264,6 +269,7 @@ export const getMainContext = async (req: any, res: any): Promise<MainContextT>
264269
'oldestSupported',
265270
'nextDeprecationDate',
266271
'supported',
272+
'releasesWithOldestDeprecationDate',
267273
]),
268274
enterpriseServerVersions: req.context.enterpriseServerVersions,
269275
error: req.context.error ? req.context.error.toString() : '',

src/versions/components/DeprecationBanner.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import styles from './DeprecationBanner.module.scss'
99
export const DeprecationBanner = () => {
1010
const { data, enterpriseServerReleases } = useMainContext()
1111
const { currentVersion } = useVersion()
12+
const currentRelease = currentVersion.replace('enterprise-server@', '')
1213

13-
if (!currentVersion.includes(enterpriseServerReleases.oldestSupported)) {
14+
if (!enterpriseServerReleases.releasesWithOldestDeprecationDate.includes(currentRelease)) {
1415
return null
1516
}
1617

src/versions/lib/enterprise-server-releases.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const oldestSupported: string
4242
export const dates: Dates
4343
export const nextDeprecationDate: string
4444
export const isOldestReleaseDeprecated: boolean
45+
export const releasesWithOldestDeprecationDate: string[]
4546
export const deprecatedOnNewSite: string[]
4647
export const deprecatedReleasesWithLegacyFormat: string[]
4748
export const deprecatedReleasesWithNewFormat: string[]

src/versions/lib/enterprise-server-releases.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ export const isOldestReleaseDeprecated = nextDeprecationDate
127127
? new Date() > new Date(nextDeprecationDate)
128128
: false
129129

130+
// Find any other releases that may share the oldest deprecation date
131+
// We'll want to display the deprecation banner on all of these releases (not just oldest)
132+
export const releasesWithOldestDeprecationDate = Object.entries(dates)
133+
.filter(([, versionData]) => versionData.deprecationDate === nextDeprecationDate)
134+
.map(([version]) => version)
135+
130136
// Filtered version arrays for different use cases
131137
export const deprecatedOnNewSite = deprecated.filter((version) =>
132138
versionSatisfiesRange(version, '>=2.13'),
@@ -210,6 +216,7 @@ export default {
210216
oldestSupported,
211217
nextDeprecationDate,
212218
isOldestReleaseDeprecated,
219+
releasesWithOldestDeprecationDate,
213220
deprecatedOnNewSite,
214221
dates,
215222
firstVersionDeprecatedOnNewSite,

src/versions/tests/enterprise-versions.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import { describe, expect, test } from 'vitest'
22

33
import patterns from '@/frame/lib/patterns'
44
import EnterpriseServerReleases from '@/versions/lib/enterprise-server-releases'
5-
const { supported, deprecated, all, latest, oldestSupported, nextDeprecationDate } =
6-
EnterpriseServerReleases
5+
const {
6+
supported,
7+
deprecated,
8+
all,
9+
latest,
10+
oldestSupported,
11+
nextDeprecationDate,
12+
releasesWithOldestDeprecationDate,
13+
} = EnterpriseServerReleases
714

815
describe('enterpriseServerReleases module', () => {
916
test('includes an array of `supported` versions', async () => {
@@ -37,4 +44,10 @@ describe('enterpriseServerReleases module', () => {
3744
test('has a `nextDeprecationDate` property', async () => {
3845
expect(nextDeprecationDate).toMatch(patterns.ymd)
3946
})
47+
48+
test('has a `releasesWithOldestDeprecationDate` property', async () => {
49+
expect(Array.isArray(releasesWithOldestDeprecationDate)).toBe(true)
50+
expect(releasesWithOldestDeprecationDate.length).toBeGreaterThan(0)
51+
expect(releasesWithOldestDeprecationDate).toContain(oldestSupported)
52+
})
4053
})

0 commit comments

Comments
 (0)