diff --git a/components/rest/PreviewsRow.tsx b/components/rest/PreviewsRow.tsx index f2369580c6..90b9c9ad72 100644 --- a/components/rest/PreviewsRow.tsx +++ b/components/rest/PreviewsRow.tsx @@ -3,11 +3,10 @@ import { useTranslation } from 'components/hooks/useTranslation' type Props = { slug: string - hasRequiredPreviews: boolean xGitHub: xGitHub } -export function PreviewsRow({ slug, hasRequiredPreviews, xGitHub }: Props) { +export function PreviewsRow({ slug, xGitHub }: Props) { const { t } = useTranslation('products') const hasPreviews = xGitHub.previews && xGitHub.previews.length > 0 @@ -19,21 +18,17 @@ export function PreviewsRow({ slug, hasRequiredPreviews, xGitHub }: Props) { string header - {hasRequiredPreviews ? ( -

{t('rest.reference.preview_notice_to_change')}.

- ) : ( -

- Setting to - application/vnd.github.v3+json is recommended. - {hasPreviews && ( - - {xGitHub.previews.length > 1 - ? ` ${t('rest.reference.see_preview_notices')}` - : ` ${t('rest.reference.see_preview_notice')}`} - - )} -

- )} +

+ Setting to + application/vnd.github.v3+json is recommended. + {hasPreviews && ( + + {xGitHub.previews.length > 1 + ? ` ${t('rest.reference.see_preview_notices')}` + : ` ${t('rest.reference.see_preview_notice')}`} + + )} +

) diff --git a/components/rest/RestOperation.tsx b/components/rest/RestOperation.tsx index f3d95cfc2c..882e6f7f2c 100644 --- a/components/rest/RestOperation.tsx +++ b/components/rest/RestOperation.tsx @@ -6,6 +6,8 @@ import { RestResponse } from './RestResponse' import { Operation } from './types' import { RestNotes } from './RestNotes' import { RestPreviewNotice } from './RestPreviewNotice' +import { useTranslation } from 'components/hooks/useTranslation' +import { RestStatusCodes } from './RestStatusCodes' type Props = { operation: Operation @@ -13,10 +15,11 @@ type Props = { } export function RestOperation({ operation }: Props) { + const { t } = useTranslation('products') const previews = operation['x-github'].previews - const hasRequiredPreviews = previews - ? previews.filter((preview) => preview.required).length > 0 - : false + const nonErrorResponses = operation.responses.filter( + (response) => parseInt(response.httpStatusCode) < 400 + ) return (
@@ -29,7 +32,6 @@ export function RestOperation({ operation }: Props) { {operation.parameters && ( 0 && ( )} - + {(operation.notes.length > 0 || operation['x-github'].enabledForGitHubApps) && ( )} - +
) } diff --git a/components/rest/RestParameterTable.tsx b/components/rest/RestParameterTable.tsx index 2732588beb..2c5ff7e54f 100644 --- a/components/rest/RestParameterTable.tsx +++ b/components/rest/RestParameterTable.tsx @@ -8,19 +8,12 @@ import { BodyParameterRows } from './BodyParametersRows' type Props = { slug: string - hasRequiredPreviews: boolean xGitHub: xGitHub parameters: Array bodyParameters: Array } -export function RestParameterTable({ - slug, - hasRequiredPreviews, - xGitHub, - parameters, - bodyParameters, -}: Props) { +export function RestParameterTable({ slug, xGitHub, parameters, bodyParameters }: Props) { const { t } = useTranslation('products') return ( @@ -38,7 +31,7 @@ export function RestParameterTable({ - + diff --git a/components/rest/RestResponse.tsx b/components/rest/RestResponse.tsx index ea89589579..0d3f7c97ec 100644 --- a/components/rest/RestResponse.tsx +++ b/components/rest/RestResponse.tsx @@ -1,44 +1,20 @@ import { CodeResponse } from './types' import { CodeBlock } from './CodeBlock' -import { useTranslation } from 'components/hooks/useTranslation' -import { RestResponseTable } from './RestResponseTable' type Props = { responses: Array - variant?: 'non-error' | 'error' } export function RestResponse(props: Props) { - const { responses, variant = 'non-error' } = props - const { t } = useTranslation('products') + const { responses } = props if (!responses || responses.length === 0) { return null } - const filteredResponses = responses.filter((response) => { - const responseCode = parseInt(response.httpStatusCode) - - if (variant === 'error') { - return responseCode >= 400 - } else { - return responseCode < 400 - } - }) - - if (filteredResponses.length === 0) { - return null - } - - if (variant === 'error') { - return ( - - ) - } - return ( <> - {filteredResponses.map((response, index) => { + {responses.map((response, index) => { return (

diff --git a/components/rest/RestResponseTable.module.scss b/components/rest/RestResponseTable.module.scss index cf933c580c..eb86817a7b 100644 --- a/components/rest/RestResponseTable.module.scss +++ b/components/rest/RestResponseTable.module.scss @@ -8,6 +8,7 @@ th { border: 0; font-weight: normal; + background-color: transparent; } th:first-child { diff --git a/components/rest/RestResponseTable.tsx b/components/rest/RestStatusCodes.tsx similarity index 51% rename from components/rest/RestResponseTable.tsx rename to components/rest/RestStatusCodes.tsx index f6a2f4e500..aa04886e03 100644 --- a/components/rest/RestResponseTable.tsx +++ b/components/rest/RestStatusCodes.tsx @@ -8,7 +8,7 @@ type Props = { responses: Array } -export function RestResponseTable({ heading, responses }: Props) { +export function RestStatusCodes({ heading, responses }: Props) { const { t } = useTranslation('products') return ( @@ -22,22 +22,21 @@ export function RestResponseTable({ heading, responses }: Props) { - {responses.map((response, index) => { - return ( - - - {response.httpStatusCode} - - - {response.description ? ( -
- ) : ( - response.httpStatusMessage - )} - - - ) - })} + {responses.map((response, index) => ( + + + {response.httpStatusCode} + + + {response.description && + response.description.toLowerCase() !== '

response

' ? ( +
+ ) : ( + response.httpStatusMessage + )} + + + ))} diff --git a/components/rest/types.ts b/components/rest/types.ts index e647246a29..15c500d5a0 100644 --- a/components/rest/types.ts +++ b/components/rest/types.ts @@ -6,7 +6,6 @@ export interface Operation { notes: Array requestPath: string responses: Array - hasRequiredPreviews: boolean parameters: Array bodyParameters: Array 'x-github': xGitHub diff --git a/data/ui.yml b/data/ui.yml index 852e0c769e..3d2bb36ace 100644 --- a/data/ui.yml +++ b/data/ui.yml @@ -113,7 +113,7 @@ products: notes: Notes parameters: Parameters response: Response - error_codes: Error Codes + status_codes: Status codes http_status_code: HTTP Status Code code_sample: Code sample code_samples: Code samples