Skip to content

Commit 6b26400

Browse files
authored
only include props we need (#28067)
1 parent 5102f4c commit 6b26400

File tree

1 file changed

+41
-45
lines changed

1 file changed

+41
-45
lines changed

pages/[versionId]/admin/release-notes.tsx

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,21 @@ import { MainContextT, MainContext, getMainContext } from 'components/context/Ma
44
import { DefaultLayout } from 'components/DefaultLayout'
55
import { GHAEReleaseNotes } from 'components/release-notes/GHAEReleaseNotes'
66
import { GHESReleaseNotes } from 'components/release-notes/GHESReleaseNotes'
7-
import {
8-
CurrentVersion,
9-
GHAEReleaseNotesContextT,
10-
GHESReleaseNotesContextT,
11-
} from 'components/release-notes/types'
7+
import { GHAEReleaseNotesContextT, GHESReleaseNotesContextT } from 'components/release-notes/types'
128

139
const liquid = new Liquid()
1410
type Props = {
1511
mainContext: MainContextT
16-
ghaeContext: GHAEReleaseNotesContextT
17-
ghesContext: GHESReleaseNotesContextT
18-
currentVersion: CurrentVersion
12+
ghaeContext?: GHAEReleaseNotesContextT
13+
ghesContext?: GHESReleaseNotesContextT
1914
}
20-
export default function ReleaseNotes({
21-
mainContext,
22-
ghesContext,
23-
ghaeContext,
24-
currentVersion,
25-
}: Props) {
15+
export default function ReleaseNotes({ mainContext, ghesContext, ghaeContext }: Props) {
2616
return (
2717
<MainContext.Provider value={mainContext}>
2818
<DefaultLayout>
29-
{currentVersion.plan === 'enterprise-server' && <GHESReleaseNotes context={ghesContext} />}
19+
{ghesContext && <GHESReleaseNotes context={ghesContext} />}
3020

31-
{currentVersion.plan === 'github-ae' && <GHAEReleaseNotes context={ghaeContext} />}
21+
{ghaeContext && <GHAEReleaseNotes context={ghaeContext} />}
3222
</DefaultLayout>
3323
</MainContext.Provider>
3424
)
@@ -42,35 +32,41 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
4232
return {
4333
props: {
4434
mainContext: getMainContext(req, res),
45-
currentVersion,
46-
ghesContext: {
47-
currentVersion,
48-
latestPatch,
49-
latestRelease,
50-
prevRelease: req.context.prevRelease || '',
51-
nextRelease: req.context.nextRelease || '',
52-
releaseNotes: req.context.releaseNotes,
53-
releases: req.context.releases,
54-
message: {
55-
ghes_release_notes_upgrade_patch_only: liquid.parseAndRenderSync(
56-
req.context.site.data.ui.header.notices.ghes_release_notes_upgrade_patch_only,
57-
{ latestPatch, latestRelease }
58-
),
59-
ghes_release_notes_upgrade_release_only: liquid.parseAndRenderSync(
60-
req.context.site.data.ui.header.notices.ghes_release_notes_upgrade_release_only,
61-
{ latestPatch, latestRelease }
62-
),
63-
ghes_release_notes_upgrade_patch_and_release: liquid.parseAndRenderSync(
64-
req.context.site.data.ui.header.notices.ghes_release_notes_upgrade_patch_and_release,
65-
{ latestPatch, latestRelease }
66-
),
67-
},
68-
},
69-
ghaeContext: {
70-
currentVersion,
71-
releaseNotes: req.context.releaseNotes,
72-
releases: req.context.releases,
73-
},
35+
ghesContext:
36+
currentVersion.plan === 'enterprise-server'
37+
? {
38+
currentVersion,
39+
latestPatch,
40+
latestRelease,
41+
prevRelease: req.context.prevRelease || '',
42+
nextRelease: req.context.nextRelease || '',
43+
releaseNotes: req.context.releaseNotes,
44+
releases: req.context.releases,
45+
message: {
46+
ghes_release_notes_upgrade_patch_only: liquid.parseAndRenderSync(
47+
req.context.site.data.ui.header.notices.ghes_release_notes_upgrade_patch_only,
48+
{ latestPatch, latestRelease }
49+
),
50+
ghes_release_notes_upgrade_release_only: liquid.parseAndRenderSync(
51+
req.context.site.data.ui.header.notices.ghes_release_notes_upgrade_release_only,
52+
{ latestPatch, latestRelease }
53+
),
54+
ghes_release_notes_upgrade_patch_and_release: liquid.parseAndRenderSync(
55+
req.context.site.data.ui.header.notices
56+
.ghes_release_notes_upgrade_patch_and_release,
57+
{ latestPatch, latestRelease }
58+
),
59+
},
60+
}
61+
: undefined,
62+
ghaeContext:
63+
currentVersion.plan === 'github-ae'
64+
? {
65+
currentVersion,
66+
releaseNotes: req.context.releaseNotes,
67+
releases: req.context.releases,
68+
}
69+
: undefined,
7470
},
7571
}
7672
}

0 commit comments

Comments
 (0)