Adding Custom Action / Permission for a UserType in Content Tree
Here is my question:
What is the Umbraco 7 prescribed method to add an Action to the "Default Permissions" list in UserTypes and then have it show up in the context menu for users who have that permission?
This is what I've got so far:
I created this class which gives me the Checkbox in Default Permissions:
public class TestNewPermission : IAction
{
public char Letter
{
get { return '+';}
}
public bool ShowInNotifier
{
get{ return true;}
}
public string Alias
{
get{return "TestNewPermission";}
}
public bool CanBePermissionAssigned
{
get {return true;}
}
public string Icon
{
get { return umbraco.BusinessLogic.Actions.ActionNotify.Instance.Icon; }
}
public string JsFunctionName
{
get { return "LogToConsole();"; }
}
public string JsSource
{
get { return "function LogToConsole(){ Console.Log('Function From IAction was hit'); }"; }
}
}
Then I hooked into the Tree Menu Rendering Event to show this action where users have the permission.
Even when using Method B, the solution still requires the new IAction class so that the to that the '+' permission can be assigned to the UserType. If Action is considered "legacy," why would it still be needed to accomplish this?
No idea if this is the recommended way. From what I remember, the Umbraco core is doing similar; however, the Umbraco core also contains a bunch of legacy stuff (such as ASPX dialogs rather than Angular dialogs).
Adding Custom Action / Permission for a UserType in Content Tree
Here is my question:
This is what I've got so far:
I created this class which gives me the Checkbox in Default Permissions:
Then I hooked into the Tree Menu Rendering Event to show this action where users have the permission.
Example A:
I noted that the overload to use this IAction for MenuItem read:
public MenuItem(IAction legacyMenu, string name = "");
When I select "My Custom Action" from the Context Menu it doesn't run the javascript defined in the IAction class.
I also went a different route and built a MenuItem object and added it via the permission:
Example B:
Even when using Method B, the solution still requires the new IAction class so that the to that the '+' permission can be assigned to the UserType. If Action is considered "legacy," why would it still be needed to accomplish this?
I use the LaunchDialogView() function to open an HTML file in the flyout dialog, as shown here (I forget, but LaunchDialogView may be an extension method): https://github.com/Nicholas-Westby/usergrouppermissions/blob/upgrade-part-2/UserGroupPermissions/Events/AddUserGroupPermissionToContextMenu.cs#L61
You can see my menu action here: https://github.com/Nicholas-Westby/usergrouppermissions/blob/upgrade-part-2/UserGroupPermissions/MenuActions/UserGroupPermissions.cs
I check if the user has the appropriate permission here: https://github.com/Nicholas-Westby/usergrouppermissions/blob/upgrade-part-2/UserGroupPermissions/Events/AddUserGroupPermissionToContextMenu.cs#L46
No idea if this is the recommended way. From what I remember, the Umbraco core is doing similar; however, the Umbraco core also contains a bunch of legacy stuff (such as ASPX dialogs rather than Angular dialogs).
is working on a reply...