Skip to content
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

#7412: Verified and added several Cloning overrides in many drivers #7592

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

MatteoPiovanelli-Laser
Copy link
Contributor

@MatteoPiovanelli-Laser MatteoPiovanelli-Laser commented Mar 1, 2017

Fixes #7412

I am not sure all the overrides are correct even here.
I added the Cloning override in some of the drivers that did not have it as well.

@sebastienros
Copy link
Member

Looks good but we need someone to confirm it works.

/cc summoning @BenedekFarkas

@BenedekFarkas
Copy link
Member

I'll be happy to do testing on this and the related PRs, but won't be able to do so in the next few days. I'll add myself as a reviewer just in case, so it shows up for me on GitHub.

…Cleanup

# Conflicts:
#	src/Orchard.Web/Core/Contents/Views/Parts.Contents.Publish.SummaryAdmin.cshtml
#	src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/AudioPartDriver.cs
#	src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/DocumentPartDriver.cs
#	src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/MediaPartDriver.cs
#	src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/OEmbedPartDriver.cs
@BenedekFarkas BenedekFarkas changed the title Verified and added several Cloning overrides in many drivers #7412: Verified and added several Cloning overrides in many drivers Apr 18, 2024
@BenedekFarkas
Copy link
Member

BenedekFarkas commented Nov 18, 2024

@MatteoPiovanelli-Laser please merge from dev, I'm testing/reviewing this now. How does this relate to #7409 BTW?

return RedirectToRoute(adminRouteValues);
if (string.IsNullOrWhiteSpace(returnUrl)) {
var adminRouteValues = _contentManager.GetItemMetadata(cloneContentItem).AdminRouteValues;
return RedirectToRoute(adminRouteValues);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After you merge from dev, please adjust Core/Contents/Views/Parts.Contents.Clone.SummaryAdmin.cshtml and Parts.Contents.Publish.SummaryAdmin.cshtml (line 29) not to include the ReturnUrl parameter.

protected override void Cloning(MenuPart originalPart, MenuPart clonePart, CloneContentContext context) {
clonePart.MenuText = originalPart.MenuText;
clonePart.MenuPosition = originalPart.MenuPosition;
clonePart.Menu = context.CloneContentItem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context.CloneContentItem causes the "Show on a menu" to always be checked incorrectly.

Suggested change
clonePart.Menu = context.CloneContentItem;
clonePart.Menu = originalPart.Menu;

protected override void Cloning(ImageProfilePart originalPart, ImageProfilePart clonePart, CloneContentContext context) {
clonePart.Name = originalPart.Name;
clonePart.ModifiedUtc = originalPart.ModifiedUtc;
clonePart.Record.Filters = originalPart.Filters;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throws YSOD:

Don't change the reference to a collection with cascade="all-delete-orphan"

Filters are records (and thus references), so they should be cloned too.

clonePart.Name = originalPart.Name;
clonePart.ModifiedUtc = originalPart.ModifiedUtc;
clonePart.Record.Filters = originalPart.Filters;
clonePart.Record.FileNames = originalPart.FileNames;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to clone these? Shouldn't this start empty, since the new profile doesn't have any images generated?

}

protected override void Cloned(NavigationQueryPart originalPart, NavigationQueryPart clonePart, CloneContentContext context) {
clonePart.QueryPartRecord = originalPart.QueryPartRecord;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is this in Cloned and not Cloning?

Comment on lines +285 to +287
clonePart.Record.SortCriteria = originalPart.SortCriteria;
clonePart.Record.FilterGroups = originalPart.FilterGroups;
clonePart.Record.Layouts = originalPart.Layouts;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also throws YSOD.

foreach (var addingRole in origRoleRecords.Where(x => !cloneRoleRecords.Contains(x))) {
_userRolesRepository.Create(new UserRolesPartRecord { UserId = clonePart.ContentItem.Id, Role = addingRole });
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we even allow cloning Users? Do you know of a good use-case here?


protected override void Cloning(SearchSettingsPart originalPart, SearchSettingsPart clonePart, CloneContentContext context) {
clonePart.SearchFields = originalPart.SearchFields;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are site settings and the Site shouldn't be cloned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify Cloning method implementation for parts/fields
6 participants