Skip to content

Commit 66c5507

Browse files
authored
Merge branch 'main' into patch-4
2 parents 7c1e5fd + 06f3cd9 commit 66c5507

File tree

133 files changed

+1107
-1077
lines changed

Some content is hidden

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

133 files changed

+1107
-1077
lines changed

.github/workflows/azure-preview-env-deploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ jobs:
163163
rsync -rptovR ./user-code/assets/./**/*.png ./assets
164164
rsync -rptovR ./user-code/data/./**/*.{yml,md} ./data
165165
rsync -rptovR ./user-code/components/./**/*.{ts,tsx} ./components
166-
rsync -rptovR ./user-code/lib/./**/*.{js,ts,json} ./lib
167-
rsync -rptovR ./user-code/middleware/./**/*.{js,ts} ./middleware
168-
rsync -rptovR ./user-code/pages/./**/*.{tsx} ./pages
169-
rsync -rptovR ./user-code/stylesheets/./**/*.{scss} ./stylesheets
166+
rsync -rptovR --ignore-missing-args ./user-code/lib/./**/*.{js,ts} ./lib
167+
rsync -rptovR --ignore-missing-args ./user-code/middleware/./**/*.{js,ts} ./middleware
168+
rsync -rptovR ./user-code/pages/./**/*.tsx ./pages
169+
rsync -rptovR ./user-code/stylesheets/./**/*.scss ./stylesheets
170170
171171
# In addition to making the final image smaller, we also save time by not sending unnecessary files to the docker build context
172172
- name: 'Prune for preview env'

.github/workflows/move-ready-to-merge-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: move PR
2525
uses: alex-page/github-project-automation-plus@bb266ff4dde9242060e2d5418e120a133586d488
2626
with:
27-
project: Docs team reviews
27+
project: Docs open source board
2828
column: Triage
2929
repo-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
3030

components/article/ArticlePage.tsx

Lines changed: 8 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
import { useState, useEffect, ReactNode } from 'react'
1+
import { useState, useEffect } from 'react'
22
import { useRouter } from 'next/router'
33
import dynamic from 'next/dynamic'
4-
import cx from 'classnames'
5-
import { ActionList, Heading } from '@primer/react'
64

75
import { ZapIcon, InfoIcon, ShieldLockIcon } from '@primer/octicons-react'
86
import { Callout } from 'components/ui/Callout'
97

108
import { Link } from 'components/Link'
119
import { DefaultLayout } from 'components/DefaultLayout'
1210
import { ArticleTitle } from 'components/article/ArticleTitle'
13-
import { MiniTocItem, useArticleContext } from 'components/context/ArticleContext'
11+
import { useArticleContext } from 'components/context/ArticleContext'
1412
import { useTranslation } from 'components/hooks/useTranslation'
1513
import { LearningTrackNav } from './LearningTrackNav'
1614
import { MarkdownContent } from 'components/ui/MarkdownContent'
1715
import { Lead } from 'components/ui/Lead'
1816
import { ArticleGridLayout } from './ArticleGridLayout'
1917
import { PlatformPicker } from 'components/article/PlatformPicker'
2018
import { ToolPicker } from 'components/article/ToolPicker'
19+
import { MiniTocs } from 'components/ui/MiniTocs'
2120

22-
const ClientSideRedirectExceptions = dynamic(() => import('./ClientsideRedirectExceptions'), {
23-
ssr: false,
24-
})
2521
const ClientSideHighlightJS = dynamic(() => import('./ClientSideHighlightJS'), { ssr: false })
2622

2723
// Mapping of a "normal" article to it's interactive counterpart
@@ -49,12 +45,11 @@ const interactiveAlternatives: Record<string, { href: string }> = {
4945
href: '/codespaces/setting-up-your-project-for-codespaces/setting-up-your-project-for-codespaces?langId=py',
5046
},
5147
}
52-
53-
export type StructuredContentT = {
54-
structuredContent?: ReactNode
48+
type Props = {
49+
children?: React.ReactNode
5550
}
5651

57-
export const ArticlePage = ({ structuredContent }: StructuredContentT) => {
52+
export const ArticlePage = ({ children }: Props) => {
5853
const { asPath } = useRouter()
5954
const {
6055
title,
@@ -69,58 +64,9 @@ export const ArticlePage = ({ structuredContent }: StructuredContentT) => {
6964
miniTocItems,
7065
currentLearningTrack,
7166
} = useArticleContext()
72-
const renderedContent = structuredContent || renderedPage
7367
const { t } = useTranslation('pages')
7468
const currentPath = asPath.split('?')[0]
7569

76-
const renderTocItem = (item: MiniTocItem) => {
77-
return (
78-
<ActionList.Item
79-
as="li"
80-
key={item.contents}
81-
className={item.platform}
82-
sx={{ listStyle: 'none', padding: '2px' }}
83-
>
84-
<div className={cx('lh-condensed d-block width-full')}>
85-
<div dangerouslySetInnerHTML={{ __html: item.contents }} />
86-
{item.items && item.items.length > 0 ? (
87-
<ul className="ml-3">{item.items.map(renderTocItem)}</ul>
88-
) : null}
89-
</div>
90-
</ActionList.Item>
91-
)
92-
}
93-
94-
// We have some one-off redirects for rest api docs
95-
// currently those are limited to the repos page, but
96-
// that will grow soon as we restructure the rest api docs.
97-
// This is a workaround to updating the hardcoded links
98-
// directly in the REST API code in a separate repo, which
99-
// requires many file changes and teams to sign off.
100-
// While the organization is turbulent, we can do this.
101-
// Once it's more settled, we can refactor the rest api code
102-
// to leverage the OpenAPI urls rather than hardcoded urls.
103-
// The code below determines if we should bother loading this redirecting
104-
// component at all.
105-
// The reason this isn't done at the server-level is because there you
106-
// can't possibly access the URL hash. That's only known in client-side
107-
// code.
108-
const [loadClientsideRedirectExceptions, setLoadClientsideRedirectExceptions] = useState(false)
109-
useEffect(() => {
110-
const { hash, pathname } = window.location
111-
// Today, Jan 2022, it's known explicitly what the pathname.
112-
// In the future there might be more.
113-
// Hopefully, we can some day delete all of this and no longer
114-
// be dependent on the URL hash to do the redirect.
115-
if (
116-
hash &&
117-
(pathname.endsWith('/rest/reference/repos') ||
118-
pathname.endsWith('/rest/reference/enterprise-admin'))
119-
) {
120-
setLoadClientsideRedirectExceptions(true)
121-
}
122-
}, [])
123-
12470
// If the page contains `[data-highlight]` blocks, these pages need
12571
// syntax highlighting. But not every page needs it, so it's conditionally
12672
// lazy-loaded on the client.
@@ -139,29 +85,8 @@ export const ArticlePage = ({ structuredContent }: StructuredContentT) => {
13985
// consecutive one does.
14086
}, [asPath])
14187

142-
// Scrollable code blocks in our REST API docs and elsewhere aren't accessible
143-
// via keyboard navigation without setting tabindex="0". But we don't want to set
144-
// this attribute on every `<pre>` code block, only the ones where there are scroll
145-
// bars because the content isn't all visible.
146-
useEffect(() => {
147-
const codeBlocks = document.querySelectorAll<HTMLPreElement>('pre')
148-
149-
codeBlocks.forEach((codeBlock) => {
150-
if (
151-
codeBlock.scrollWidth > codeBlock.clientWidth ||
152-
codeBlock.scrollHeight > codeBlock.clientHeight
153-
) {
154-
codeBlock.setAttribute('tabindex', '0')
155-
}
156-
})
157-
}, [])
158-
15988
return (
16089
<DefaultLayout>
161-
{/* Doesn't matter *where* this is included because it will
162-
never render anything. It always just return null. */}
163-
{loadClientsideRedirectExceptions && <ClientSideRedirectExceptions />}
164-
16590
{/* Doesn't matter *where* this is included because it will
16691
never render anything. It always just return null. */}
16792
{lazyLoadHighlightJS && <ClientSideHighlightJS />}
@@ -220,28 +145,13 @@ export const ArticlePage = ({ structuredContent }: StructuredContentT) => {
220145
</div>
221146
)}
222147
{miniTocItems.length > 1 && (
223-
<>
224-
<Heading as="h2" id="in-this-article" className="mb-1" sx={{ fontSize: 1 }}>
225-
<Link href="#in-this-article">{t('miniToc')}</Link>
226-
</Heading>
227-
228-
<ActionList
229-
key={title}
230-
items={miniTocItems.map((items, i) => {
231-
return {
232-
key: title + i,
233-
text: title,
234-
renderItem: () => <ul>{renderTocItem(items)}</ul>,
235-
}
236-
})}
237-
/>
238-
</>
148+
<MiniTocs pageTitle={title} miniTocItems={miniTocItems} />
239149
)}
240150
</>
241151
}
242152
>
243153
<div id="article-contents">
244-
<MarkdownContent>{renderedContent}</MarkdownContent>
154+
<MarkdownContent>{children || renderedPage}</MarkdownContent>
245155
{effectiveDate && (
246156
<div className="mt-4" id="effectiveDate">
247157
Effective as of:{' '}

components/page-header/Breadcrumbs.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import styles from './Breadcrumbs.module.scss'
66

77
export type BreadcrumbT = {
88
title: string
9-
documentType?: string
109
href?: string
1110
}
1211

components/rest/RestParameterTable.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
}
2525

2626
tbody {
27+
tr td {
28+
width: auto;
29+
}
30+
2731
tr td:first-child {
2832
font-weight: bold;
2933
}

components/rest/RestReferencePage.tsx

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
import { useState, useEffect } from 'react'
2+
import { useRouter } from 'next/router'
3+
import dynamic from 'next/dynamic'
4+
5+
import { DefaultLayout } from 'components/DefaultLayout'
6+
import { ArticleTitle } from 'components/article/ArticleTitle'
7+
import { useMainContext } from 'components/context/MainContext'
8+
import { MarkdownContent } from 'components/ui/MarkdownContent'
9+
import { Lead } from 'components/ui/Lead'
10+
import { ArticleGridLayout } from 'components/article/ArticleGridLayout'
11+
import { MiniTocItem } from 'components/context/ArticleContext'
12+
import { RestCategoryOperationsT } from './types'
13+
import { RestOperation } from './RestOperation'
14+
import { MiniTocs } from 'components/ui/MiniTocs'
15+
16+
const ClientSideHighlightJS = dynamic(() => import('components/article/ClientSideHighlightJS'), {
17+
ssr: false,
18+
})
19+
20+
const ClientSideRedirectExceptions = dynamic(
21+
() => import('components/article/ClientsideRedirectExceptions'),
22+
{
23+
ssr: false,
24+
}
25+
)
26+
27+
export type StructuredContentT = {
28+
descriptions: any
29+
introContent: string
30+
restOperations: RestCategoryOperationsT
31+
miniTocItems?: MiniTocItem[]
32+
}
33+
34+
export const RestReferencePage = ({
35+
descriptions,
36+
introContent,
37+
restOperations,
38+
miniTocItems,
39+
}: StructuredContentT) => {
40+
const { asPath } = useRouter()
41+
const { page } = useMainContext()
42+
const subcategories = Object.keys(restOperations)
43+
44+
// We have some one-off redirects for rest api docs
45+
// currently those are limited to the repos page, but
46+
// that will grow soon as we restructure the rest api docs.
47+
// This is a workaround to updating the hardcoded links
48+
// directly in the REST API code in a separate repo, which
49+
// requires many file changes and teams to sign off.
50+
// While the organization is turbulent, we can do this.
51+
// Once it's more settled, we can refactor the rest api code
52+
// to leverage the OpenAPI urls rather than hardcoded urls.
53+
// The code below determines if we should bother loading this redirecting
54+
// component at all.
55+
// The reason this isn't done at the server-level is because there you
56+
// can't possibly access the URL hash. That's only known in client-side
57+
// code.
58+
const [loadClientsideRedirectExceptions, setLoadClientsideRedirectExceptions] = useState(false)
59+
useEffect(() => {
60+
const { hash, pathname } = window.location
61+
// Today, Jan 2022, it's known explicitly what the pathname.
62+
// In the future there might be more.
63+
// Hopefully, we can some day delete all of this and no longer
64+
// be dependent on the URL hash to do the redirect.
65+
if (
66+
hash &&
67+
(pathname.endsWith('/rest/reference/repos') ||
68+
pathname.endsWith('/rest/reference/enterprise-admin'))
69+
) {
70+
setLoadClientsideRedirectExceptions(true)
71+
}
72+
}, [])
73+
74+
// Scrollable code blocks in our REST API docs and elsewhere aren't accessible
75+
// via keyboard navigation without setting tabindex="0". But we don't want to set
76+
// this attribute on every `<pre>` code block, only the ones where there are scroll
77+
// bars because the content isn't all visible.
78+
useEffect(() => {
79+
const codeBlocks = document.querySelectorAll<HTMLPreElement>('pre')
80+
81+
codeBlocks.forEach((codeBlock) => {
82+
if (
83+
codeBlock.scrollWidth > codeBlock.clientWidth ||
84+
codeBlock.scrollHeight > codeBlock.clientHeight
85+
) {
86+
codeBlock.setAttribute('tabindex', '0')
87+
}
88+
})
89+
}, [])
90+
91+
// If the page contains `[data-highlight]` blocks, these pages need
92+
// syntax highlighting. But not every page needs it, so it's conditionally
93+
// lazy-loaded on the client.
94+
const [lazyLoadHighlightJS, setLazyLoadHighlightJS] = useState(false)
95+
useEffect(() => {
96+
// It doesn't need to use querySelector because all we care about is if
97+
// there is greater than zero of these in the DOM.
98+
// Note! This "core selector", which determines whether to bother
99+
// or not, needs to match what's used inside ClientSideHighlightJS.tsx
100+
if (document.querySelector('[data-highlight]')) {
101+
setLazyLoadHighlightJS(true)
102+
}
103+
104+
// Important to depend on the current path because the first page you
105+
// load, before any client-side navigation, might not need it, but the
106+
// consecutive one does.
107+
}, [asPath])
108+
109+
return (
110+
<DefaultLayout>
111+
{/* Doesn't matter *where* this is included because it will
112+
never render anything. It always just return null. */}
113+
{loadClientsideRedirectExceptions && <ClientSideRedirectExceptions />}
114+
{lazyLoadHighlightJS && <ClientSideHighlightJS />}
115+
116+
<div className="container-xl px-3 px-md-6 my-4">
117+
<ArticleGridLayout
118+
topper={<ArticleTitle>{page.title}</ArticleTitle>}
119+
intro={
120+
<>
121+
{page.introPlainText && (
122+
<Lead data-testid="lead" data-search="lead">
123+
{page.introPlainText}
124+
</Lead>
125+
)}
126+
</>
127+
}
128+
toc={
129+
<>
130+
{miniTocItems && miniTocItems.length > 1 && (
131+
<MiniTocs pageTitle={page.title} miniTocItems={miniTocItems} />
132+
)}
133+
</>
134+
}
135+
>
136+
<div key={`restCategory-introContent`}>
137+
<div dangerouslySetInnerHTML={{ __html: introContent }} />
138+
</div>
139+
<div id="article-contents">
140+
<MarkdownContent>
141+
{subcategories.map((subcategory, index) => (
142+
<div key={`restCategory-${index}`}>
143+
<div dangerouslySetInnerHTML={{ __html: descriptions[subcategory] }} />
144+
{restOperations[subcategory].map((operation, index) => (
145+
<RestOperation
146+
key={`restOperation-${index}`}
147+
operation={operation}
148+
index={index}
149+
/>
150+
))}
151+
</div>
152+
))}
153+
</MarkdownContent>
154+
</div>
155+
</ArticleGridLayout>
156+
</div>
157+
</DefaultLayout>
158+
)
159+
}

components/rest/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ export interface ChildParameter {
6969
description: string
7070
type: string
7171
}
72+
73+
export interface RestCategoryOperationsT {
74+
[subcategory: string]: Operation[]
75+
}

0 commit comments

Comments
 (0)