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

Avoid cloning the AutoPart pattern in the localized content #15810

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

hishamco
Copy link
Member

@hishamco hishamco commented Apr 23, 2024

Fixes #15805

Summary by CodeRabbit

  • New Features

    • Enhanced content localization by automatically regenerating permalinks when localizing content.
    • Expanded service configurations to support new localization features across content culture pickers and sitemaps.
  • Refactor

    • Introduced new handlers and services for improved content localization management.
  • Documentation

    • Updated project references to support new localization functionalities.

@hishamco
Copy link
Member Author

There's might be a better solution, but this the quick one that I go with, @MichaelPetrinolis could you please try the PR

Copy link
Contributor

@MichaelPetrinolis MichaelPetrinolis left a comment

Choose a reason for hiding this comment

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

If adding a dependency to Autoroute Core is ok, clearing the autoroutepart path does the job. Either it is draftable or not, the localized version has empty path and the user is able to update eg. the localized title and create a localized route. Thanx!

@hishamco
Copy link
Member Author

I tried to avoid depending on OC.Autoroute module, but still looking for a better solution if there's

/cc @Skrypt

@hishamco
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Apr 24, 2024

Walkthrough

The update involves improving the content localization process in OrchardCore by automatically regenerating permalinks when content is localized. This enhancement ensures that the autoroute path is correctly handled during localization, addressing a specific issue related to culture names in the path pattern.

Changes

File Path Change Summary
.../DefaultContentLocalizationManager.cs Added logic to clear AutoroutePart path for permalink regeneration during content localization.
.../OrchardCore.ContentLocalization.csproj Added a project reference to OrchardCore.Autoroute.Core.csproj to support the new localization functionality.
.../AutoPartContentLocalizationHandler.cs Introduced a new class AutoPartContentLocalizationHandler implementing IContentLocalizationHandler methods.
.../Startup.cs Various changes including namespace additions and method modifications to support content localization features.

Assessment against linked issues

Objective Addressed Explanation
Content Localization Autoroute problem with culture name in path (#15805) The changes address the issue by enhancing the content localization process to handle autoroute paths correctly.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hishamco
Copy link
Member Author

Seems coderabbitai ignores my PR :)

@Piedone
Copy link
Member

Piedone commented Apr 24, 2024

Hmm, it seems it didn't actually do a review. I've asked the CR team about this.

@hishamco
Copy link
Member Author

hishamco commented May 1, 2024

@MichaelPetrinolis the new update might much better

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (1)
src/OrchardCore.Modules/OrchardCore.ContentLocalization/Handlers/AutoPartContentLocalizationHandler.cs (1)

11-19: The logic to clear the AutoroutePart path is correctly implemented to support automatic permalink regeneration.

Consider adding a comment explaining why the path is set to null, for future maintainability.

@hishamco hishamco requested a review from Piedone May 2, 2024 10:49
@hishamco hishamco requested a review from Piedone May 2, 2024 16:49
@hishamco hishamco requested a review from Piedone May 2, 2024 17:42
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't fix the issue:

2024-05-02_20h06_41.mp4

Copy link
Member Author

@hishamco hishamco May 2, 2024

Choose a reason for hiding this comment

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

Please try it without your last suggestion - Using Alter - I'm 100% percentage sure it was working as expected

Copy link
Member Author

Choose a reason for hiding this comment

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

This is weird I don't know why the

context.ContentItem.Alter<AutoroutePart>(p => p.Path = null);

doesn't work as expected here?!! Do you have any idea or shall I revert the last change

Copy link
Member

Choose a reason for hiding this comment

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

That's good, but please make it work in a statically typed way. We don't need dynamic for this.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, sorry, I'd also need to get into debugging this to figure it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

We might need to revise this, using CloningAsync() might resolve the issue but not make sense while LocalizingAsync() should be the suited event for that

Copy link
Member

Choose a reason for hiding this comment

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

if that is the case, then call _session.SaveAsync() after calling LocalizingAsync. But honestly, this sounds like a bad idea to me. IContentHandler should be the right event to hook into at that point. LocalizingAsync should not be used to alter the content item.

Copy link
Member Author

Choose a reason for hiding this comment

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

LocalizingAsync should not be used to alter the content item.

For that I alert the autoroute path without using Alter() just to solve the above issue

Copy link
Member

Choose a reason for hiding this comment

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

Can you create a test case for the Alter method to make sure STJ isn't causing a problem? Alter should work.

Copy link
Member Author

@hishamco hishamco May 3, 2024

Choose a reason for hiding this comment

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

This is #15714 a recent PR that I merged, the Alter was working fine

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

Successfully merging this pull request may close these issues.

Content Localization Autoroute problem with culture name in path
4 participants