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

Redirect to the published URL when exiting preview #18114

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Jan 24, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #7922

Description

Following the discussion on #7922, when exiting document previews we should not blindly redirect to the "by ID" route. Instead we should:

  1. Attempt to redirect to the published URL of the document being previewed, or
  2. Redirect to the "by ID" route if permitted for published documents, or
  3. Redirect to root if the "by ID" route is not permitted.

This PR implements that 👍

Testing this PR - with URL providers

When exiting preview for a given document, verify that:

  1. If the document is already published, the client is redirected to the published URL of the document.
  2. If the document is not published (draft-only), the client is redirected to the site root (in lieu of better options).

Test this both for culture variant and invariant content.

Testing this PR - without URL providers

Remove all URL providers with this code:

using Umbraco.Cms.Core.Composing;

namespace My.Site;

public class MyUrlProviderRemover : IComposer
{
    public void Compose(IUmbracoBuilder builder)
        => builder.UrlProviders().Clear();
}

When exiting preview for a given document, verify that:

  1. With Umbraco:WebRouting:DisableFindContentByIdPath set to false, the client is redirected to the "by ID" route (as-is today).
  2. With Umbraco:WebRouting:DisableFindContentByIdPath set to true, the client is redirected to the site root (in lieu of better options).

image

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

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

Looks logical to me and works as described 💪

@AndyButland AndyButland enabled auto-merge (squash) January 24, 2025 13:49
@AndyButland AndyButland removed their assignment Jan 24, 2025
@AndyButland AndyButland merged commit 7850078 into v13/dev Jan 24, 2025
19 checks passed
@AndyButland AndyButland deleted the v13/feature/exit-preview-to-published-url branch January 24, 2025 18:46
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.

3 participants