@@ -34,12 +34,12 @@ import { getDOMEditStack } from "../utils/getCsDataOfElement";
3434import { VariantIcon } from "./icons/variant" ;
3535import {
3636 BASE_VARIANT_STATUS ,
37- FieldRevertComponent ,
3837 getFieldVariantStatus ,
3938 IVariantStatus ,
4039 VariantRevertDropdown ,
4140} from "./FieldRevert/FieldRevertComponent" ;
4241import { LoadingIcon } from "./icons/loading" ;
42+ import { EntryPermissions } from "../utils/getEntryPermissions" ;
4343
4444export type FieldDetails = Pick <
4545 VisualBuilderCslpEventDetails ,
@@ -52,6 +52,7 @@ interface MultipleFieldToolbarProps {
5252 eventDetails : VisualBuilderCslpEventDetails ;
5353 hideOverlay : ( ) => void ;
5454 isVariant ?: boolean ;
55+ entryPermissions ?: EntryPermissions ;
5556}
5657
5758function handleReplaceAsset ( fieldMetadata : CslpData ) {
@@ -107,7 +108,11 @@ function handleFormFieldFocus(eventDetails: VisualBuilderCslpEventDetails) {
107108function FieldToolbarComponent (
108109 props : MultipleFieldToolbarProps
109110) : JSX . Element | null {
110- const { eventDetails, isVariant : isVariantOrParentOfVariant } = props ;
111+ const {
112+ eventDetails,
113+ isVariant : isVariantOrParentOfVariant ,
114+ entryPermissions,
115+ } = props ;
111116 const { fieldMetadata, editableElement : targetElement } = eventDetails ;
112117 const [ isFormLoading , setIsFormLoading ] = useState ( false ) ;
113118
@@ -131,16 +136,17 @@ function FieldToolbarComponent(
131136 let fieldType = null ;
132137 let isWholeMultipleField = false ;
133138
139+ let disableFieldActions = false ;
134140 if ( fieldSchema ) {
135- const { isDisabled } = isFieldDisabled ( fieldSchema , {
136- editableElement : targetElement ,
137- fieldMetadata ,
138- } ) ;
139-
140- // field is disabled, no actions needed
141- if ( isDisabled ) {
142- return null ;
143- }
141+ const { isDisabled } = isFieldDisabled (
142+ fieldSchema ,
143+ {
144+ editableElement : targetElement ,
145+ fieldMetadata ,
146+ } ,
147+ entryPermissions
148+ ) ;
149+ disableFieldActions = isDisabled ;
144150
145151 fieldType = getFieldType ( fieldSchema ) ;
146152 isModalEditable = ALLOWED_MODAL_EDITABLE_FIELD . includes ( fieldType ) ;
@@ -165,7 +171,8 @@ function FieldToolbarComponent(
165171 fieldMetadata . instance . fieldPathWithIndex ||
166172 fieldMetadata . multipleFieldMetadata ?. index === - 1 ) ;
167173
168- isReplaceAllowed = ALLOWED_REPLACE_FIELDS . includes ( fieldType ) && ! isWholeMultipleField ;
174+ isReplaceAllowed =
175+ ALLOWED_REPLACE_FIELDS . includes ( fieldType ) && ! isWholeMultipleField ;
169176 // if (
170177 // DEFAULT_MULTIPLE_FIELDS.includes(fieldType) &&
171178 // isWholeMultipleField &&
@@ -201,6 +208,7 @@ function FieldToolbarComponent(
201208 e . stopPropagation ( ) ;
202209 handleEdit ( fieldMetadata ) ;
203210 } }
211+ disabled = { disableFieldActions }
204212 >
205213 < Icon />
206214 </ button >
@@ -232,6 +240,7 @@ function FieldToolbarComponent(
232240 return ;
233241 }
234242 } }
243+ disabled = { disableFieldActions }
235244 >
236245 < ReplaceAssetIcon />
237246 </ button >
@@ -250,8 +259,10 @@ function FieldToolbarComponent(
250259 invertTooltipPosition ,
251260 } ,
252261 {
253- [ visualBuilderStyles ( ) [ "visual-builder__button--comment-loader" ] ] : isFormLoading ,
254- "visual-builder__button--comment-loader" : isFormLoading
262+ [ visualBuilderStyles ( ) [
263+ "visual-builder__button--comment-loader"
264+ ] ] : isFormLoading ,
265+ "visual-builder__button--comment-loader" : isFormLoading ,
255266 }
256267 ) }
257268 data-tooltip = { "Form" }
@@ -409,7 +420,9 @@ function FieldToolbarComponent(
409420 "previous"
410421 ) ;
411422 } }
412- disabled = { disableMoveLeft }
423+ disabled = {
424+ disableFieldActions || disableMoveLeft
425+ }
413426 >
414427 < MoveLeftIcon
415428 className = { classNames ( {
@@ -419,7 +432,10 @@ function FieldToolbarComponent(
419432 "visual-builder__rotate--90"
420433 ] ] : direction === "vertical" ,
421434 } ) }
422- disabled = { disableMoveLeft }
435+ disabled = {
436+ disableFieldActions ||
437+ disableMoveLeft
438+ }
423439 />
424440 </ button >
425441
@@ -441,7 +457,9 @@ function FieldToolbarComponent(
441457 "next"
442458 ) ;
443459 } }
444- disabled = { disableMoveRight }
460+ disabled = {
461+ disableFieldActions || disableMoveRight
462+ }
445463 >
446464 < MoveRightIcon
447465 className = { classNames ( {
@@ -451,7 +469,10 @@ function FieldToolbarComponent(
451469 "visual-builder__rotate--90"
452470 ] ] : direction === "vertical" ,
453471 } ) }
454- disabled = { disableMoveRight }
472+ disabled = {
473+ disableFieldActions ||
474+ disableMoveRight
475+ }
455476 />
456477 </ button >
457478
@@ -470,6 +491,7 @@ function FieldToolbarComponent(
470491 e . stopPropagation ( ) ;
471492 handleDeleteInstance ( fieldMetadata ) ;
472493 } }
494+ disabled = { disableFieldActions }
473495 >
474496 < DeleteIcon />
475497 </ button >
0 commit comments