File tree Expand file tree Collapse file tree 6 files changed +69
-41
lines changed Expand file tree Collapse file tree 6 files changed +69
-41
lines changed Original file line number Diff line number Diff line change @@ -682,6 +682,7 @@ export interface OwnPropsOfMasterListItem {
682682 index : number ;
683683 selected : boolean ;
684684 path : string ;
685+ enabled : boolean ;
685686 schema : JsonSchema ;
686687 handleSelect ( index : number ) : ( ) => void ;
687688 removeItem ( path : string , value : number ) : ( ) => void ;
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export const ListWithDetailMasterItem = ({
3939 index,
4040 childLabel,
4141 selected,
42+ enabled,
4243 handleSelect,
4344 removeItem,
4445 path,
@@ -50,15 +51,17 @@ export const ListWithDetailMasterItem = ({
5051 < Avatar aria-label = 'Index' > { index + 1 } </ Avatar >
5152 </ ListItemAvatar >
5253 < ListItemText primary = { childLabel } />
53- < ListItemSecondaryAction >
54- < IconButton
55- aria-label = { translations . removeAriaLabel }
56- onClick = { removeItem ( path , index ) }
57- size = 'large'
58- >
59- < DeleteIcon />
60- </ IconButton >
61- </ ListItemSecondaryAction >
54+ { enabled && (
55+ < ListItemSecondaryAction >
56+ < IconButton
57+ aria-label = { translations . removeAriaLabel }
58+ onClick = { removeItem ( path , index ) }
59+ size = 'large'
60+ >
61+ < DeleteIcon />
62+ </ IconButton >
63+ </ ListItemSecondaryAction >
64+ ) }
6265 </ ListItem >
6366 ) ;
6467} ;
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export const MaterialListWithDetailRenderer = ({
5151 schema,
5252 uischema,
5353 path,
54+ enabled,
5455 errors,
5556 visible,
5657 label,
@@ -114,6 +115,7 @@ export const MaterialListWithDetailRenderer = ({
114115 ) }
115116 errors = { errors }
116117 path = { path }
118+ enabled = { enabled }
117119 addItem = { addItem }
118120 createDefault = { handleCreateDefaultValue }
119121 />
@@ -126,6 +128,7 @@ export const MaterialListWithDetailRenderer = ({
126128 index = { index }
127129 path = { path }
128130 schema = { schema }
131+ enabled = { enabled }
129132 handleSelect = { handleListItemClick }
130133 removeItem = { handleRemoveItem }
131134 selected = { selectedIndex === index }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export interface ArrayLayoutToolbarProps {
77 label : string ;
88 errors : string ;
99 path : string ;
10+ enabled : boolean ;
1011 addItem ( path : string , data : any ) : ( ) => void ;
1112 createDefault ( ) : any ;
1213 translations : ArrayTranslations ;
@@ -16,39 +17,56 @@ export const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({
1617 errors,
1718 addItem,
1819 path,
20+ enabled,
1921 createDefault,
2022 translations,
2123} : ArrayLayoutToolbarProps ) {
2224 return (
2325 < Toolbar disableGutters = { true } >
2426 < Grid container alignItems = 'center' justifyContent = 'space-between' >
2527 < Grid item >
26- < Typography variant = { 'h6' } > { label } </ Typography >
28+ < Grid
29+ container
30+ justifyContent = { 'flex-start' }
31+ alignItems = { 'center' }
32+ spacing = { 2 }
33+ >
34+ < Grid item >
35+ < Typography variant = { 'h6' } > { label } </ Typography >
36+ </ Grid >
37+ < Grid item >
38+ { errors . length !== 0 && (
39+ < Grid item >
40+ < ValidationIcon
41+ id = 'tooltip-validation'
42+ errorMessages = { errors }
43+ />
44+ </ Grid >
45+ ) }
46+ </ Grid >
47+ </ Grid >
2748 </ Grid >
28- { errors . length !== 0 && (
49+ { enabled && (
2950 < Grid item >
30- < ValidationIcon id = 'tooltip-validation' errorMessages = { errors } />
31- </ Grid >
32- ) }
33- < Grid item >
34- < Grid container >
35- < Grid item >
36- < Tooltip
37- id = 'tooltip-add'
38- title = { translations . addTooltip }
39- placement = 'bottom'
40- >
41- < IconButton
42- aria-label = { translations . addAriaLabel }
43- onClick = { addItem ( path , createDefault ( ) ) }
44- size = 'large'
51+ < Grid container >
52+ < Grid item >
53+ < Tooltip
54+ id = 'tooltip-add'
55+ title = { translations . addTooltip }
56+ placement = 'bottom'
4557 >
46- < AddIcon />
47- </ IconButton >
48- </ Tooltip >
58+ < IconButton
59+ aria-label = { translations . addTooltip }
60+ onClick = { addItem ( path , createDefault ( ) ) }
61+ size = 'large'
62+ >
63+ < AddIcon />
64+ </ IconButton >
65+ </ Tooltip >
66+ </ Grid >
4967 </ Grid >
5068 </ Grid >
51- </ Grid >
69+ ) }
5270 </ Grid >
5371 </ Toolbar >
5472 ) ;
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ const ExpandPanelRendererComponent = (props: ExpandPanelProps) => {
164164 justifyContent = 'center'
165165 alignItems = 'center'
166166 >
167- { showSortButtons ? (
167+ { showSortButtons && enabled ? (
168168 < Fragment >
169169 < Grid item >
170170 < IconButton
@@ -192,16 +192,18 @@ const ExpandPanelRendererComponent = (props: ExpandPanelProps) => {
192192 ) : (
193193 ''
194194 ) }
195- < Grid item >
196- < IconButton
197- onClick = { removeItems ( path , [ index ] ) }
198- style = { iconStyle }
199- aria-label = { translations . removeAriaLabel }
200- size = 'large'
201- >
202- < DeleteIcon />
203- </ IconButton >
204- </ Grid >
195+ { enabled && (
196+ < Grid item >
197+ < IconButton
198+ onClick = { removeItems ( path , [ index ] ) }
199+ style = { iconStyle }
200+ aria-label = { translations . removeAriaLabel }
201+ size = 'large'
202+ >
203+ < DeleteIcon />
204+ </ IconButton >
205+ </ Grid >
206+ ) }
205207 </ Grid >
206208 </ Grid >
207209 </ Grid >
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ const MaterialArrayLayoutComponent = (props: ArrayLayoutProps) => {
8080 ) }
8181 errors = { errors }
8282 path = { path }
83+ enabled = { enabled }
8384 addItem = { addItem }
8485 createDefault = { innerCreateDefaultValue }
8586 />
You can’t perform that action at this time.
0 commit comments