From 9591c23f1f1eb95c4eb45c96c3d1455d4554f065 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Thu, 24 Dec 2020 14:56:46 +0300 Subject: [PATCH] refactor usages. --- .../Layout/PageHeader.razor.cs | 11 +-- .../PageToolbars/AbpPageToolbarOptions.cs | 30 -------- .../PageToolbars/IPageToolbarManager.cs | 2 +- .../PageToolbars/PageToolbar.cs | 5 +- .../PageToolbarContributionContext.cs | 6 -- .../PageToolbars/PageToolbarManager.cs | 8 +-- .../EntityActions/EntityActionDictionary.cs | 5 +- .../EntityActionsConfiguration.cs | 19 ----- .../TableColumns/TableColumnDictionary.cs | 8 ++- .../TableColumns/TableColumnsConfiguration.cs | 25 ------- .../Components/Extensibility/UIExtensions.cs | 20 ------ .../Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 9 ++- .../Components/AbpExtensibleDataGrid.razor | 71 ++++++++++--------- .../Components/AbpExtensibleDataGrid.razor.cs | 2 +- .../Pages/Identity/RoleManagement.razor | 12 ++-- .../Pages/Identity/RoleManagement.razor.cs | 31 ++++---- .../Pages/Identity/UserManagement.razor | 4 +- .../Pages/Identity/UserManagement.razor.cs | 33 +++++---- 18 files changed, 106 insertions(+), 195 deletions(-) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/AbpPageToolbarOptions.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionsConfiguration.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnsConfiguration.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/UIExtensions.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Layout/PageHeader.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Layout/PageHeader.razor.cs index 60d8d51b42..ebaed62959 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Layout/PageHeader.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Layout/PageHeader.razor.cs @@ -26,23 +26,24 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Layout [Parameter] public List BreadcrumbItems { get; set; } + + [Parameter] + public PageToolbar Toolbar { get; set; } [Parameter] public string PageName { get; set; } - - public PageHeader(IPageToolbarManager pageToolbarManager) + public PageHeader() { BreadcrumbItems = new List(); ToolbarItemRenders = new List(); - PageToolbarManager = pageToolbarManager; } protected override async Task OnInitializedAsync() { - if (!PageName.IsNullOrEmpty()) + if (Toolbar!=null) { - var toolbarItems = await PageToolbarManager.GetItemsAsync(PageName); + var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar); ToolbarItemRenders.Clear(); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/AbpPageToolbarOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/AbpPageToolbarOptions.cs deleted file mode 100644 index 7bfcf5acaf..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/AbpPageToolbarOptions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JetBrains.Annotations; -using System; -using System.Collections.Generic; - -namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars -{ - public class AbpPageToolbarOptions - { - public PageToolbarDictionary Toolbars { get; } - - public AbpPageToolbarOptions() - { - Toolbars = new PageToolbarDictionary(); - } - - public void Configure([NotNull] Action configureAction) - { - Configure(typeof(TPage).FullName, configureAction); - } - - public void Configure([NotNull] string pageName, [NotNull] Action configureAction) - { - Check.NotNullOrWhiteSpace(pageName, nameof(pageName)); - Check.NotNull(configureAction, nameof(configureAction)); - - var toolbar = Toolbars.GetOrAdd(pageName, () => new PageToolbar(pageName)); - configureAction(toolbar); - } - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/IPageToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/IPageToolbarManager.cs index 9344afe91f..403a059a12 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/IPageToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/IPageToolbarManager.cs @@ -4,6 +4,6 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars { public interface IPageToolbarManager { - Task GetItemsAsync(string pageName); + Task GetItemsAsync(PageToolbar toolbar); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbar.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbar.cs index 8f7e5a393c..f40f0f809f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbar.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbar.cs @@ -4,13 +4,10 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars { public class PageToolbar { - public string PageName { get; } - public PageToolbarContributorList Contributors { get; set; } - public PageToolbar([NotNull] string pageName) + public PageToolbar() { - PageName = Check.NotNullOrEmpty(pageName, nameof(pageName)); Contributors = new PageToolbarContributorList(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarContributionContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarContributionContext.cs index 3cae80199b..0754df73ac 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarContributionContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarContributionContext.cs @@ -5,9 +5,6 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars { public class PageToolbarContributionContext { - [NotNull] - public string PageName { get; } - [NotNull] public IServiceProvider ServiceProvider { get; } @@ -15,12 +12,9 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars public PageToolbarItemList Items { get; } public PageToolbarContributionContext( - [NotNull] string pageName, [NotNull] IServiceProvider serviceProvider) { - PageName = Check.NotNull(pageName, nameof(pageName)); ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider)); - Items = new PageToolbarItemList(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarManager.cs index f8eb784ebf..9aa164d2b9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/PageToolbars/PageToolbarManager.cs @@ -9,20 +9,16 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars { public class PageToolbarManager : IPageToolbarManager, ITransientDependency { - protected AbpPageToolbarOptions Options { get; } protected IHybridServiceScopeFactory ServiceScopeFactory { get; } public PageToolbarManager( - IOptions options, IHybridServiceScopeFactory serviceScopeFactory) { - Options = options.Value; ServiceScopeFactory = serviceScopeFactory; } - public virtual async Task GetItemsAsync(string pageName) + public virtual async Task GetItemsAsync(PageToolbar toolbar) { - var toolbar = Options.Toolbars.GetOrDefault(pageName); if (toolbar == null || !toolbar.Contributors.Any()) { return Array.Empty(); @@ -30,7 +26,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.PageToolbars using (var scope = ServiceScopeFactory.CreateScope()) { - var context = new PageToolbarContributionContext(pageName, scope.ServiceProvider); + var context = new PageToolbarContributionContext(scope.ServiceProvider); foreach (var contributor in toolbar.Contributors) { diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionDictionary.cs index 3f0aa796c5..4b1009da67 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionDictionary.cs @@ -4,6 +4,9 @@ namespace Volo.Abp.AspNetCore.Components.Extensibility.EntityActions { public class EntityActionDictionary : Dictionary> { - + public List Get() + { + return this.GetOrAdd(typeof(T).FullName, () => new List()); + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionsConfiguration.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionsConfiguration.cs deleted file mode 100644 index 26cc22275b..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/EntityActions/EntityActionsConfiguration.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; - -namespace Volo.Abp.AspNetCore.Components.Extensibility.EntityActions -{ - public class EntityActionsConfiguration - { - protected EntityActionDictionary EntityActions { get; set; } - - public EntityActionsConfiguration() - { - EntityActions = new EntityActionDictionary(); - } - - public List Get() - { - return EntityActions.GetOrAdd(typeof(T).FullName, () => new List()); - } - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnDictionary.cs index f4e7a9b46a..d414839e8b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnDictionary.cs @@ -1,9 +1,13 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Volo.Abp.AspNetCore.Components.Extensibility.TableColumns { public class TableColumnDictionary : Dictionary> { - + public List Get() + { + return this.GetOrAdd(typeof(T).FullName, () => new List()); + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnsConfiguration.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnsConfiguration.cs deleted file mode 100644 index 2668b5c583..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumnsConfiguration.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Volo.Abp.AspNetCore.Components.Extensibility.TableColumns -{ - public class TableColumnsConfiguration - { - protected TableColumnDictionary TableColumns { get; set; } - - public TableColumnsConfiguration() - { - TableColumns = new TableColumnDictionary(); - } - - public List Get() - { - return Get(typeof(T)); - } - - public List Get(Type type) - { - return TableColumns.GetOrAdd(type.FullName, () => new List()); - } - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/UIExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/UIExtensions.cs deleted file mode 100644 index d2ab1b6688..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/UIExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Volo.Abp.AspNetCore.Components.Extensibility.EntityActions; -using Volo.Abp.AspNetCore.Components.Extensibility.TableColumns; - -namespace Volo.Abp.AspNetCore.Components.Extensibility -{ - public class UIExtensions - { - public static UIExtensions Instance { get; protected set; } = new UIExtensions(); - - public EntityActionsConfiguration EntityActions { get; } - - public TableColumnsConfiguration TableColumns { get; } - - private UIExtensions() - { - EntityActions = new EntityActionsConfiguration(); - TableColumns = new TableColumnsConfiguration(); - } - } -} diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 3d6a1df7f8..89b94ef262 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -14,6 +14,8 @@ using Microsoft.Extensions.Options; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.AspNetCore.Components; +using Volo.Abp.AspNetCore.Components.Extensibility.EntityActions; +using Volo.Abp.AspNetCore.Components.Extensibility.TableColumns; using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.Authorization; using Volo.Abp.BlazoriseUI.Components; @@ -190,6 +192,8 @@ namespace Volo.Abp.BlazoriseUI protected Validations EditValidationsRef; protected List BreadcrumbItems = new List(2); protected DataGridEntityActionsColumn EntityActionsColumn; + protected EntityActionDictionary EntityActions { get; set; } + protected TableColumnDictionary TableColumns { get; set; } protected string CreatePolicyName { get; set; } protected string UpdatePolicyName { get; set; } @@ -203,13 +207,15 @@ namespace Volo.Abp.BlazoriseUI { NewEntity = new TCreateViewModel(); EditingEntity = new TUpdateViewModel(); + TableColumns = new TableColumnDictionary(); + EntityActions = new EntityActionDictionary(); } protected override async Task OnInitializedAsync() { - await SetToolbarItemsAsync(); await SetEntityActionsAsync(); await SetTableColumnsAsync(); + await SetToolbarItemsAsync(); await SetBreadcrumbItemsAsync(); await SetPermissionsAsync(); } @@ -420,6 +426,7 @@ namespace Volo.Abp.BlazoriseUI await AppService.DeleteAsync(entity.Id); await GetEntitiesAsync(); + await InvokeAsync(() => StateHasChanged()); } protected virtual string GetDeleteConfirmationMessage(TListViewModel entity) diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor index 52e1a374b0..2ddfef7741 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor @@ -10,48 +10,51 @@ ShowPager="@ShowPager" PageSize="@PageSize"> - @foreach (var column in UIExtensions.Instance.TableColumns.Get(Page)) + @if (Columns != null) { - if (column.Actions.Any()) + @foreach (var column in Columns) { - - - - @foreach (var action in column.Actions) - { - if (action.ConfirmationMessage != null) - { - - } - else - { - - } - } - - - - } - else - { - @if (column.Render != null) + if (column.Actions.Any()) { - + - @column.Render.Invoke(context) + + @foreach (var action in column.Actions) + { + if (action.ConfirmationMessage != null) + { + + } + else + { + + } + } + - + } else { - + @if (column.Render != null) + { + + + @column.Render.Invoke(context) + + + } + else + { + + } } } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs index 73c952ee33..34d2e365d7 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs @@ -26,7 +26,7 @@ namespace Volo.Abp.BlazoriseUI.Components public int PageSize { get; set; } [Parameter] - public Type Page { get; set; } + public IEnumerable Columns { get; set; } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor index 7e2188c39e..ff1ba5c67b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor @@ -15,18 +15,18 @@ @* ************************* PAGE HEADER ************************* *@ + Toolbar="@Toolbar"> @* ************************* DATA GRID ************************* *@ + PageSize="@PageSize" + Columns="@RoleManagementTableColumns"> diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs index b84a8fa884..967e8c0799 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs @@ -26,8 +26,9 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected bool HasManagePermissionsPermission { get; set; } - [Inject] - protected IOptions ToolbarOptions { get; set; } + protected PageToolbar Toolbar { get; set; } + + private List RoleManagementTableColumns => TableColumns.Get(); public RoleManagement() { @@ -38,23 +39,26 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity UpdatePolicyName = IdentityPermissions.Roles.Update; DeletePolicyName = IdentityPermissions.Roles.Delete; ManagePermissionsPolicyName = IdentityPermissions.Roles.ManagePermissions; + Toolbar = new PageToolbar(); } protected override ValueTask SetEntityActionsAsync() { - UIExtensions.Instance - .EntityActions + EntityActions .Get() - .AddIfNotContains(new EntityAction[] + .AddRange(new EntityAction[] { new EntityAction { Text = L["Edit"], RequiredPolicy = UpdatePolicyName, - Clicked = async (data) => await OpenEditModalAsync(data.As()) + Clicked = async (data) => + { + await OpenEditModalAsync(data.As()); + } }, new EntityAction - { + { Text = L["Permissions"], RequiredPolicy = ManagePermissionsPolicyName, Clicked = async (data) => @@ -77,15 +81,14 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected override ValueTask SetTableColumnsAsync() { - UIExtensions.Instance - .TableColumns + TableColumns .Get() - .AddIfNotContains(new TableColumn[] + .AddRange(new TableColumn[] { new TableColumn { Title = L["Actions"], - Actions = UIExtensions.Instance.EntityActions.Get() + Actions = EntityActions.Get() }, new TableColumn { @@ -151,10 +154,8 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected override ValueTask SetToolbarItemsAsync() { - ToolbarOptions.Value.Configure(toolbar => - { - toolbar.AddButton(L["NewRole"], OpenCreateModalAsync, IconName.Add, requiredPolicyName: CreatePolicyName); - }); + Toolbar.AddButton(L["NewRole"], OpenCreateModalAsync, IconName.Add, + requiredPolicyName: CreatePolicyName); return base.SetToolbarItemsAsync(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index d96846a137..8ea0fe9ca4 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -12,7 +12,7 @@ @* ************************* PAGE HEADER ************************* *@ + Toolbar="@Toolbar"> @@ -23,7 +23,7 @@ TotalItems="TotalCount" ShowPager="true" PageSize="PageSize" - Page="typeof(UserManagement)"> + Columns="@UserManagementTableColumns"> diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs index 003830c03b..d9ed40ef56 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs @@ -30,15 +30,16 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected AssignedRoleViewModel[] EditUserRoles; protected string ManagePermissionsPolicyName; - + protected bool HasManagePermissionsPermission { get; set; } protected string CreateModalSelectedTab = DefaultSelectedTab; protected string EditModalSelectedTab = DefaultSelectedTab; - [Inject] - protected IOptions ToolbarOptions { get; set; } + protected PageToolbar Toolbar { get; set; } + + private List UserManagementTableColumns => TableColumns.Get(); public UserManagement() { @@ -49,6 +50,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity UpdatePolicyName = IdentityPermissions.Users.Update; DeletePolicyName = IdentityPermissions.Users.Delete; ManagePermissionsPolicyName = IdentityPermissions.Users.ManagePermissions; + Toolbar = new PageToolbar(); } protected override async Task OnInitializedAsync() @@ -62,7 +64,8 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity { await base.SetPermissionsAsync(); - HasManagePermissionsPermission = await AuthorizationService.IsGrantedAsync(IdentityPermissions.Users.ManagePermissions); + HasManagePermissionsPermission = + await AuthorizationService.IsGrantedAsync(IdentityPermissions.Users.ManagePermissions); } protected override Task OpenCreateModalAsync() @@ -116,10 +119,9 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected override ValueTask SetEntityActionsAsync() { - UIExtensions.Instance - .EntityActions + EntityActions .Get() - .AddIfNotContains(new EntityAction[] + .AddRange(new EntityAction[] { new EntityAction { @@ -151,15 +153,14 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected override ValueTask SetTableColumnsAsync() { - UIExtensions.Instance - .TableColumns + TableColumns .Get() - .AddIfNotContains(new TableColumn[] + .AddRange(new TableColumn[] { new TableColumn { Title = L["Actions"], - Actions = UIExtensions.Instance.EntityActions.Get() + Actions = EntityActions.Get() }, new TableColumn { @@ -189,11 +190,9 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity protected override ValueTask SetToolbarItemsAsync() { - ToolbarOptions.Value.Configure(toolbar => - { - toolbar.AddButton(L["NewUser"], OpenCreateModalAsync, IconName.Add, requiredPolicyName: CreatePolicyName); - }); - + Toolbar.AddButton(L["NewUser"], OpenCreateModalAsync, IconName.Add, + requiredPolicyName: CreatePolicyName); + return base.SetToolbarItemsAsync(); } } @@ -204,4 +203,4 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity public bool IsAssigned { get; set; } } -} +} \ No newline at end of file