|
| 1 | +import { Card, theme, Typography } from 'antd'; |
| 2 | +import { |
| 3 | + ExclamationCircleOutlined, |
| 4 | + CloseCircleOutlined, |
| 5 | +} from '@ant-design/icons'; |
| 6 | + |
| 7 | +const { useToken } = theme; |
| 8 | + |
| 9 | +function AdditionalPropertyCard({ |
| 10 | + additionalProperties, |
| 11 | + style, |
| 12 | +}: { |
| 13 | + additionalProperties: string[] | null; |
| 14 | + style: 'warning' | 'error'; |
| 15 | +}) { |
| 16 | + const { token } = useToken(); |
| 17 | + |
| 18 | + if (!additionalProperties) return null; |
| 19 | + |
| 20 | + const styleConfig = { |
| 21 | + warning: { |
| 22 | + title: 'Extra Properties set via JSON Editor', |
| 23 | + icon: <ExclamationCircleOutlined />, |
| 24 | + textColor: token.colorWarningText, |
| 25 | + }, |
| 26 | + error: { |
| 27 | + title: 'Schema Validation Errors', |
| 28 | + icon: <CloseCircleOutlined />, |
| 29 | + textColor: token.colorErrorText, |
| 30 | + }, |
| 31 | + }; |
| 32 | + |
| 33 | + const { title, icon, textColor } = styleConfig[style]; |
| 34 | + |
| 35 | + return ( |
| 36 | + <Card |
| 37 | + data-testid="extra-properties-card" |
| 38 | + title={ |
| 39 | + <div |
| 40 | + style={{ |
| 41 | + display: 'flex', |
| 42 | + alignItems: 'center', |
| 43 | + gap: '8px', |
| 44 | + color: textColor, |
| 45 | + }} |
| 46 | + > |
| 47 | + {icon} |
| 48 | + <span>{title}</span> |
| 49 | + </div> |
| 50 | + } |
| 51 | + style={{ |
| 52 | + width: '100%', |
| 53 | + marginTop: '10px', |
| 54 | + maxHeight: '300px', |
| 55 | + overflowY: 'auto', |
| 56 | + backgroundColor: '#f5f5f5', |
| 57 | + boxShadow: '0px 3px 15px rgba(0, 0, 0, 0.2)', |
| 58 | + borderRadius: '8px', |
| 59 | + }} |
| 60 | + > |
| 61 | + <ul |
| 62 | + style={{ |
| 63 | + display: 'grid', |
| 64 | + gridTemplateRows: 'repeat(3, auto)', |
| 65 | + gridAutoFlow: 'column', |
| 66 | + gap: '10px', |
| 67 | + padding: 0, |
| 68 | + listStyleType: 'none', |
| 69 | + }} |
| 70 | + > |
| 71 | + {additionalProperties.map((prop) => ( |
| 72 | + <li key={prop} style={{ paddingLeft: '10px' }}> |
| 73 | + <Typography.Text style={{ color: textColor, fontSize: '16px' }}> |
| 74 | + {prop} |
| 75 | + </Typography.Text> |
| 76 | + </li> |
| 77 | + ))} |
| 78 | + </ul> |
| 79 | + </Card> |
| 80 | + ); |
| 81 | +} |
| 82 | + |
| 83 | +export default AdditionalPropertyCard; |
0 commit comments