@@ -24,6 +24,7 @@ export interface IGroupProps {
2424 contentOverlay ?: React . ReactNode ;
2525 id : string ;
2626 isRoot : boolean ;
27+ readOnly ?: boolean ;
2728}
2829
2930export const Group : FC < IGroupProps > = ( {
@@ -34,6 +35,7 @@ export const Group: FC<IGroupProps> = ({
3435 contentOverlay,
3536 id,
3637 isRoot,
38+ readOnly : localReadOnly = false ,
3739} ) => {
3840 const {
3941 components,
@@ -46,14 +48,15 @@ export const Group: FC<IGroupProps> = ({
4648 groupTypes,
4749 singleRootGroup,
4850 } = useContext ( BuilderContext ) ;
51+ const isReadOnly = readOnly || localReadOnly ;
4952 const Add = components . Add || Button ;
5053 const GroupContainer = components . Group || DefaultGroupContainer ;
5154 const Option = components . GroupHeaderOption || DefaultOption ;
5255 const Popover = components . Popover || DefaultPopover ;
5356 const PopoverItem = components . PopoverItem || DefaultPopoverItem ;
5457 const Remove = components . Remove || SecondaryButton ;
5558 const resolvedGroupTypes = groupTypes || 'with-modifiers' ;
56- const canDeleteGroup = ! ( singleRootGroup && isRoot ) ;
59+ const canDeleteGroup = ! ( singleRootGroup && isRoot ) && ! isReadOnly ;
5760
5861 const addItem = ( payload : NormalizedNode ) => {
5962 applyDataUpdate (
@@ -170,7 +173,7 @@ export const Group: FC<IGroupProps> = ({
170173 < Option
171174 isSelected = { Boolean ( isNegated ) }
172175 value = { ! isNegated }
173- disabled = { readOnly }
176+ disabled = { isReadOnly }
174177 onClick = { handleToggleNegateGroup }
175178 data-test = "Option[not]"
176179 >
@@ -179,7 +182,7 @@ export const Group: FC<IGroupProps> = ({
179182 < Option
180183 isSelected = { value === 'AND' }
181184 value = "AND"
182- disabled = { readOnly }
185+ disabled = { isReadOnly }
183186 onClick = { handleChangeGroupType }
184187 data-test = "Option[and]"
185188 >
@@ -188,7 +191,7 @@ export const Group: FC<IGroupProps> = ({
188191 < Option
189192 isSelected = { value === 'OR' }
190193 value = "OR"
191- disabled = { readOnly }
194+ disabled = { isReadOnly }
192195 onClick = { handleChangeGroupType }
193196 data-test = "Option[or]"
194197 >
@@ -198,7 +201,7 @@ export const Group: FC<IGroupProps> = ({
198201 ) : null
199202 }
200203 controlsRight = {
201- ! readOnly && (
204+ ! isReadOnly && (
202205 < >
203206 < Add onClick = { handleAddRule } data-test = "AddRule" >
204207 { strings . group . addRule }
0 commit comments