Replace Section Sidebar Context menu in Umbraco 17

Hi all,
So I see there is a breaking change where the SectionSidebarContextMenu has been removed - SectionSidebarContextMenu: Delete element and methods for interaction by madsrasmussen · Pull Request #20399 · umbraco/Umbraco-CMS

I use this in a custom package that I have on a site and so obviously I need to fix this before I can upgrade to U17. I’ve searched the docs and poked around the source but I what would have been nice is, since this is a breaking change maybe provide examples on how to fix the breaking change :slight_smile: (I might have missed this somewhere).

I know U17 is only out today but just wondering if anyone has had the same issue and found a way to use the new dropdown menu instead of the old way?

I guess this whole section in the docs needs revisited now :slight_smile: Entity Actions | Umbraco CMS

Unless I’ve created my Sidebar context in a way that is incorrect and just by chance it worked in U16

That documentation is being worked, hope it’s available soon!

1 Like

That’s good to know. Thought I’d maybe his missed something.

I did try and look at the source code to see how it’s been done but that was too much for me to take in :joy:

Hi @OwainWilliams

I assume you used this Context to get the entityType or unique?
You can get these via arguments parsed to your Action API.

We base our actions on this Abstract Class: UmbEntityActionBase. With it, your code could look like this:

export class MyCustomEntityAction extends UmbEntityActionBase<never> {

	override async execute() {
		if (!this.args.unique) throw new Error('Cannot performe custom? action for an item without a unique identifier.');
		console.log("custom action for " + this.args.unique)
	}
}

The new, alternative way to get these values via Context, is via UMB_ENTITY_CONTEXT, which is more generic, also available in other places. — But as you get these values as args, then no reason to consume a context for this.

I hope that will work for you. Sorry for the inconvenience.

1 Like

Thanks @nielslyngsoe - I’ll try this today and if I have any other questions I’ll update here. #h5yr