New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blazor UI extensions #6647
Blazor UI extensions #6647
Conversation
- Read bundling parameters from appsettings.json - Implement exclude from bundle feature.
...ssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ComponentsWebAssemblyBundleContributor.cs
Outdated
Show resolved
Hide resolved
...pNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/UIExtensions.cs
Outdated
Show resolved
Hide resolved
<DataGridColumns> | ||
@foreach (var column in UIExtensions.Instance.TableColumns.Get(Page)) | ||
{ | ||
if (column.Actions.Any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, one datagrid will have a single column with "actions". So, instead of adding Actions
to column, it might be better to add it to a containing object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, probably. There is also UIExtensions.Instance.EntityActions
property. Devs can get entity action collection for a specific page and update actions. Putting an Actions
property inside the table column provides flexibility and devs can change the order of the Actions
column etc.. We provide the same flexibility on the MVC side and, I want to provide that on the Blazor side.
framework/src/Volo.Abp.BlazoriseUI/Components/AbpDataGrid.razor
Outdated
Show resolved
Hide resolved
UIExtensions.Instance | ||
.EntityActions | ||
.Get<RoleManagement>() | ||
.AddIfNotContains(new EntityAction[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AddIfNotContains
prevents duplicate adding. However, wouldn't it better to make this into the module's ConfigureServices
method (with OneTimeRunner
wrapper) to not execute it every time component is rendered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below.
UIExtensions.Instance | ||
.TableColumns | ||
.Get<RoleManagement>() | ||
.AddIfNotContains(new TableColumn[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment like SetEntityActionsAsync
A sample project would be ideal |
I've made some improvements to the design. Instead of storing the actions and columns in a singleton type, I moved the definitions to the [Dependency(ReplaceServices = true)]
[ExposeServices(typeof(RoleManagement))]
public class MyRoleManagement : RoleManagement
{
protected override async ValueTask SetTableColumnsAsync()
{
await base.SetTableColumnsAsync();
TableColumns.Get<RoleManagement>().Add(new Volo.Abp.AspNetCore.Components.Extensibility.TableColumns.TableColumn()
{
Title = "MyCustomColumn",
Data = nameof(IdentityRoleDto.Name)
});
}
protected override async ValueTask SetEntityActionsAsync()
{
await base.SetEntityActionsAsync();
EntityActions.Get<RoleManagement>().Add(new Volo.Abp.AspNetCore.Components.Extensibility.EntityActions.EntityAction
{
Text = "My Custom Action",
Clicked = (data) =>
{
Console.WriteLine("Clicked!");
return Task.CompletedTask;
}
});
}
protected override async ValueTask SetToolbarItemsAsync()
{
await base.SetToolbarItemsAsync();
Toolbar.AddButton("Toolbar item", () =>
{
Console.WriteLine("Toolbar item Clicked");
return Task.CompletedTask;
}, IconName.Baby);
}
} |
…onents.Web project.
…eb.Theming project
The PR is ready for review. |
await base.OnParametersSetAsync(); | ||
if (Toolbar!=null) | ||
{ | ||
Console.WriteLine("Toolbar is not null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove Console.WriteLine
{ | ||
Console.WriteLine("Toolbar is not null"); | ||
var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar); | ||
Console.WriteLine($"Toolbar item count:{toolbarItems.Length}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove Console.WriteLine. If you want, you can write debug logs.
This PR contains blazor UI extensibility features except the module extensibility feature.
I implemented the usage in the Identity module. I will start implementing the other modules once I get initial feedback. It takes time to change all modules when you get feedback on usage :)
Entity Actions and Table Columns
Developers can easily define table columns and actions by using
UIExtensions.Instance.EntityActions
andUIExtensions.Instance.TableColumns
properties. This PR also introduces theABPDataGrid
component. This component creates table columns and actions automatically using the UI extensibility system.Developers can also extend the modules and add their actions/columns like below.
Page Toolbars
In the final implementation, I will move the
PageHeader
component and related types fromAbp.Volo.BlazoriseUI
toVolo.Abp.AspNetCore.Components.WebAssembly.Theming
. There twoPageHeader
components in this branch right now. I didn't want to break the all modules.In our modules, we can simply inject
IOptions<AbpPageToolbarOptions>
and add the toolbar items insideSetToolbarItemsAsync
method.Developers can also define their own contributors and add them inside configure method.
Bundling and Minification
I made related changes and
abp bundle
command reads the appsettings.json to get the bundling settings right now. I also added a parameter namedparameters
. Developers can define extra key/value pair parameters and send them to the contributors.I didn't make any changes on the extensibility side. The current design supports extensibility. Developers can define a contributor and update any dependency by using
context.BundleDefinitions
property.