File tree Expand file tree Collapse file tree 4 files changed +33
-13
lines changed Expand file tree Collapse file tree 4 files changed +33
-13
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,11 @@ class Editor extends Component {
4949 render ( ) {
5050 const { title} = this . props ;
5151 const icon = this . state . valid ? "ok" : "remove" ;
52+ const cls = this . state . valid ? "valid" : "invalid" ;
5253 return (
5354 < fieldset >
5455 < legend >
55- < span className = { `glyphicon glyphicon-${ icon } ` } />
56+ < span className = { `${ cls } glyphicon glyphicon-${ icon } ` } />
5657 { " " }
5758 { title }
5859 </ legend >
Original file line number Diff line number Diff line change 1919.rjsf input [type = radio ] {
2020 margin-right : .4em ;
2121}
22+
23+ .invalid {
24+ color : red;
25+ }
26+
27+ .valid {
28+ color : green;
29+ }
Original file line number Diff line number Diff line change @@ -40,8 +40,17 @@ class ObjectField extends Component {
4040 const { schema, uiSchema, name} = this . props ;
4141 const title = name || schema . title ;
4242 const SchemaField = this . props . SchemaField ;
43- const orderedProperties = orderProperties (
44- Object . keys ( schema . properties ) , uiSchema . order ) ;
43+ try {
44+ var orderedProperties = orderProperties (
45+ Object . keys ( schema . properties ) , uiSchema . order ) ;
46+ } catch ( err ) {
47+ return (
48+ < p className = "config-error" style = { { color : "red" } } >
49+ Invalid { name || "root" } object field configuration:
50+ < em > { err . message } </ em > .
51+ </ p >
52+ ) ;
53+ }
4554 return (
4655 < fieldset >
4756 { title ? < legend > { title } </ legend > : null }
Original file line number Diff line number Diff line change @@ -81,19 +81,21 @@ describe("Form", () => {
8181 } ) ;
8282
8383 it ( "should throw when order list length mismatches" , ( ) => {
84- expect ( ( ) => {
85- createComponent ( { schema, uiSchema : {
86- order : [ "bar" , "foo" , "baz?" ]
87- } } ) ;
88- } ) . to . Throw ( Error , / s h o u l d m a t c h o b j e c t p r o p e r t i e s l e n g t h / ) ;
84+ const { node} = createComponent ( { schema, uiSchema : {
85+ order : [ "bar" , "foo" , "baz?" ]
86+ } } ) ;
87+
88+ expect ( node . querySelector ( ".config-error" ) . textContent )
89+ . to . match ( / s h o u l d m a t c h o b j e c t p r o p e r t i e s l e n g t h / ) ;
8990 } ) ;
9091
9192 it ( "should throw when order and properties lists differs" , ( ) => {
92- expect ( ( ) => {
93- createComponent ( { schema, uiSchema : {
94- order : [ "bar" , "wut?" ]
95- } } ) ;
96- } ) . to . Throw ( Error , / d o e s n o t m a t c h o b j e c t p r o p e r t i e s l i s t / ) ;
93+ const { node} = createComponent ( { schema, uiSchema : {
94+ order : [ "bar" , "wut?" ]
95+ } } ) ;
96+
97+ expect ( node . querySelector ( ".config-error" ) . textContent )
98+ . to . match ( / d o e s n o t m a t c h o b j e c t p r o p e r t i e s l i s t / ) ;
9799 } ) ;
98100 } ) ;
99101
You can’t perform that action at this time.
0 commit comments