How to refresh the Umbraco V14+ Bellissima content tree with code

Hello all,
It’s been a while since I have shared a quick tip working with Umbraco Bellissima aka the modern WebComponent built Umbraco backoffice that has been available since Umbraco V14+.

I have been working for a client where their requirements was to import and sync nodes from another instance and a nice little UX was when the nodes have finished importing that the tree and its child nodes (if expanded), would automatically refresh and show the new nodes.

What does this do?

Rather than me try to explain this, sometimes with a quick gif/video I can show you what we are trying to achieve.

An animated gif showing a custom modal updating and refreshing the content tree to see new content nodes immediately

Just show me the code snippet

// Imports
import { UMB_ACTION_EVENT_CONTEXT, UmbActionEventContext } from "@umbraco-cms/backoffice/action";
import { UmbRequestReloadChildrenOfEntityEvent } from "@umbraco-cms/backoffice/entity-action";
import { UMB_DOCUMENT_ENTITY_TYPE } from "@umbraco-cms/backoffice/document";

// Properties of class
#eventContext: UmbActionEventContext | undefined;

// Constructor
constructor() {
    // Consume the contexts & assign
    this.consumeContext(UMB_ACTION_EVENT_CONTEXT, (eventContext) => {
        this.#eventContext = eventContext;
    });
}

// Example click method assigned to an uui-button
#clickSyncNodes(ev: Event) {
    // Call some API to do some work and import content nodes
    // ...

    // Use the notification context to show a success message
    // ...

    // Sends out an event to reload the children of the tree
    // If the tree is expanded then you will see the new nodes appear
    this.#eventContext?.dispatchEvent(new UmbRequestReloadChildrenOfEntityEvent(
        {
            // This is the unique GUID/key of the current node in the tree to refresh
            // Use a GUID passed into a modal instead of hardcoded value as in this demo code
            unique: "f57456d6-9f8b-4943-8b85-01a44e023dde",
            
            // Type of entities to reload, could be things like media, members or own custom entity types
            entityType: UMB_DOCUMENT_ENTITY_TYPE
        }
    ));
};

I hope you found the snippet of some use, if you use this in your codebase. Drop me a message in the comments. I would love to hear about your use case and why you needed to use the UmbRequestReloadChildrenOfEntityEvent

Until next time…
Happy Hacking 👋

My first Umbraco Bellissima Package

Just a super quick blog post to share that I have created my first Umbraco V14 Package for the new Umbraco backoffice codenamed ‘Belissma’.

Umbraco V14 has a totally different architecture when it comes to extending the backoffice, as its been architected on using Web Standards by using WebComponents. YAY for using the Web platform and not getting locked into a specific Javascript framework anymore !

So what did I build?

I present to you a simple package that allows you to view a specific content nodes entry in Examine, to see what values and raw data it has stored for an Umbraco node. This is useful if you use Examine a lot along with customising the index or adding extra fields, you are then able to easily peek to see what’s stored.

A screenshot of the Umbraco Package 'Examine Peek'
A screenshot of the Umbraco Package ‘Examine Peek’

So Examine Peek was born an Umbraco V14 Entity Action that open a dialog from the content node Actions menu or the right click menu items from the content tree.

I hope to find some time to create a video rebuilding it from scratch to help teach you some of my findings I learnt along the way. So watch this space 👀

Where can I get it?

You can download and install the package into your Umbraco V14 beta001 site by installing the package from Nuget or if your curious you can take a look through the source code on GitHub.

dotnet add package ExaminePeek --version 1.0.0-beta001