Fix external redirect link not shown to author #2882
Merged
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.
Fixes an issue where a page configured as a redirect and having a target of anything other than a Page (e.g. Asset, or external URL) does not display the link target to the author viewing the page in edit mode.
This issue occurred because:
v1/RedirectItemImpl
resolved thePage
for the redirect target before handing that page to theLinkManager
.LinkManager#get(Page)
requiresPage
to be not null; however it would be passed a null unless the redirect target could be resolved to aPage
.LinkManager#get(null)
is called (because the redirect target does not point to aPage
), aLink
is returned where the URL for the link is null.Additionally, even if a valid
Link
were returned, it would not be presented to the author because of a typo inpage/v3/redirect.html
:The problem here is that
redirectTarget.linkURL
does not exist because there is no methodNavigationItem#getLinkURL()
.This is probably a simple typo that should have been
redirectTarget.link.URL
Solution
The solution included in this PR resolves the issue by:
redirect.html
.v1/RedirectItemImpl
to callLinkManager#get(Resource)
with aResource
that has the redirect target path as a property, instead of forcing it to be a page and callingLinkManager#get(Page)
.This solution allows the link to be anything: Page, Asset, external, etc.
The path/URL will be shown to the author in all cases except where the redirect target is a page, in which case the page title will continue to be shown.