umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.42k stars 2.67k forks source link

Hide link box via notification no longer work #14737

Closed bjarnef closed 1 year ago

bjarnef commented 1 year ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.1.1

Bug summary

In Umbraco 12.0.0 we had the following the hide link box on specific node types: https://docs.umbraco.com/umbraco-cms/reference/notifications/editormodel-notifications/customizing-the-links-box

However after upgrading to 12.1.0 or 12.1.1 it seems this no longer works.

image

Specifics

No response

Steps to reproduce

Implement the example from the documentation https://docs.umbraco.com/umbraco-cms/reference/notifications/editormodel-notifications/customizing-the-links-box or something similar to the code below using ModelsBuilder.

public class EditorSendingContentNotificationHandler : INotificationHandler<SendingContentNotification>
{
    private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;

    public EditorSendingContentNotificationHandler(
        IPublishedSnapshotAccessor publishedSnapshotAccessor)
    {
        _publishedSnapshotAccessor = publishedSnapshotAccessor;
    }

    public void Handle(SendingContentNotification notification)
    {
        if (notification.Content.ContentTypeAlias.Equals(EmployeeArchive.ModelTypeAlias) ||
            notification.Content.ContentTypeAlias.Equals(Employee.ModelTypeAlias) ||
            notification.Content.ContentTypeAlias.Equals(LocationArchive.ModelTypeAlias) ||
            notification.Content.ContentTypeAlias.Equals(Location.ModelTypeAlias) ||
            notification.Content.ContentTypeAlias.Equals(TopicsArchive.ModelTypeAlias) ||
            notification.Content.ContentTypeAlias.Equals(Topic.ModelTypeAlias))
        {
            notification.Content.Urls = null;
        }
    }
}
public class SiteComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.AddNotificationHandler<SendingContentNotification, EditorSendingContentNotificationHandler>();
    }
}

Expected result / actual result

No response

github-actions[bot] commented 1 year ago

Hi there @bjarnef!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

andr317c commented 1 year ago

Hey!

Thanks for posting the issue with clear reproduction steps💪! I was able to reproduce it on 12.1.1 and 12.0.0.

I did not get the Link Box for the first ContentNode I created, but when I created a second or third node(while still having the first node). The Link Box appeared again, but only for the second and third.

See GIF: HideLinkBox

From what I can see. the LinkBox gets the redirectUrls from this API call redirecturlmanagement/RedirectUrlsForContentItem.

Response from the first ContentNode: {"searchResults":[],"totalCount":0,"pageCount":1,"currentPage":1} . Response from the second ContentNode: {"searchResults":[{"redirectId":"b0e2410d-34e5-434e-9a6f-814836ef2231","originalUrl":"/newcontents/","destinationUrl":"/newcontentss/","createDateUtc":"2023-08-29T08:10:36.3288761","contentId":1060,"culture":""},{"redirectId":"fcd56d82-5043-4275-afca-60ef35c27ce6","originalUrl":"/newcontent/","destinationUrl":"/newcontentss/","createDateUtc":"2023-08-29T08:10:33.6393988","contentId":1060,"culture":""}],"totalCount":2,"pageCount":1,"currentPage":1}

I will mark this issue as an up for grabs!

github-actions[bot] commented 1 year ago

Hi @bjarnef,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post.

Thanks muchly, from your friendly Umbraco GitHub bot :-)

bjarnef commented 1 year ago

@andr317c I think we started the project on Umbraco 11, so it may be before upgrade to Umbraco 12, but I am pretty sure it worked at that time :)

Not sure it the new Content Delivery API in Umbraco 12 in any way has impact on this.

bjarnef commented 1 year ago

Filtering of urls does work though, e.g.

notification.Content.Urls = notification.Content.Urls?.Where(x => x.IsUrl).ToArray();

Since this is a multi-site solutions and 8 languages configured, it was showing a lot of empty links.

image

with this change:

image

bjarnef commented 1 year ago

Actually I think this works as expected.. I was just looking at the wrong page type.