Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesse Andrews 191 posts 716 karma points c-trib
    Feb 07, 2024 @ 22:03
    Jesse Andrews
    0

    Get the error "TargetNodePermissions is undefined" when I view pending translations

    I ran into this error with umbraco 8.19.9 and translation manager 8.7.9. I upgraded translation manager to 8.7.12, but the issue remained.

    Fortunately the issue was an easy fix. All I did was change

    function canPublish(item) {
        return item.TargetNodePermissions === null || item.TargetNodePermissions.indexOf('U') != -1;
    }
    function canSave(item) {
        return item.TargetNodePermissions === null || item.TargetNodePermissions.indexOf('A') != -1;
    }
    

    to

    function canPublish(item) {
        return !item.TargetNodePermissions || item.TargetNodePermissions.indexOf('U') != -1;
    }
    function canSave(item) {
        return !item.TargetNodePermissions || item.TargetNodePermissions.indexOf('A') != -1;
    }
    

    in "/App_Plugins/TranslationManager/items/itemListViewComponent.js."

    The problem is that the "TargetNodePermissions" value doesn't exist in the data returned by the api "/umbraco/backoffice/TranslationManager/TranslationJobApi/GetNodesByJob/{id}" when it's called in my environment, so it's undefined rather than null and so fails the original test.

    Not sure why this error happens now, as it worked fine with earlier translation jobs. Guessing something changed in umbraco that caused the problem, as the site has been through a number of umbraco upgrades. This isn't an urgent issue, since my adjustment fixes the problem as far as I can tell. Mostly sharing it for other's reference.

  • ivan 41 posts 182 karma points
    Apr 14, 2024 @ 00:57
    ivan
    0

    Hi Jesse,

    Did you find any alternative on this fixed?

    Thanks

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Apr 14, 2024 @ 10:02
    Kevin Jump
    0

    Hi,

    The error in the JavaScript is because we are checking for null but getting undefined.

    The only way for undefined to come back here is for the JSON serializer not to return the null objects.

    This is almost certainly occurring because there is a global Json setting somewhere set to. IgnoreNull on serialization.

    We can reproduce this error by setting the ignore null setting on the global configuration.

    GlobalConfiguration.Configuration
        .Formatters.JsonFormatter
        .SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
    

    The presence of this setting causes the null items not to be serialized into JSON across the whole Umbraco instance.

    Ideally when doing this if you want a null setting value it should be set either on the model,

    [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
    public class SimpleModel
    

    or on the property

    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    public string Description { get; set; }
    

    as this then effects the attribute/class and not the whole solution and third party code.

    We can provide a 'fix' for this in translation manager (see below) - but we can't say that setting that value globally isn't going to cause other issues/issues in other plugins, etc.


    v8 Umbraco (and by extension v8 Translation manager) are no longer in a support phase, so we will not be releasing full version releases (e.g 8.7.13) for patches, because we don't want people with stable installs to encounter any new issues/bugs that could be introduced by a new release.

    We have however released an unsupported legacy release on our own nuget feed which does fix this issue.

    (to connect to the nightly you will likelyu want to use a nuget.config file in your solution.

Please Sign in or register to post replies

Write your reply to:

Draft