-
Notifications
You must be signed in to change notification settings - Fork 2.8k
V14/fix/element switch validation #16421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix smalle bug + optimization
I think it will also cause issues if changing a parent document type to element type, which I in the linked issue did for "Component" to make ModelsBuilder generate correct models (implement "Component" itself wasn't created as content, but the child "Emergency" content type (document type) was created as content node, which threw the YSOD, because the it inherited |
Hey Bjarne, thx for looking along. You insights made me think about how strict we should be with this. It looks to me that if we enforce more and more rules on this, we might end up in a situation where restructuring a certain (nested/partial) data model is not possible because of the limitations. And I for sure would be upset if I had to recreate it from scratch. So maybe introducing a setting that allows these changes, but warns you instead would be nice. Not sure yet, but I will bring it up with the team. If you have any other concerns around this feel free to note them here in the mean time. |
# Conflicts: # src/Umbraco.Core/Services/DataTypeService.cs
src/Umbraco.Core/Handlers/WarnDocumentTypeElementSwitchNotificationHandler.cs
Show resolved
Hide resolved
src/Umbraco.Core/Services/ContentTypeEditing/ContentTypeEditingService.cs
Outdated
Show resolved
Hide resolved
Looks like we have a failing unit test ( I would love to see an endpoint that the client could use to preemptively prevent these destructive/offensive actions. We have one for V13, which tests for content type usage and prevents turning an in-use document type into an element. Something similar (with the added rules) would make sense in V14: |
Upon further reflection, all the inheritance related restrictions (warnings) are only relevant with ModelsBuilder enabled. Mixing elements and non-elements works fine if ModelsBuilder does not have to generate models. That got me thinking... Should we disable these validations/warnings if ModelsBuilder is not enabled? Anyone building content types purely for Delivery API couldn't care less about models being generated 🤔 |
Agreed, I will move the logic into a service so it can be called by both the save validation, event handler warnings, and (new) prevalidation endpoints. |
True it "works" and only models builder breaks (right now), but a state where these "rules" are broken smells like bad data architecture. Warning them seems the right thing to do anyway. |
Note that some generates models themselves using custom code or own packages like I wonder if that would cause any issues as well with inheritance @abjerner ? |
I have also though about if element types should live under a separate tree in future #15082 Ideally these can be shared between document, media and member types and act as compositions or blocks shared for the content types. I would also make the element type picker cleaner. But it a bit off-topic. |
Co-authored-by: Kenn Jacobsen <[email protected]>
Moved validation logic regarding doctype IsElement switch into its own service as it will be consumed by more things down the line
# Conflicts: # src/Umbraco.Cms.Api.Management/Controllers/DocumentType/DocumentTypeControllerBase.cs # src/Umbraco.Core/Services/ContentTypeEditing/ContentTypeEditingService.cs # src/Umbraco.Core/Services/OperationStatus/ContentTypeOperationStatus.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests out good 💪
Prerequisites
Related issue: #15604
Description
Based on the linked issue, we need to ensure that we:
Because some changes to the element flag might need to be done on multiple doctypes, we can not block updating a single doctype. Therefore we will issues warnings on these scenario's instead
Current known block structures: block grid, block list, rich text editor
Testing notes
Umb-Notifications
headers.Possible Breaking changes
Content Editing service constructor => Mitigated trough obsoleting old constructor.