Add explicit model types to Content/Part editor views#19305
Open
okalangkenneth wants to merge 5 commits into
Open
Add explicit model types to Content/Part editor views#19305okalangkenneth wants to merge 5 commits into
okalangkenneth wants to merge 5 commits into
Conversation
gvkries
reviewed
Jun 3, 2026
|
|
||
| namespace OrchardCore.ContentManagement.Display.ViewModels; | ||
|
|
||
| public class ContentPartShapeViewModel : ShapeViewModel |
Member
There was a problem hiding this comment.
The ShapeResult is expecting this to be a Shape instance, otherwise the editors are not added to the parentShape here:
I'm not sure if that's a bug in ShapeResult or by design.
Contributor
Author
There was a problem hiding this comment.
It is a real regression. ShapeViewModel doesn't inherit Shape so the is Shape check at ShapeResult.cs:473 would silently discard child shapes when ContentPartShapeViewModel is the terminal parent in zone traversal. I have fixed it by replacing the guard with a null-check....parentShape is typed IShape at that point and IShape contracts AddAsync so no cast is needed.
5dfbd43 to
8421ce7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19273
Introduces a strongly-typed
ContentPartShapeViewModelfor theContentPart_Editeditor shape and adds explicit
@modeldirectives to the remaining Content/Partviews in
OrchardCore.Contents, continuing the pattern established in #18641.Changes
ContentPartShapeViewModel: new class inOrchardCore.ContentManagement.Display/ViewModels/,extending
ShapeViewModelwith typedContentPartandContentTypePartDefinitionpropertiesContentItemDisplayCoordinator:CreateShapeResult()now instantiatesContentPartShapeViewModeldirectly;BuildEditorAsyncandUpdateEditorAsyncassign typed properties instead of
Properties[...]dictionary entries. A fallbackelsebranch preserves the oldProperties[...]assignment for any code path thatproduces a non-
ContentPartShapeViewModelshapeContentPart.Edit.cshtml:@model ContentPartShapeViewModeladded; all memberaccess is now statically typed
ContentItem.cshtml:@model IShapeadded (Itemsis declared onIShape)Stereotype.Edit.cshtml,Stereotype.DetailAdmin.cshtml,Stereotype.Summary.cshtml,Stereotype.SummaryAdmin.cshtml:@model IShapeaddedNotes
ShapeResult.BuildAndAddShapeAsyncalwayssets
Metadata.Typefrom the shape type string, regardless of how the factory createsthe shape
ContentPart.cshtmlvariants (andContent.cshtml) are not includedhere, those shapes are
ZoneHoldinginstances, and the zone surface requires aseparate approach; deferred as a follow-up