diff --git a/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx b/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx index db29e5acbe..5db522b9a8 100644 --- a/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx +++ b/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx @@ -19,6 +19,7 @@ import { Box, Chip, Divider, + makeStyles, Paper, Table, TableBody, @@ -46,8 +47,8 @@ export function MetadataViewRow({ label, text, data }: MetadataViewRowProps) { } return ( - - + + {label} @@ -167,6 +168,68 @@ export function VisibilityView({ schema }: { schema: Schema }) { return null; } +const usePropertyTitleStyles = makeStyles(theme => ({ + title: { + marginBottom: 0, + }, + chip: { + marginLeft: theme.spacing(1), + marginRight: 0, + marginBottom: 0, + }, +})); + +export function PropertyTitle({ + path, + depth, + schema, + required, +}: { + path: string; + depth: number; + schema?: Schema; + required?: boolean; +}) { + const classes = usePropertyTitleStyles(); + const chips = new Array(); + const chipProps = { size: 'small' as const, classes: { root: classes.chip } }; + + if (required) { + chips.push( + , + ); + } + + const visibility = (schema as { visibility?: string })?.visibility; + if (visibility === 'frontend') { + chips.push( + , + ); + } else if (visibility === 'secret') { + chips.push( + , + ); + } + + return ( + + + {path} + + {chips.length > 0 && } + {chips} + + ); +} + export function ArrayView({ path, depth, schema }: SchemaViewProps) { const itemDepth = depth + 1; const itemPath = path ? `${path}[]` : '[]'; @@ -186,11 +249,11 @@ export function ArrayView({ path, depth, schema }: SchemaViewProps) { - - - {itemPath} - - + {itemSchema && ( - - - {propPath} - - {isRequired(name, schema.required) && ( - - - required - - - )} - - +