Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 20, 2021 @ 20:20
    Bo Damgaard Mortensen
    0

    uSync appsettings.json handlers

    Hi all,

    We're running Umbraco 9 with uSync 9 on the following environements:

    • Local development (our dev laptops)
    • QA (Azure site for internal testing)
    • Stage (Azure site for testing pre-prod changes)
    • Production (Azure site, live/production)

    We'd like to set up uSync to the following behavior:

    1. Developer adds a new dictionary item locally and checks in the uSync file to git, to be deployed on QA
    2. When running an import on QA/Stage/Production (manually triggered), the dictionary item is imported.
    3. Developer makes a change to the dictionary item locally and checks in the uSync file
    4. When running an import QA/Stage/Production (manually triggered), the dictionary item change should not be overridden by the import.

    So all in all: we'd like the import to be one way: never overwrite Content and/or Dictionary items.

    On some of our Umbraco 8 solutions, we have added the following config:

    <!-- Never import Content -->
    <Handler Alias="contentHandler" Enabled="false"/>
    
    <Handler Alias="dictionaryHandler" Enabled="true">
        <Add Key="OneWay" Value="true" />
    </Handler>
    

    Having read the uSync 9 documentation about appsettings.json, I'm still not sure how exactly to achieve the above behavior :-) I'm guessing it should be something like this?

    "uSync" : {
        "Settings" :{
          "RootFolder" : "/uSync/v9/",
          "DefaultSet" : "default",
          "ImportAtStartup" : false,
          "ExportAtStartup" : false,
          "ExportOnSave" : true,
          "ReportDebug" : false,
          "AddOnPing" : true,
          "CacheFolderKeys" : true,
          "ShowVersionCheckWarning": false,
          "SignalRoot" : "",
          "EnableHistory" : true
        },
        "Sets" : {
          "default" : {
            "Enabled" : true,
            "DisabledHandlers" : [],
            "HandlerDefaults" : {
              "Enabled": true,
              "Actions": [],
              "UseFlatStructure": true,
              "GuidNames": false,
              "FailOnMissingParent": false,
              "Group": "",
              "Settings": {}
            },
            "Handlers":  {
              "DictionaryHandler": { <--- is this correct?
                "Enabled": true,
                "OneWay": true,
                "Actions": "Import"
              }
            }
          }
        }
    

    Thanks a lot for your help :-)

    All the best,

    Bo

  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Sep 21, 2021 @ 06:37
    Kevin Jump
    0

    Hi,

    Yes, almost.

    As most of the settings are default, you can omit them. then you only need the setting for the dictionaryHandler.

    "uSync": {
      "Sets": {
        "default": {
          "Handlers": {
            "dictionaryHandler": {
              "Settings": {
                "OneWay":  true
              }
            }
          }
        }
      }
    }
    

    Its lowercase "dictionaryHandler" and there is an extra "settings" in there for the OneWay.

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 21, 2021 @ 07:15
    Bo Damgaard Mortensen
    0

    Thanks a lot, Kevin :-) Greatly appreciated!

    So if we want to disable the Content handler entirely, we can do this?

    "uSync": {
      "Sets": {
        "default": {
          "Handlers": {
            "dictionaryHandler": {
              "Settings": {
                "OneWay":  true
              }
            },
          "contentHandler": {
              "Settings": {
                "Enabled": false
              }
            }
          }
        }
      }
    }
    
  • Kevin Jump 2343 posts 14890 karma points MVP 8x c-trib
    Sep 21, 2021 @ 09:53
    Kevin Jump
    100

    In theory , (not 100% sure that works in the latest release candidate)

    but it is easier to add it to DisabledHandlers - in the sets config.

    "Sets": {
      "default": {
        "DisabledHandlers": [ "contentHandler" ],
      }
    }
    

    In a perfect world (and we are working through this setup for final release)

    you would want to move dictionaryHandler to the Settings group, and then disable, content as a group (so content, media, etc.)

    this would do it but it doesn't work just yet - this will be work in rc004

    "uSync": {
      "Settings": {
        "exportOnSave": "Settings",
        "UIEnabledGroups": "Settings"
      },
      "Sets": {
        "default": {
          "Handlers": {
            "dictionaryHandler": {
              "Group": "Settings",
              "Settings": {
                "OneWay": true
              }
            }
          }
        }
      }
     }
    

    what this does is move dictionary to the "Settings" group (so it syncs with doctypes, etc) and sets it so only the Settings group is used for Export on Save (events in umbraco) and shown in the UI (so you can't sync content at all).

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 21, 2021 @ 10:33
    Bo Damgaard Mortensen
    0

    Hi Kevin,

    Ah, of course :-) It makes sense to move them to the DisabledHandlers array. Thanks!

    I'll make sure to keep an eye on the documentation to see if anything has changed for the final release.

    Thanks a lot for your help :-)

Please Sign in or register to post replies

Write your reply to:

Draft