Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/discussions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ redirect_from:
- /organizations/collaborating-with-your-team/pinning-a-team-discussion
- /organizations/collaborating-with-your-team
- /rest/teams/discussion-comments
- /rest/teams/discussions
featuredLinks:
startHere:
- /discussions/collaborating-with-your-community-using-discussions/about-discussions
Expand Down
19 changes: 0 additions & 19 deletions content/rest/teams/discussions.md

This file was deleted.

1 change: 0 additions & 1 deletion content/rest/teams/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ versions:
topics:
- API
children:
- /discussions
- /external-groups
- /members
- /team-sync
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default [

// Disabled rules to review
'no-console': 'off', // 800+
'@typescript-eslint/no-explicit-any': 'off', // 1000+
'@typescript-eslint/no-explicit-any': 'off',
},
},

Expand Down
34 changes: 28 additions & 6 deletions src/automated-pipelines/components/AutomatedPageContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createContext, useContext } from 'react'
import type { IncomingMessage } from 'http'
import type { JSX } from 'react'
import type { MiniTocItem } from '@/frame/components/context/ArticleContext'
import type { Context } from '@/types'

export type AutomatedPageContextT = {
title: string
Expand All @@ -25,15 +27,35 @@ export const useAutomatedPageContext = (): AutomatedPageContextT => {
return context
}

export const getAutomatedPageContextFromRequest = (req: any): AutomatedPageContextT => {
const page = req.context.page
type AutomatedPageContextRequest = { context?: Partial<Context> } | IncomingMessage

type AutomatedPage = {
title: string
intro: string
product?: string
permissions?: string
rawPermissions?: string
}

export const getAutomatedPageContextFromRequest = (
req: AutomatedPageContextRequest,
): AutomatedPageContextT => {
const context = 'context' in req ? ((req.context as Partial<Context> | undefined) ?? {}) : {}
const page = context.page as AutomatedPage | undefined

if (!page) {
throw new Error('"getAutomatedPageContextFromRequest" requires req.context.page')
}

const renderedPage = context.renderedPage ?? ''
const miniTocItems = context.miniTocItems ?? []

return {
title: page.title,
intro: page.intro,
renderedPage: req.context.renderedPage || '',
miniTocItems: req.context.miniTocItems || [],
product: page.product || '',
permissions: page.permissions || '',
renderedPage,
miniTocItems,
product: page.product ?? '',
permissions: page.permissions ?? page.rawPermissions ?? '',
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const imageFileKebabCase = {
suggestedFileName,
imageFileName,
[token.line.indexOf(imageFileName) + 1, imageFileName.length],
null, // Todo add fix
null,
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/deployments/production/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Production deploys

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


## Auto deploys

Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/fixtures/rest-redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
"/v3/scim": "/en/enterprise-cloud@latest/rest/scim",
"/v3/search": "/en/rest/search",
"/v3/teams/discussion_comments": "/en/discussions",
"/v3/teams/discussions": "/en/rest/teams/discussions",
"/v3/teams/discussions": "/en/discussions",
"/v3/teams": "/en/rest/teams",
"/v3/teams/members": "/en/rest/teams/members",
"/v3/teams/team_sync": "/en/enterprise-cloud@latest/rest/teams/team-sync",
Expand Down
6 changes: 3 additions & 3 deletions src/fixtures/tests/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('annotations', () => {
expect(annotation.find('.annotate-inline').length).toBe(1)
expect(annotation.find('.annotate-row').length).toBe(3)
const notes = $('.annotate-row .annotate-note p', annotation)
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
const noteTexts = notes.map((_, el) => $(el).text()).get()
expect(noteTexts).toEqual(["Let's get started", 'This is just a sample', 'End of the script'])
}
// Second code snippet block
Expand All @@ -33,7 +33,7 @@ describe('annotations', () => {
expect(annotation.find('.annotate-inline').length).toBe(1)
expect(annotation.find('.annotate-row').length).toBe(2)
const notes = $('.annotate-row .annotate-note p', annotation)
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
const noteTexts = notes.map((_, el) => $(el).text()).get()
expect(noteTexts).toEqual(['Has to start with a comment.', 'This is the if statement'])
}
// Yaml code snippet that starts with an empty comment
Expand All @@ -44,7 +44,7 @@ describe('annotations', () => {
expect(annotation.find('.annotate-inline').length).toBe(1)
expect(annotation.find('.annotate-row').length).toBe(3)
const notes = $('.annotate-row .annotate-note p', annotation)
const noteTexts = notes.map((i: number, el: any) => $(el).text()).get()
const noteTexts = notes.map((_, el) => $(el).text()).get()
expect(noteTexts).toEqual([
'Configures this workflow to run every time a change is pushed to the branch called release.',
"This job checks out the repository contents ...\nAnd here's the second comment line.",
Expand Down
48 changes: 28 additions & 20 deletions src/frame/tests/find-page-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
import { fileURLToPath } from 'url'
import path from 'path'
import http from 'http'
import { Socket } from 'net'

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

import Page from '@/frame/lib/page'
import findPage from '@/frame/middleware/find-page'
import type { ExtendedRequest } from '@/types'
import type { ExtendedRequest, Context } from '@/types'

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

type TestResponse = Response & { _status?: number; _message?: string }

function makeRequestResponse(
url: string,
currentVersion = 'free-pro-team@latest',
): [ExtendedRequest, Response & { _status?: number; _message?: string }] {
const req = new http.IncomingMessage(null as any) as ExtendedRequest
): [ExtendedRequest, TestResponse] {
const req = new http.IncomingMessage(new Socket()) as ExtendedRequest

Object.defineProperty(req, 'path', {
value: url,
writable: true,
})

req.method = 'GET'
req.url = url
// @ts-expect-error - path is read-only but we need to set it for testing
req.path = url
req.cookies = {}
req.headers = {}

// Custom keys on the request
const context: Context = {
currentVersion,
pages: {},
}

req.pagePath = url
req.context = {}
req.context.currentVersion = currentVersion
req.context.pages = {}
req.context = context

const res = new http.ServerResponse(req) as Response & {
_status?: number
_message?: string
}
res.status = function (code: number) {
const res = new http.ServerResponse(req) as TestResponse
res.status = function status(this: TestResponse, code: number) {
this._status = code
return {
return Object.assign(this, {
send: (message: string) => {
this._message = message
return this
},
} as any
})
}

return [req, res]
Expand All @@ -56,7 +63,7 @@ describe('find page middleware', () => {
})
if (page && req.context) {
req.context.pages = {
'/en/foo/bar': page as any,
'/en/foo/bar': page,
}
}

Expand Down Expand Up @@ -88,7 +95,7 @@ describe('find page middleware', () => {
})
if (page && req.context) {
req.context.pages = {
'/en/page-with-redirects': page as any,
'/en/page-with-redirects': page,
}
}

Expand All @@ -98,6 +105,7 @@ describe('find page middleware', () => {
})
expect(req.context?.page).toBeInstanceOf(Page)
})

test('finds it for non-fpt version URLS', async () => {
const [req, res] = makeRequestResponse('/en/page-with-redirects', 'enterprise-cloud@latest')
const page = await Page.init({
Expand All @@ -107,7 +115,7 @@ describe('find page middleware', () => {
})
if (page && req.context) {
req.context.pages = {
'/en/page-with-redirects': page as any,
'/en/page-with-redirects': page,
}
}

Expand All @@ -129,7 +137,7 @@ describe('find page middleware', () => {
})
if (page && req.context) {
req.context.pages = {
'/en/page-with-redirects': page as any,
'/en/page-with-redirects': page,
}
}

Expand Down
Loading
Loading