Skip to content

Commit c34e3e0

Browse files
authored
Merge branch 'main' into fix-early-access-tocs
2 parents 2352829 + bcf257c commit c34e3e0

72 files changed

Lines changed: 762 additions & 626 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
224 KB
Loading
25.1 KB
Loading

‎components/DefaultLayout.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useTranslation } from './hooks/useTranslation'
1111

1212
type Props = { children?: React.ReactNode }
1313
export const DefaultLayout = (props: Props) => {
14-
const { builtAssets, page, error, isHomepageVersion } = useMainContext()
14+
const { page, error, isHomepageVersion } = useMainContext()
1515
const { t } = useTranslation('errors')
1616
return (
1717
<div className="d-lg-flex">
@@ -22,8 +22,6 @@ export const DefaultLayout = (props: Props) => {
2222
<title>{page.fullTitle}</title>
2323
) : null}
2424

25-
<script src={builtAssets.main.js} />
26-
2725
{/* For Google and Bots */}
2826
{page.introPlainText && <meta name="description" content={page.introPlainText} />}
2927

‎components/PrintAction.tsx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react'
2+
3+
type Props = {
4+
children: React.ReactElement
5+
}
6+
export function PrintAction({ children }: Props) {
7+
const onClick = () => {
8+
try {
9+
document.execCommand('print', false)
10+
} catch (e) {
11+
window.print()
12+
}
13+
}
14+
15+
return React.cloneElement(React.Children.only(children), { onClick })
16+
}

‎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/article/ArticleTitle.tsx‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Tooltip } from '@primer/components'
22
import { PrinterIcon } from './PrinterIcon'
33

4+
import { PrintAction } from 'components/PrintAction'
5+
46
type Props = {
57
children: React.ReactNode
68
}
@@ -10,18 +12,11 @@ export const ArticleTitle = ({ children }: Props) => {
1012
<h1 className="my-4 border-bottom-0">{children}</h1>
1113
<div className="d-none d-lg-block ml-2">
1214
<Tooltip aria-label="Print this article" noDelay direction="n">
13-
<button
14-
className="btn-link Link--muted"
15-
onClick={() => {
16-
try {
17-
document.execCommand('print', false)
18-
} catch (e) {
19-
window.print()
20-
}
21-
}}
22-
>
23-
<PrinterIcon />
24-
</button>
15+
<PrintAction>
16+
<button className="btn-link Link--muted">
17+
<PrinterIcon />
18+
</button>
19+
</PrintAction>
2520
</Tooltip>
2621
</div>
2722
</div>

‎components/context/MainContext.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export type MainContextT = {
6868
maptopic?: BreadcrumbT
6969
article?: BreadcrumbT
7070
}
71-
builtAssets: { main: { js: string } }
7271
activeProducts: Array<ProductT>
7372
currentProduct?: ProductT
7473
currentLayoutName: string
@@ -112,7 +111,6 @@ export type MainContextT = {
112111

113112
export const getMainContextFromRequest = (req: any): MainContextT => {
114113
return {
115-
builtAssets: { main: { js: req.context.builtAssets.main.js } },
116114
breadcrumbs: req.context.breadcrumbs || {},
117115
activeProducts: req.context.activeProducts,
118116
currentProduct: req.context.productMap[req.context.currentProduct] || null,

‎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/GHESReleaseNotePatch.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { PatchNotes } from './PatchNotes'
66
import { Link } from 'components/Link'
77
import { CurrentVersion, ReleaseNotePatch, GHESMessage } from './types'
88
import { useOnScreen } from 'components/hooks/useOnScreen'
9+
import { PrintAction } from 'components/PrintAction'
910

1011
type Props = {
1112
patch: ReleaseNotePatch
@@ -65,7 +66,9 @@ export function GHESReleaseNotePatch({
6566
</Link>
6667
)}
6768

68-
<button className="js-print btn-link ml-3 text-small text-bold">Print</button>
69+
<PrintAction>
70+
<button className="btn-link ml-3 text-small text-bold">Print</button>
71+
</PrintAction>
6972
</div>
7073

7174
<p className="color-text-secondary mt-1">{dayjs(patch.date).format('MMMM, DD, YYYY')}</p>

0 commit comments

Comments
 (0)