Skip to content

Commit 9111b4d

Browse files
authored
Merge branch 'main' into patch-4
2 parents 4c85fb5 + 2014034 commit 9111b4d

44 files changed

Lines changed: 2274 additions & 318 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.

.github/allowed-actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default [
1818
'dawidd6/action-download-artifact@af92a8455a59214b7b932932f2662fdefbd78126', // v2.15.0
1919
'docker://chinthakagodawita/autoupdate-action:v1',
2020
'dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58',
21+
'trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b', // v1.2.4
2122
'github/codeql-action/analyze@v1',
2223
'github/codeql-action/init@v1',
2324
'juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8',

.github/workflows/check-broken-links-github-github.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ jobs:
5959
#
6060
# https://docs.github.com/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions
6161

62-
- if: ${{ failure() }}
62+
- if: ${{ failure() && env.FREEZE != 'true' }}
6363
name: Get title for issue
6464
id: check
6565
run: echo "::set-output name=title::$(head -1 broken_github_github_links.md)"
66-
- if: ${{ failure() }}
66+
- if: ${{ failure() && env.FREEZE != 'true'}}
6767
name: Create issue from file
6868
id: github-github-broken-link-report
6969
uses: peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e

.github/workflows/enterprise-dates.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
branch: enterprise-server-dates-update
6969
delete-branch: true
7070

71-
- if: ${{ failure() }}
71+
- if: ${{ failure() && env.FREEZE != 'true' }}
7272
name: Delete remote branch (if previous steps failed)
7373
uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
7474
with:
@@ -84,7 +84,7 @@ jobs:
8484

8585
- name: Send Slack notification if workflow fails
8686
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
87-
if: failure()
87+
if: ${{ failure() && env.FREEZE != 'true' }}
8888
with:
8989
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
9090
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/remove-unused-assets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
project: Core docs work for the current week
5959
project-column: Should do
6060
branch: remove-unused-assets
61-
- if: ${{ failure() }}
61+
- if: ${{ failure() && env.FREEZE != 'true' }}
6262
name: Delete remote branch (if previous steps failed)
6363
uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
6464
with:

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ jobs:
4646
# Enables cloning the Early Access repo later with the relevant PAT
4747
persist-credentials: 'false'
4848

49+
- name: Gather files changed
50+
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
51+
id: get_diff_files
52+
with:
53+
# So that `steps.get_diff_files.outputs.files` becomes
54+
# a string like `foo.js path/bar.md`
55+
output: ' '
56+
57+
- name: Insight into changed files
58+
run: |
59+
echo ${{ steps.get_diff_files.outputs.files }}
60+
4961
- name: Setup node
5062
uses: actions/setup-node@270253e841af726300e85d718a5f606959b2903c
5163
with:
@@ -67,4 +79,6 @@ jobs:
6779
run: npm run build
6880

6981
- name: Run tests
82+
env:
83+
DIFF_FILES: ${{ steps.get_diff_files.outputs.files }}
7084
run: npm run test tests/${{ matrix.test-group }}/

.github/workflows/update-graphql-files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
number: ${{ steps.create-pull-request.outputs.pull-request-number }}
7676
- name: Send Slack notification if workflow fails
7777
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
78-
if: failure()
78+
if: ${{ failure() && env.FREEZE != 'true' }}
7979
with:
8080
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
8181
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
2.89 KB
Loading

components/Search.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useTranslation } from 'components/hooks/useTranslation'
77
import { sendEvent, EventType } from 'components/lib/events'
88
import { useMainContext } from './context/MainContext'
99
import { useVersion } from 'components/hooks/useVersion'
10+
import { useQuery } from 'components/hooks/useQuery'
1011
import { useLanguages } from './context/LanguagesContext'
1112

1213
import styles from './Search.module.scss'
@@ -36,10 +37,7 @@ export function Search({
3637
children,
3738
}: Props) {
3839
const router = useRouter()
39-
const query =
40-
router.query.query && Array.isArray(router.query.query)
41-
? router.query.query[0]
42-
: router.query.query || ''
40+
const { query, debug } = useQuery()
4341
const [localQuery, setLocalQuery] = useState(query)
4442
const [debouncedQuery, setDebouncedQuery] = useDebounce<string>(localQuery, 300)
4543
const inputRef = useRef<HTMLInputElement>(null)
@@ -185,7 +183,7 @@ export function Search({
185183
isLoading={isLoading}
186184
results={previousResults}
187185
closeSearch={closeSearch}
188-
debug={'debug' in router.query}
186+
debug={debug}
189187
query={query}
190188
/>
191189
</div>
@@ -279,7 +277,7 @@ function ShowSearchResults({
279277
results: SearchResult[] | undefined
280278
closeSearch: () => void
281279
debug: boolean
282-
query: string | string[]
280+
query: string
283281
}) {
284282
const { t } = useTranslation('search')
285283
const router = useRouter()
@@ -298,7 +296,13 @@ function ShowSearchResults({
298296
version: version,
299297
}
300298
})
301-
const redirectQuery = query ? `?query=${query}` : ''
299+
300+
const redirectParams: {
301+
query: string
302+
debug?: string
303+
} = { query }
304+
if (debug) redirectParams.debug = JSON.stringify(debug)
305+
const redirectQuery = `?${new URLSearchParams(redirectParams).toString()}`
302306

303307
if (results) {
304308
if (results.length === 0) {
@@ -350,7 +354,7 @@ function ShowSearchResults({
350354
renderItem: () => (
351355
<ActionList.Item as="div">
352356
<Link href={url} className="no-underline color-fg-default">
353-
<li key={url} data-testid="search-result" className={cx('list-style-none')}>
357+
<li data-testid="search-result" className={cx('list-style-none')}>
354358
<div className={cx('py-2 px-3')}>
355359
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
356360
<Label variant="small" sx={{ bg: 'accent.emphasis' }}>

components/article/ArticlePage.tsx

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRouter } from 'next/router'
22
import cx from 'classnames'
3-
import { Heading } from '@primer/components'
3+
import { ActionList, Heading } from '@primer/components'
44

55
import { ZapIcon, InfoIcon, ShieldLockIcon } from '@primer/octicons-react'
66
import { Callout } from 'components/ui/Callout'
@@ -45,12 +45,19 @@ export const ArticlePage = () => {
4545

4646
const renderTocItem = (item: MiniTocItem) => {
4747
return (
48-
<li key={item.contents} className={cx(item.platform, 'mb-2 lh-condensed')}>
49-
<div className="mb-2 lh-condensed" dangerouslySetInnerHTML={{ __html: item.contents }} />
50-
{item.items && item.items.length > 0 ? (
51-
<ul className="list-style-none pl-0 f5 mb-0 ml-3">{item.items.map(renderTocItem)}</ul>
52-
) : null}
53-
</li>
48+
<ActionList.Item
49+
as="div"
50+
key={item.contents}
51+
className={item.platform}
52+
sx={{ listStyle: 'none', padding: '2px' }}
53+
>
54+
<div className={cx('lh-condensed')}>
55+
<div dangerouslySetInnerHTML={{ __html: item.contents }} />
56+
{item.items && item.items.length > 0 ? (
57+
<ul className="ml-3">{item.items.map(renderTocItem)}</ul>
58+
) : null}
59+
</div>
60+
</ActionList.Item>
5461
)
5562
}
5663

@@ -111,13 +118,19 @@ export const ArticlePage = () => {
111118
{miniTocItems.length > 1 && (
112119
<>
113120
<Heading as="h2" fontSize={1} id="in-this-article" className="mb-1">
114-
<a className="Link--primary" href="#in-this-article">
115-
{t('miniToc')}
116-
</a>
121+
<Link href="#in-this-article">{t('miniToc')}</Link>
117122
</Heading>
118-
<ul className="list-style-none pl-0 f5 mb-0">
119-
{miniTocItems.map(renderTocItem)}
120-
</ul>
123+
124+
<ActionList
125+
key={title}
126+
items={miniTocItems.map((items) => {
127+
return {
128+
key: title,
129+
text: title,
130+
renderItem: () => <ul>{renderTocItem(items)}</ul>,
131+
}
132+
})}
133+
/>
121134
</>
122135
)}
123136
</>

components/hooks/useQuery.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { useRouter } from 'next/router'
2+
3+
type QueryInfo = {
4+
query: string
5+
debug: boolean
6+
}
7+
export const useQuery = (): QueryInfo => {
8+
const router = useRouter()
9+
const query =
10+
router.query.query && Array.isArray(router.query.query)
11+
? router.query.query[0]
12+
: router.query.query || ''
13+
14+
let debug = false
15+
if (router.query.debug) {
16+
// Now `router.query.debug` is either string or any array of strings
17+
debug = Boolean(
18+
JSON.parse(Array.isArray(router.query.debug) ? router.query.debug[0] : router.query.debug)
19+
)
20+
} else if (router.query.debug === '') {
21+
// E.g. `?query=foo&debug` should be treated as truthy
22+
debug = true
23+
}
24+
25+
return {
26+
query,
27+
debug,
28+
}
29+
}

0 commit comments

Comments
 (0)