Skip to content

Commit b084dbc

Browse files
authored
React: Enable all remaining pages (#20012)
* enable all remaining pages * update tests for survey, filter card dropdowns * fix search test * fix: mobile search layout * update sidebar test * fix: learning track page is optional * fix broken links
1 parent ac4aa70 commit b084dbc

File tree

12 files changed

+47
-67
lines changed

12 files changed

+47
-67
lines changed

components/Search.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ type Props = {
2323
// Homepage and 404 should be `isStandalone`, all others not
2424
// `updateSearchParams` should be false on the GraphQL explorer page
2525
export function Search({ isStandalone = false, updateSearchParams = true, children }: Props) {
26-
const [query, setQuery] = useState('')
26+
const router = useRouter()
27+
const [query, setQuery] = useState(router.query.query || '')
2728
const [results, setResults] = useState<Array<SearchResult>>([])
2829
const [activeHit, setActiveHit] = useState(0)
2930
const inputRef = useRef<HTMLInputElement>(null)
@@ -32,18 +33,14 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr
3233

3334
// Figure out language and version for index
3435
const { languages, searchVersions, nonEnterpriseDefaultVersion } = useMainContext()
35-
const router = useRouter()
3636
// fall back to the non-enterprise default version (FPT currently) on the homepage, 404 page, etc.
3737
const version = searchVersions[currentVersion] || searchVersions[nonEnterpriseDefaultVersion]
3838
const language = (Object.keys(languages).includes(router.locale || '') && router.locale) || 'en'
3939

4040
// If the user shows up with a query in the URL, go ahead and search for it
4141
useEffect(() => {
42-
const params = new URLSearchParams(location.search)
43-
if (params.has('query')) {
44-
const xquery = params.get('query')?.trim() || ''
45-
setQuery(xquery)
46-
/* await */ fetchSearchResults(xquery)
42+
if (router.query.query) {
43+
/* await */ fetchSearchResults((router.query.query as string).trim())
4744
}
4845
}, [])
4946

@@ -183,7 +180,7 @@ export function Search({ isStandalone = false, updateSearchParams = true, childr
183180
</div>
184181
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
185182
<div
186-
className={'search-overlay-desktop' + (!isStandalone && query ? ' js-open' : '')}
183+
className={cx('search-overlay-desktop', !isStandalone && query ? 'js-open' : '')}
187184
onClick={closeSearch}
188185
></div>
189186
</>

components/Survey.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Survey = () => {
3535
}
3636

3737
return (
38-
<form className="f5" onSubmit={submit} ref={formRef}>
38+
<form className="f5" onSubmit={submit} ref={formRef} data-testid="survey-form">
3939
<h2 className="mb-1 f4">
4040
{t`able_to_find`}
4141

@@ -128,7 +128,7 @@ export const Survey = () => {
128128
</>
129129
)}
130130

131-
{state === ViewState.END && <p className="color-text-secondary f6">{t`feedback`}</p>}
131+
{state === ViewState.END && <p className="color-text-secondary f6" data-testid="survey-end">{t`feedback`}</p>}
132132
</form>
133133
)
134134
}

components/context/ProductSubLandingContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type FeaturedTrack = {
55
trackName: string
66
title: string
77
description: string
8-
guides?: Array<{ href: string; page: { type: string }; title: string; intro: string }>
8+
guides?: Array<{ href: string; page?: { type: string }; title: string; intro: string }>
99
} | null
1010

1111
export type ArticleGuide = {

components/release-notes/GHESReleaseNotes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function GHESReleaseNotes({ context }: Props) {
3636
{prevRelease ? (
3737
<Link
3838
className="btn btn-outline"
39-
href={`/${currentLanguage}/${currentVersion.plan}@${prevRelease}/${currentProduct}/release-notes`}
39+
href={`/${currentLanguage}/${currentVersion.plan}@${prevRelease}/${currentProduct?.id}/release-notes`}
4040
>
4141
<ChevronLeftIcon /> {prevRelease}
4242
</Link>
@@ -51,7 +51,7 @@ export function GHESReleaseNotes({ context }: Props) {
5151
{nextRelease ? (
5252
<Link
5353
className="btn btn-outline"
54-
href={`/${currentLanguage}/${currentVersion.plan}@${nextRelease}/${currentProduct}/release-notes`}
54+
href={`/${currentLanguage}/${currentVersion.plan}@${nextRelease}/${currentProduct?.id}/release-notes`}
5555
>
5656
{nextRelease} <ChevronRightIcon />
5757
</Link>

components/sublanding/ArticleCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ type Props = {
77

88
export const ArticleCard = ({ card, typeLabel }: Props) => {
99
return (
10-
<div className="d-flex col-12 col-md-4 pr-0 pr-md-6 pr-lg-8">
10+
<div data-testid="article-card" className="d-flex col-12 col-md-4 pr-0 pr-md-6 pr-lg-8">
1111
<a className="no-underline d-flex flex-column py-3 border-bottom" href={card.href}>
1212
<h4 className="h4 color-text-primary mb-1">{card.title}</h4>
13-
<div className="h6 text-uppercase">{typeLabel}</div>
13+
<div className="h6 text-uppercase" data-testid="article-card-type">{typeLabel}</div>
1414
<p className="color-text-secondary my-3">{card.intro}</p>
1515
{card.topics.length > 0 && (
1616
<div>
1717
{card.topics.map((topic) => {
1818
return (
1919
<span
20+
data-testid="article-card-topic"
2021
key={topic}
2122
className="IssueLabel bg-gradient--pink-blue color-text-inverse mr-1"
2223
>

components/sublanding/ArticleCards.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const ArticleCards = () => {
5050
className="form-select f4 text-bold border-0 rounded-0 border-top box-shadow-none pl-0"
5151
name="type"
5252
aria-label="guide types"
53+
data-testid="card-filter-dropdown"
5354
onChange={onChangeTypeFilter}
5455
>
5556
<option value="">{t('filters.all')}</option>
@@ -70,6 +71,7 @@ export const ArticleCards = () => {
7071
value={topicFilter}
7172
className="form-select f4 text-bold border-0 rounded-0 border-top box-shadow-none pl-0"
7273
name="topics"
74+
data-testid="card-filter-dropdown"
7375
aria-label="guide topics"
7476
onChange={onChangeTopicFilter}
7577
>

components/sublanding/LearningTrack.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const LearningTrack = ({ track }: Props) => {
5353
</div>
5454
<h5 className="flex-auto pr-2">{guide.title}</h5>
5555
<div className="color-text-tertiary h6 text-uppercase flex-shrink-0">
56-
{t('guide_types')[guide.page.type]}
56+
{t('guide_types')[guide.page?.type || '']}
5757
</div>
5858
</a>
5959
{track?.guides && track?.guides?.indexOf(guide) + 1 === MAX_VISIBLE_GUIDES ? (

components/sublanding/SubLandingHero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const SubLandingHero = () => {
2626
)}
2727
</div>
2828
<div className="color-text-tertiary h6 text-uppercase">
29-
{t('guide_types')[guide.page.type]}
29+
{t('guide_types')[guide.page?.type || '']}
3030
</div>
3131
</div>
3232
<h3 className="font-mktg h3-mktg my-4 color-text-primary">{guide.title}</h3>

middleware/is-next-request.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,6 @@ const versionIds = Object.keys(require('../lib/all-versions'))
55

66
const { FEATURE_NEXTJS } = process.env;
77

8-
const enabledSubSections = [
9-
// 'actions',
10-
// 'admin',
11-
"billing",
12-
// "code-security",
13-
// "codespaces",
14-
"communities",
15-
"desktop",
16-
// "developers",
17-
"discussions",
18-
// 'early-access',
19-
"education",
20-
// 'github',
21-
// "graphql",
22-
// 'insights',
23-
// "issues",
24-
"organizations",
25-
'packages',
26-
"pages",
27-
"rest",
28-
"sponsors",
29-
];
30-
318
const homePageExp = pathToRegexp('/:locale/:versionId?')
329
const productPageExp = pathToRegexp('/:locale/:versionId?/:productId')
3310
const subSectionExp = pathToRegexp('/:locale/:versionId?/:productId/:subSection*')
@@ -53,8 +30,7 @@ module.exports = function isNextRequest(req, res, next) {
5330
} else if (productPageMatch && productIds.includes(productPageMatch[3])) {
5431
req.renderWithNextjs = true
5532
} else if (subSectionMatch) {
56-
// depending on whether versionId is included the productId is in a different place
57-
req.renderWithNextjs = enabledSubSections.includes(subSectionMatch[2]) || enabledSubSections.includes(subSectionMatch[3])
33+
req.renderWithNextjs = true
5834
}
5935
}
6036
}

stylesheets/search.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ header {
8686
margin-bottom: 0;
8787
}
8888

89-
@include breakpoint(md) {
89+
@include breakpoint(lg) {
9090
#search-results-container {
9191
display: none;
9292
position: absolute;

0 commit comments

Comments
 (0)