-
Notifications
You must be signed in to change notification settings - Fork 60k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15968 from github/repo-sync
repo sync
- Loading branch information
Showing
9 changed files
with
207 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Fragment } from 'react' | ||
import type { BodyParameter } from './types' | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
import { ChildBodyParametersRows } from './ChildBodyParametersRows' | ||
|
||
type Props = { | ||
slug: string | ||
bodyParameters: BodyParameter[] | ||
} | ||
|
||
export function BodyParameterRows({ slug, bodyParameters }: Props) { | ||
const { t } = useTranslation('products') | ||
|
||
return ( | ||
<> | ||
{bodyParameters.map((bodyParam) => { | ||
return ( | ||
<Fragment key={bodyParam.name + bodyParam.description}> | ||
<tr> | ||
<td> | ||
<code>{bodyParam.name}</code> | ||
</td> | ||
<td>{bodyParam.type}</td> | ||
<td>{bodyParam.in}</td> | ||
<td> | ||
<div dangerouslySetInnerHTML={{ __html: bodyParam.description }} /> | ||
{bodyParam.default && ( | ||
<p> | ||
{t('rest.reference.default')}: <code>{bodyParam.default}</code> | ||
</p> | ||
)} | ||
</td> | ||
</tr> | ||
{bodyParam.childParamsGroups && bodyParam.childParamsGroups.length > 0 && ( | ||
<ChildBodyParametersRows | ||
slug={slug} | ||
childParamsGroups={bodyParam.childParamsGroups} | ||
/> | ||
)} | ||
</Fragment> | ||
) | ||
})} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
import type { ChildParamsGroup } from './types' | ||
|
||
type Props = { | ||
slug: string | ||
childParamsGroups: ChildParamsGroup[] | ||
} | ||
|
||
export function ChildBodyParametersRows({ slug, childParamsGroups }: Props) { | ||
const { t } = useTranslation('products') | ||
|
||
return ( | ||
<tr className="border-none"> | ||
<td colSpan={4} className="has-nested-table"> | ||
{childParamsGroups?.map((childParamGroup) => { | ||
return ( | ||
<details key={childParamGroup.id}> | ||
<summary | ||
role="button" | ||
aria-expanded="false" | ||
className="keyboard-focus color-fg-muted" | ||
> | ||
<span className="d-inline-block mb-3" id={`${slug}-${childParamGroup.id}`}> | ||
Properties of the | ||
<code>{childParamGroup.parentName}</code> | ||
{childParamGroup.parentType} | ||
</span> | ||
</summary> | ||
<table | ||
id={`${childParamGroup.parentName}-object`} | ||
className="ml-4 mb-4 mt-2 color-bg-subtle" | ||
> | ||
<thead> | ||
<tr> | ||
<th> | ||
{t('rest.reference.name')} ({t('rest.reference.type')}) | ||
</th> | ||
<th>{t('rest.reference.description')}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{childParamGroup.params.map((childParam) => { | ||
return ( | ||
<tr key={`${childParam.name}-${childParam.description}`}> | ||
<td className="color-bg-subtle"> | ||
<code>{childParam.name}</code> ({childParam.type}) | ||
</td> | ||
<td className="color-bg-subtle"> | ||
<div dangerouslySetInnerHTML={{ __html: childParam.description }} /> | ||
</td> | ||
</tr> | ||
) | ||
})} | ||
</tbody> | ||
</table> | ||
</details> | ||
) | ||
})} | ||
</td> | ||
</tr> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Parameter } from './types' | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
|
||
type Props = { | ||
parameters: Parameter[] | ||
} | ||
|
||
export function ParameterRows({ parameters }: Props) { | ||
const { t } = useTranslation('products') | ||
|
||
return ( | ||
<> | ||
{parameters.map((param) => ( | ||
<tr key={`${param.name}-${param.descriptionHTML}`}> | ||
<td> | ||
<code>{param.name}</code> | ||
</td> | ||
<td>{param.schema.type}</td> | ||
<td>{param.in}</td> | ||
<td> | ||
{param.descriptionHTML && ( | ||
<div dangerouslySetInnerHTML={{ __html: param.descriptionHTML }} /> | ||
)} | ||
{param.schema.default && ( | ||
<p> | ||
{t('rest.reference.default')}: <code>{param.schema.default}</code> | ||
</p> | ||
)} | ||
</td> | ||
</tr> | ||
))} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { xGitHub } from './types' | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
|
||
type Props = { | ||
slug: string | ||
hasRequiredPreviews: boolean | ||
xGitHub: xGitHub | ||
} | ||
|
||
export function PreviewsRow({ slug, hasRequiredPreviews, xGitHub }: Props) { | ||
const { t } = useTranslation('products') | ||
|
||
return ( | ||
<tr> | ||
<td> | ||
<code>accept</code> | ||
</td> | ||
<td>string</td> | ||
<td>header</td> | ||
<td> | ||
{hasRequiredPreviews ? ( | ||
<p>{t('rest.reference.preview_notice_to_change')}.</p> | ||
) : ( | ||
<p className="m-0"> | ||
Setting to | ||
<code>application/vnd.github.v3+json</code> is recommended. | ||
{xGitHub.previews && ( | ||
<a href={`#${slug}-preview-notices`} className="d-inline"> | ||
{xGitHub.previews.length > 1 | ||
? ` ${t('rest.reference.see_preview_notices')}` | ||
: ` ${t('rest.reference.see_preview_notice')}`} | ||
</a> | ||
)} | ||
</p> | ||
)} | ||
</td> | ||
</tr> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.