diff --git a/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx b/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx index 5db522b9a8..b49651ae7b 100644 --- a/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx +++ b/plugins/config-schema/src/components/SchemaViewer/SchemaViewer.tsx @@ -168,7 +168,7 @@ export function VisibilityView({ schema }: { schema: Schema }) { return null; } -const usePropertyTitleStyles = makeStyles(theme => ({ +const useChildViewStyles = makeStyles(theme => ({ title: { marginBottom: 0, }, @@ -179,18 +179,20 @@ const usePropertyTitleStyles = makeStyles(theme => ({ }, })); -export function PropertyTitle({ +export function ChildView({ path, depth, schema, required, + lastChild, }: { path: string; depth: number; schema?: Schema; required?: boolean; + lastChild?: boolean; }) { - const classes = usePropertyTitleStyles(); + const classes = useChildViewStyles(); const chips = new Array(); const chipProps = { size: 'small' as const, classes: { root: classes.chip } }; @@ -212,20 +214,28 @@ export function PropertyTitle({ } return ( - - - {path} - - {chips.length > 0 && } - {chips} + + + + + + {path} + + {chips.length > 0 && } + {chips} + + {schema && ( + + )} + ); } @@ -246,23 +256,12 @@ export function ArrayView({ path, depth, schema }: SchemaViewProps) { Items - - - - - {itemSchema && ( - - )} - - + ); } @@ -284,42 +283,77 @@ export function ObjectView({ path, depth, schema }: SchemaViewProps) { {properties.length > 0 && ( <> {depth > 0 && Properties} - {properties.map(([name, propSchema], index) => { - const propDepth = depth + 1; - const propPath = path ? `${path}.${name}` : name; - - return ( - - - - - - - - ); - })} + {properties.map(([name, propSchema], index) => ( + + ))} )} ); } +export function MatchView({ + path, + depth, + schema, + label, +}: { + path: string; + depth: number; + schema: Schema[]; + label: string; +}) { + return ( + <> + {label} + {schema.map((optionSchema, index) => ( + + ))} + + ); +} + export function SchemaView(props: SchemaViewProps) { - // TODO(Rugvip): allOf, anyOf, oneOf - switch (props.schema.type) { + const { schema } = props; + if (schema.anyOf) { + return ( + + ); + } + if (schema.oneOf) { + return ( + + ); + } + if (schema.allOf) { + return ( + + ); + } + switch (schema.type) { case 'array': return ; case 'object':