umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.4k stars 2.66k forks source link

Inherit element type on child content types #15604

Open bjarnef opened 7 months ago

bjarnef commented 7 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.0.3

Bug summary

I noticed in a migrated project from Umbraco v8 -> v10 -> v12 -> v13, which didn't use ModelsBuilder before, it caused some issues.

The "Component" here was a document types and most children element types.

image

ModelsBuilder couldn't generate models for these as the parent "Component" was a document type, switching this to an element type fixed models generation.

However it causes other issues as "Emergency" is used as content node, so accessing this caused the following error, because it no longer implements IPublishedContent because it inherits "Component" whichs is an IPublishedElement:

image

Maye there should be an event, so it parent document type is changed to element type, it updates children/descendant content types to element type as well?

But in this case "Is an Element Type" is locked on "Emergency" content type - probably because it is already used as a node.

Often if would also be nice to move nested content types out of inheritance from UI. https://github.com/umbraco/Umbraco-CMS/discussions/15605

Specifics

No response

Steps to reproduce

Expected result / actual result

No response

github-actions[bot] commented 7 months ago

Hi there @bjarnef!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

bjarnef commented 7 months ago

I think the UI ideally show handle this:

elit0451 commented 7 months ago

Hey @bjarnef 👋

Thanks for reaching out! To make sure I understood you correctly, can you please see if I am not missing any steps in the video below, as I am not getting the error when visiting the content node I created with one of the nested content types. In my case, the node named "Component" is a folder and the Models builder mode is "SourceCodeManual" 🙂

https://github.com/umbraco/Umbraco-CMS/assets/21998037/1476848b-7411-4e12-a483-4f4f38a70410

bjarnef commented 7 months ago

Hi @elit0451

The "Component" is not a folder / entity container - its a content type :)

This is a project migrated from v8 -> v10 -> v12 -> v13 ... but I think it was on v7 or previous v8 before folders were implemented.

The "Component" was a document type, while most children was element types - except "Emergency" which was a document type.

With this ModelsBuilder generation fails, because the child element types inherits from "Component", but it expect parent to inherit IPublishedElement.

Changing the "Component" document type to element type instead fix the models generation.

However if an existing node has been created of type "Emergency" or creating a new one of this type, it will throw an error, because "Emergy" now inherits from IPublishedElement, but it expect to implement IPublishedContent.

I solved this by moving "Emergency" document type to root instead by updating parentId and path in umbracoNode table.

elit0451 commented 7 months ago

I see, here is a video of how I managed to reproduce the error:

https://github.com/umbraco/Umbraco-CMS/assets/21998037/1e978e20-da42-4094-8fcf-faf2e85258d5


I will talk to the team about how we want to approach this and will get back to you on Monday 💪

bjarnef commented 7 months ago

@elit0451 if you now disable element type on "Root" content type (so it's a document type), then accessing the node won't show the error, but generation of ModelsBuilder models fail, because of the other nested content type (element type), which expect the parent content type "Root" to be an element type.

elit0451 commented 7 months ago

Great insights 🙌

elit0451 commented 6 months ago

Hey again @bjarnef, and thanks for being patient with my reply 🙌 (busy days 🙈)

I will hopefully be able to provide some feedback for you tomorrow 🤞

elit0451 commented 6 months ago

So, here it is:

  1. You are completely right - the UI shouldn't allow the creation of an Element Type under a Document Type - I will mark this as up for grabs if you or anyone else wants to give it a go 😊
  2. And there need to be additional checks when you try to change to and from an Element Type - we will take this into a sprint;

Thanks again for pointing this out!

github-actions[bot] commented 6 months ago

Hi @bjarnef,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post.

Thanks muchly, from your friendly Umbraco GitHub bot :-)