Open Closed

Sorting in Permission Management #3088


User avatar
0
deepak created
  • ABP Framework version: 4.3.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

Is that possible to sort the Permission Management module (Left Menu)? Can we set User created module first and than Identity and so on?


1 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @deepak

    We designed permissions to be kept in a Dictionary. Unfortunately dictionaries in C# aren't designed for being able to be sorted. https://stackoverflow.com/a/7521383/7200126

    We can consider adding an order to permissions but currently, there is no order in permission groups.

    I can show you a workaround until we'll add that feature.

    • Go to your YourProjectNamePermissionDefinitionProvider in .Application.Contracts project and make a manual ordering like below.
    public override void Define(IPermissionDefinitionContext context)
    {
        // some other permission additions of your app
        // ...
        
        if (context is PermissionDefinitionContext definitionContext)
        {
            var ordered = definitionContext.Groups.OrderByDescending(...).ToList();
    
            definitionContext.Groups.Clear();
    
            foreach (var item in ordered)
            {
                definitionContext.Groups.Add(item.Key, item.Value);
            }
        }
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11