({
rowParams,
slug,
numPreviews = 0,
isChild = false,
rowIndex = 0,
bodyParamExpandCallback = undefined,
clickedBodyParameterName = undefined,
}: Props)
| 36 | ] |
| 37 | |
| 38 | export function ParameterRow({ |
| 39 | rowParams, |
| 40 | slug, |
| 41 | numPreviews = 0, |
| 42 | isChild = false, |
| 43 | rowIndex = 0, |
| 44 | bodyParamExpandCallback = undefined, |
| 45 | clickedBodyParameterName = undefined, |
| 46 | }: Props) { |
| 47 | const { t } = useTranslation(['parameter_table', 'products']) |
| 48 | |
| 49 | // This will be true if `rowParams` does not have a key called `default` |
| 50 | // and it will be true if it does and its actual value is `undefined`. |
| 51 | const hasDefault = rowParams.default !== undefined |
| 52 | return ( |
| 53 | <> |
| 54 | <tr className={`${isChild ? 'color-bg-subtle' : ''}`}> |
| 55 | <td className={`${isChild ? 'px-3' : ''}`}> |
| 56 | <div |
| 57 | className={cx( |
| 58 | 'pl-0 pt-1 pr-1 pb-1', |
| 59 | `${rowIndex > 0 && isChild ? 'pt-3 border-top color-border-muted' : ''}` |
| 60 | )} |
| 61 | > |
| 62 | <div> |
| 63 | {rowParams.name ? ( |
| 64 | <> |
| 65 | <code className={`text-bold f5`}>{rowParams.name}</code> |
| 66 | <span className="color-fg-muted pl-2 f5">{rowParams.type}</span> |
| 67 | {rowParams.isRequired ? ( |
| 68 | <span className="color-fg-attention f5 pl-3">{t('required')}</span> |
| 69 | ) : null} |
| 70 | </> |
| 71 | ) : ( |
| 72 | <> |
| 73 | <span className="color-fg-muted pl-1 f5">{rowParams.type}</span> |
| 74 | {rowParams.isRequired ? ( |
| 75 | <span className="color-fg-attention f5 pl-3">{t('required')}</span> |
| 76 | ) : null} |
| 77 | </> |
| 78 | )} |
| 79 | </div> |
| 80 | |
| 81 | <div className={cx('pl-1 f5', `${rowParams.description ? 'pt-2' : 'pt-0'}`)}> |
| 82 | <div dangerouslySetInnerHTML={{ __html: rowParams.description }} /> |
| 83 | {numPreviews > 0 && ( |
| 84 | <a href={`#${slug}-preview-notices`} className="d-inline"> |
| 85 | {numPreviews > 1 ? ` ${t('see_preview_notices')}` : ` ${t('see_preview_notice')}`} |
| 86 | </a> |
| 87 | )} |
| 88 | <div className={cx(`${hasDefault || rowParams.enum ? 'pt-2' : 'pt-0'}`)}> |
| 89 | {hasDefault && ( |
| 90 | <p> |
| 91 | <span>{t('default')}: </span> |
| 92 | <code> |
| 93 | {typeof rowParams.default === 'string' |
| 94 | ? // In the schema, the default value for strings can |
| 95 | // potentially be the empty string so we handle this case |
nothing calls this directly
no test coverage detected