Skip to content

Commit 01ba441

Browse files
authored
Merge pull request #42237 from github/repo-sync
Repo sync
2 parents 3b7d170 + 1f9d789 commit 01ba441

File tree

77 files changed

+325
-35024
lines changed

Some content is hidden

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

77 files changed

+325
-35024
lines changed

content/discussions/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ redirect_from:
1111
- /organizations/collaborating-with-your-team/pinning-a-team-discussion
1212
- /organizations/collaborating-with-your-team
1313
- /rest/teams/discussion-comments
14+
- /rest/teams/discussions
1415
featuredLinks:
1516
startHere:
1617
- /discussions/collaborating-with-your-community-using-discussions/about-discussions

content/rest/teams/discussions.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

content/rest/teams/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ versions:
1515
topics:
1616
- API
1717
children:
18-
- /discussions
1918
- /external-groups
2019
- /members
2120
- /team-sync

eslint.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default [
9797

9898
// Disabled rules to review
9999
'no-console': 'off', // 800+
100-
'@typescript-eslint/no-explicit-any': 'off', // 1000+
100+
'@typescript-eslint/no-explicit-any': 'off',
101101
},
102102
},
103103

src/automated-pipelines/components/AutomatedPageContext.tsx

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { createContext, useContext } from 'react'
2+
import type { IncomingMessage } from 'http'
23
import type { JSX } from 'react'
34
import type { MiniTocItem } from '@/frame/components/context/ArticleContext'
5+
import type { Context } from '@/types'
46

57
export type AutomatedPageContextT = {
68
title: string
@@ -25,15 +27,35 @@ export const useAutomatedPageContext = (): AutomatedPageContextT => {
2527
return context
2628
}
2729

28-
export const getAutomatedPageContextFromRequest = (req: any): AutomatedPageContextT => {
29-
const page = req.context.page
30+
type AutomatedPageContextRequest = { context?: Partial<Context> } | IncomingMessage
31+
32+
type AutomatedPage = {
33+
title: string
34+
intro: string
35+
product?: string
36+
permissions?: string
37+
rawPermissions?: string
38+
}
39+
40+
export const getAutomatedPageContextFromRequest = (
41+
req: AutomatedPageContextRequest,
42+
): AutomatedPageContextT => {
43+
const context = 'context' in req ? ((req.context as Partial<Context> | undefined) ?? {}) : {}
44+
const page = context.page as AutomatedPage | undefined
45+
46+
if (!page) {
47+
throw new Error('"getAutomatedPageContextFromRequest" requires req.context.page')
48+
}
49+
50+
const renderedPage = context.renderedPage ?? ''
51+
const miniTocItems = context.miniTocItems ?? []
3052

3153
return {
3254
title: page.title,
3355
intro: page.intro,
34-
renderedPage: req.context.renderedPage || '',
35-
miniTocItems: req.context.miniTocItems || [],
36-
product: page.product || '',
37-
permissions: page.permissions || '',
56+
renderedPage,
57+
miniTocItems,
58+
product: page.product ?? '',
59+
permissions: page.permissions ?? page.rawPermissions ?? '',
3860
}
3961
}

src/content-linter/lib/linting-rules/image-file-kebab-case.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const imageFileKebabCase = {
1818
suggestedFileName,
1919
imageFileName,
2020
[token.line.indexOf(imageFileName) + 1, imageFileName.length],
21-
null, // Todo add fix
21+
null,
2222
)
2323
}
2424
})

src/deployments/production/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Production deploys
22

3-
For internal Docs relating to our production deploys see [TODO Docs-Engineering URL]
3+
44

55
## Auto deploys
66

src/fixtures/fixtures/rest-redirects.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
"/v3/scim": "/en/enterprise-cloud@latest/rest/scim",
494494
"/v3/search": "/en/rest/search",
495495
"/v3/teams/discussion_comments": "/en/discussions",
496-
"/v3/teams/discussions": "/en/rest/teams/discussions",
496+
"/v3/teams/discussions": "/en/discussions",
497497
"/v3/teams": "/en/rest/teams",
498498
"/v3/teams/members": "/en/rest/teams/members",
499499
"/v3/teams/team_sync": "/en/enterprise-cloud@latest/rest/teams/team-sync",

src/fixtures/tests/annotations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('annotations', () => {
2222
expect(annotation.find('.annotate-inline').length).toBe(1)
2323
expect(annotation.find('.annotate-row').length).toBe(3)
2424
const notes = $('.annotate-row .annotate-note p', annotation)
25-
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
25+
const noteTexts = notes.map((_, el) => $(el).text()).get()
2626
expect(noteTexts).toEqual(["Let's get started", 'This is just a sample', 'End of the script'])
2727
}
2828
// Second code snippet block
@@ -33,7 +33,7 @@ describe('annotations', () => {
3333
expect(annotation.find('.annotate-inline').length).toBe(1)
3434
expect(annotation.find('.annotate-row').length).toBe(2)
3535
const notes = $('.annotate-row .annotate-note p', annotation)
36-
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
36+
const noteTexts = notes.map((_, el) => $(el).text()).get()
3737
expect(noteTexts).toEqual(['Has to start with a comment.', 'This is the if statement'])
3838
}
3939
// Yaml code snippet that starts with an empty comment
@@ -44,7 +44,7 @@ describe('annotations', () => {
4444
expect(annotation.find('.annotate-inline').length).toBe(1)
4545
expect(annotation.find('.annotate-row').length).toBe(3)
4646
const notes = $('.annotate-row .annotate-note p', annotation)
47-
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
47+
const noteTexts = notes.map((_, el) => $(el).text()).get()
4848
expect(noteTexts).toEqual([
4949
'Configures this workflow to run every time a change is pushed to the branch called release.',
5050
"This job checks out the repository contents ...\nAnd here's the second comment line.",

src/frame/tests/find-page-middleware.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,52 @@
11
import { fileURLToPath } from 'url'
22
import path from 'path'
33
import http from 'http'
4+
import { Socket } from 'net'
45

56
import { describe, expect, test } from 'vitest'
67
import type { Response } from 'express'
78

89
import Page from '@/frame/lib/page'
910
import findPage from '@/frame/middleware/find-page'
10-
import type { ExtendedRequest } from '@/types'
11+
import type { ExtendedRequest, Context } from '@/types'
1112

1213
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1314

15+
type TestResponse = Response & { _status?: number; _message?: string }
16+
1417
function makeRequestResponse(
1518
url: string,
1619
currentVersion = 'free-pro-team@latest',
17-
): [ExtendedRequest, Response & { _status?: number; _message?: string }] {
18-
const req = new http.IncomingMessage(null as any) as ExtendedRequest
20+
): [ExtendedRequest, TestResponse] {
21+
const req = new http.IncomingMessage(new Socket()) as ExtendedRequest
22+
23+
Object.defineProperty(req, 'path', {
24+
value: url,
25+
writable: true,
26+
})
27+
1928
req.method = 'GET'
2029
req.url = url
21-
// @ts-expect-error - path is read-only but we need to set it for testing
22-
req.path = url
2330
req.cookies = {}
2431
req.headers = {}
2532

26-
// Custom keys on the request
33+
const context: Context = {
34+
currentVersion,
35+
pages: {},
36+
}
37+
2738
req.pagePath = url
28-
req.context = {}
29-
req.context.currentVersion = currentVersion
30-
req.context.pages = {}
39+
req.context = context
3140

32-
const res = new http.ServerResponse(req) as Response & {
33-
_status?: number
34-
_message?: string
35-
}
36-
res.status = function (code: number) {
41+
const res = new http.ServerResponse(req) as TestResponse
42+
res.status = function status(this: TestResponse, code: number) {
3743
this._status = code
38-
return {
44+
return Object.assign(this, {
3945
send: (message: string) => {
4046
this._message = message
47+
return this
4148
},
42-
} as any
49+
})
4350
}
4451

4552
return [req, res]
@@ -56,7 +63,7 @@ describe('find page middleware', () => {
5663
})
5764
if (page && req.context) {
5865
req.context.pages = {
59-
'/en/foo/bar': page as any,
66+
'/en/foo/bar': page,
6067
}
6168
}
6269

@@ -88,7 +95,7 @@ describe('find page middleware', () => {
8895
})
8996
if (page && req.context) {
9097
req.context.pages = {
91-
'/en/page-with-redirects': page as any,
98+
'/en/page-with-redirects': page,
9299
}
93100
}
94101

@@ -98,6 +105,7 @@ describe('find page middleware', () => {
98105
})
99106
expect(req.context?.page).toBeInstanceOf(Page)
100107
})
108+
101109
test('finds it for non-fpt version URLS', async () => {
102110
const [req, res] = makeRequestResponse('/en/page-with-redirects', 'enterprise-cloud@latest')
103111
const page = await Page.init({
@@ -107,7 +115,7 @@ describe('find page middleware', () => {
107115
})
108116
if (page && req.context) {
109117
req.context.pages = {
110-
'/en/page-with-redirects': page as any,
118+
'/en/page-with-redirects': page,
111119
}
112120
}
113121

@@ -129,7 +137,7 @@ describe('find page middleware', () => {
129137
})
130138
if (page && req.context) {
131139
req.context.pages = {
132-
'/en/page-with-redirects': page as any,
140+
'/en/page-with-redirects': page,
133141
}
134142
}
135143

0 commit comments

Comments
 (0)