As the Fee Config document is used in the Fee Restaurant Config document the user can change the toggle even if the document is already published. As we don’t find a way to control this we need to ensure that the user will not be able to change the value of the toggle after the first publish. Sanity doc: https://dev-plk-es-whitelabel-cms.rbi.tools/desk/marketingContent;features;featureFee;feesConfig Image ModifiedTo achieve that, we can: Create a custom publish action (https://www.sanity.io/docs/document-actions) This action will be responsible for setting true on the new custom field isPublished (see below for more details) - https://www.sanity.io/docs/document-actions#362c883e4421 and https://www.sanity.io/docs/http-patches#6TPENSW3
Condition this new action to be only available for the Fee Config document (without affecting the other documents) Create a new custom field in the Fee Config option to know if the document is already published or not (the name can be isPublished , for example) Add the hidden to this new field, as the user doesn’t need to see it. This field will only be used to control if the toggle is read-only or not (aka disabled)
Add the readOnly property to the Default Config toggle using the new isPublished prop
DemonstrationDefault Config toggle read only after first publish.webm |