1
0
mirror of synced 2026-01-08 03:01:54 -05:00

automate github apps docs (#35530)

Co-authored-by: Sarah Edwards <skedwards88@github.com>
This commit is contained in:
Rachael Sewell
2023-06-16 12:23:05 -07:00
committed by GitHub
parent b0ea5f518f
commit cb37f22ef0
89 changed files with 224473 additions and 21362 deletions

View File

@@ -0,0 +1,51 @@
import { GetServerSideProps } from 'next'
import {
AutomatedPageContextT,
getAutomatedPageContextFromRequest,
} from 'src/automated-pipelines/components/AutomatedPageContext'
import { MainContextT, getMainContext } from 'components/context/MainContext'
import { EnabledList, EnabledListT } from 'src/github-apps/components/EnabledList'
type Props = {
mainContext: MainContextT
currentVersion: string
appsItems: EnabledListT
automatedPageContext: AutomatedPageContextT
categoriesWithoutSubcategories: string[]
}
export default function FineGrainedTokenEndpoints({
mainContext,
currentVersion,
appsItems,
automatedPageContext,
categoriesWithoutSubcategories,
}: Props) {
return (
<EnabledList
items={appsItems}
currentVersion={currentVersion}
categoriesWithoutSubcategories={categoriesWithoutSubcategories}
mainContext={mainContext}
automatedPageContext={automatedPageContext}
/>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const { getAppsServerSideProps } = await import('src/github-apps/lib/index.js')
const { currentVersion, appsItems, categoriesWithoutSubcategories } =
await getAppsServerSideProps(context, 'fine-grained-pat', { useDisplayTitle: false })
return {
props: {
mainContext: await getMainContext(context.req, context.res),
currentVersion,
appsItems,
automatedPageContext: getAutomatedPageContextFromRequest(context.req),
categoriesWithoutSubcategories,
},
}
}

View File

@@ -0,0 +1,51 @@
import { GetServerSideProps } from 'next'
import {
AutomatedPageContextT,
getAutomatedPageContextFromRequest,
} from 'src/automated-pipelines/components/AutomatedPageContext'
import { MainContextT, getMainContext } from 'components/context/MainContext'
import { EnabledList, EnabledListT } from 'src/github-apps/components/EnabledList'
type Props = {
mainContext: MainContextT
currentVersion: string
appsItems: EnabledListT
automatedPageContext: AutomatedPageContextT
categoriesWithoutSubcategories: string[]
}
export default function GitHubAppEndpoints({
mainContext,
currentVersion,
appsItems,
automatedPageContext,
categoriesWithoutSubcategories,
}: Props) {
return (
<EnabledList
items={appsItems}
currentVersion={currentVersion}
categoriesWithoutSubcategories={categoriesWithoutSubcategories}
mainContext={mainContext}
automatedPageContext={automatedPageContext}
/>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const { getAppsServerSideProps } = await import('src/github-apps/lib/index.js')
const { currentVersion, appsItems, categoriesWithoutSubcategories } =
await getAppsServerSideProps(context, 'server-to-server-rest', { useDisplayTitle: false })
return {
props: {
mainContext: await getMainContext(context.req, context.res),
currentVersion,
appsItems,
automatedPageContext: getAutomatedPageContextFromRequest(context.req),
categoriesWithoutSubcategories,
},
}
}

View File

@@ -0,0 +1,51 @@
import { GetServerSideProps } from 'next'
import {
AutomatedPageContextT,
getAutomatedPageContextFromRequest,
} from 'src/automated-pipelines/components/AutomatedPageContext'
import { MainContextT, getMainContext } from 'components/context/MainContext'
import { EnabledList, EnabledListT } from 'src/github-apps/components/EnabledList'
type Props = {
mainContext: MainContextT
currentVersion: string
appsItems: EnabledListT
automatedPageContext: AutomatedPageContextT
categoriesWithoutSubcategories: string[]
}
export default function UserGitHubAppEndpoints({
mainContext,
currentVersion,
appsItems,
automatedPageContext,
categoriesWithoutSubcategories,
}: Props) {
return (
<EnabledList
items={appsItems}
currentVersion={currentVersion}
categoriesWithoutSubcategories={categoriesWithoutSubcategories}
mainContext={mainContext}
automatedPageContext={automatedPageContext}
/>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const { getAppsServerSideProps } = await import('src/github-apps/lib/index.js')
const { currentVersion, appsItems, categoriesWithoutSubcategories } =
await getAppsServerSideProps(context, 'user-to-server-rest', { useDisplayTitle: false })
return {
props: {
mainContext: await getMainContext(context.req, context.res),
currentVersion,
appsItems,
automatedPageContext: getAutomatedPageContextFromRequest(context.req),
categoriesWithoutSubcategories,
},
}
}

View File

@@ -1,108 +0,0 @@
import { GetServerSideProps } from 'next'
import { Fragment } from 'react'
import { useRouter } from 'next/router'
import { AutomatedPage } from 'src/automated-pipelines/components/AutomatedPage'
import {
AutomatedPageContext,
AutomatedPageContextT,
getAutomatedPageContextFromRequest,
} from 'src/automated-pipelines/components/AutomatedPageContext'
import { MainContextT, MainContext, getMainContext } from 'components/context/MainContext'
import { Link } from 'components/Link'
import { RestRedirect } from 'src/rest/components/RestRedirect'
type OperationT = {
slug: string
subcategory: string
verb: string
requestPath: string
}
type EnabledAppCategoryT = {
[category: string]: OperationT[]
}
type Props = {
mainContext: MainContextT
currentVersion: string
enabledForApps: EnabledAppCategoryT
automatedPageContext: AutomatedPageContextT
categoriesWithoutSubcategories: string[]
}
export default function Category({
mainContext,
currentVersion,
enabledForApps,
automatedPageContext,
categoriesWithoutSubcategories,
}: Props) {
const { locale } = useRouter()
const version = currentVersion === 'free-pro-team@latest' ? '' : `/${currentVersion}`
const pathnamePrefix = `/${locale}${version}/rest/`
const content = Object.entries(enabledForApps)
.filter(([, operations]) => operations.length)
.map(([category, operations]) => (
<Fragment key={category}>
<h3 id={category}>
<Link href={`${pathnamePrefix}${category}`}>{category}</Link>
</h3>
<ul>
{operations.map((operation, index) => (
<li key={`${category}-${operation.slug}-${index}`}>
<Link
href={`${pathnamePrefix}${category}${
categoriesWithoutSubcategories.includes(category)
? ''
: '/' + operation.subcategory
}#${operation.slug}`}
>
<code>
<span className="text-uppercase">{operation.verb}</span> {operation.requestPath}
</code>
</Link>
</li>
))}
</ul>
</Fragment>
))
return (
<MainContext.Provider value={mainContext}>
<AutomatedPageContext.Provider value={automatedPageContext}>
<RestRedirect />
<AutomatedPage>{content}</AutomatedPage>
</AutomatedPageContext.Provider>
</MainContext.Provider>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const { categoriesWithoutSubcategories } = await import('src/rest/lib/index.js')
const { getEnabledForApps } = await import('src/github-apps/lib/index.js')
const req = context.req as any
const res = context.res as any
const currentVersion = context.query.versionId as string
const allVersions = req.context.allVersions
const queryApiVersion = context.query.apiVersion
const apiVersion = allVersions[currentVersion].apiVersions.includes(queryApiVersion)
? queryApiVersion
: allVersions[currentVersion].latestApiVersion
const automatedPageContext = getAutomatedPageContextFromRequest(req)
const enabledForApps = await getEnabledForApps(currentVersion, apiVersion)
return {
props: {
mainContext: await getMainContext(req, res),
currentVersion,
enabledForApps,
automatedPageContext,
categoriesWithoutSubcategories,
},
}
}

View File

@@ -0,0 +1,52 @@
import { GetServerSideProps } from 'next'
import {
AutomatedPageContextT,
getAutomatedPageContextFromRequest,
} from 'src/automated-pipelines/components/AutomatedPageContext'
import { MainContext, MainContextT, getMainContext } from 'components/context/MainContext'
import { PermissionsList, PermissionListT } from 'src/github-apps/components/PermissionsList'
type Props = {
mainContext: MainContextT
currentVersion: string
appsItems: PermissionListT
automatedPageContext: AutomatedPageContextT
categoriesWithoutSubcategories: string[]
}
export default function FineGrainedPatPermissions({
mainContext,
currentVersion,
appsItems,
automatedPageContext,
categoriesWithoutSubcategories,
}: Props) {
return (
<MainContext.Provider value={mainContext}>
<PermissionsList
items={appsItems}
currentVersion={currentVersion}
categoriesWithoutSubcategories={categoriesWithoutSubcategories}
mainContext={mainContext}
automatedPageContext={automatedPageContext}
/>
</MainContext.Provider>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const { getAppsServerSideProps } = await import('src/github-apps/lib/index.js')
const { currentVersion, appsItems, categoriesWithoutSubcategories } =
await getAppsServerSideProps(context, 'fine-grained-pat-permissions', { useDisplayTitle: true })
return {
props: {
mainContext: await getMainContext(context.req, context.res),
currentVersion,
appsItems,
automatedPageContext: getAutomatedPageContextFromRequest(context.req),
categoriesWithoutSubcategories,
},
}
}

View File

@@ -0,0 +1,52 @@
import { GetServerSideProps } from 'next'
import {
AutomatedPageContextT,
getAutomatedPageContextFromRequest,
} from 'src/automated-pipelines/components/AutomatedPageContext'
import { MainContext, MainContextT, getMainContext } from 'components/context/MainContext'
import { PermissionsList, PermissionListT } from 'src/github-apps/components/PermissionsList'
type Props = {
mainContext: MainContextT
currentVersion: string
appsItems: PermissionListT
automatedPageContext: AutomatedPageContextT
categoriesWithoutSubcategories: string[]
}
export default function GitHubAppPermissions({
mainContext,
currentVersion,
appsItems,
automatedPageContext,
categoriesWithoutSubcategories,
}: Props) {
return (
<MainContext.Provider value={mainContext}>
<PermissionsList
items={appsItems}
currentVersion={currentVersion}
categoriesWithoutSubcategories={categoriesWithoutSubcategories}
mainContext={mainContext}
automatedPageContext={automatedPageContext}
tokenTypes={true}
/>
</MainContext.Provider>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
const { getAppsServerSideProps } = await import('src/github-apps/lib/index.js')
const { currentVersion, appsItems, categoriesWithoutSubcategories } =
await getAppsServerSideProps(context, 'server-to-server-permissions', { useDisplayTitle: true })
return {
props: {
mainContext: await getMainContext(context.req, context.res),
currentVersion,
appsItems,
automatedPageContext: getAutomatedPageContextFromRequest(context.req),
categoriesWithoutSubcategories,
},
}
}