From ef7fc3b717060ac6a18c77d889a0e6eb6aa6c41a Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 17 Jul 2026 14:10:37 +0800 Subject: [PATCH] Add React to the UiFramework enum React solutions are generated by ABP Studio's modern templates, so map React in ToFrameworkName and reject it in the classic template builder. Also document that React templates can be customized in ABP Suite. --- docs/en/suite/editing-templates.md | 5 +++-- .../Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs | 3 ++- .../ProjectBuilding/Building/UiFrameworkExtensions.cs | 1 + .../Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs | 9 +++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/en/suite/editing-templates.md b/docs/en/suite/editing-templates.md index 8e3278f72c..1c730356a0 100644 --- a/docs/en/suite/editing-templates.md +++ b/docs/en/suite/editing-templates.md @@ -13,10 +13,10 @@ ABP Suite uses templates to generate the code files. You can see the template fi There are 2 template filters: -1. **UI**: You can switch between `Angular`, `MVC` and `Blazor` templates. +1. **UI**: You can switch between `Angular`, `MVC`, `Blazor` and `React` templates. 2. **Database provider:** You can switch between `EF Core` and `MongoDb` templates. -> **Note:** This template editor lists the `Angular`, `MVC` and `Blazor` templates. ABP Suite generates React CRUD pages for modern React UI solutions from built-in templates, but those React templates are not editable through this template editor. +> **Note:** For modern React UI solutions, the React templates are listed here as well. Customizing one makes ABP Suite generate the React pages from your version instead of the built-in template, the same way as for the Angular, MVC and Blazor UI stacks. These filters are automatically selected based on your ABP solution. The selected solution is shown on the top right of the page. In the current screenshot it is "Acme.BookStore". @@ -33,6 +33,7 @@ There's a naming convention for the template files. * If the template name has `Frontend.Mvc` prefix, it's used for razor pages, menus, JavaScript, CSS files. * If the template name has `Frontend.Blazor` prefix (no `.MudBlazor` segment), it's used for Blazorise-based razor components. * If the template name has `Frontend.Blazor.MudBlazor` prefix, it's used for [MudBlazor](https://mudblazor.com)-based razor components. +* If the template name has `Frontend.React` prefix, it's used for the modern React UI code generation. > The template list only shows the variant that matches your solution's [Blazor UI library](index.md#blazor-ui-library) (Blazorise or MudBlazor), so you never see both trees side-by-side and the "outdated" check only flags the active set. diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs index ae8c2b4a07..dfd74e3e2e 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs @@ -9,5 +9,6 @@ public enum UiFramework Blazor = 4, BlazorServer = 5, MauiBlazor = 6, - BlazorWebApp = 7 + BlazorWebApp = 7, + React = 8 } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs index cb592444e6..a31725f575 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs @@ -12,6 +12,7 @@ public static class UiFrameworkExtensions case UiFramework.Blazor: return "blazor"; case UiFramework.BlazorServer: return "blazor-server"; case UiFramework.BlazorWebApp: return "blazor-webapp"; + case UiFramework.React: return "react"; case UiFramework.NotSpecified: return "NotSpecified"; default: return "NotSpecified"; } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index 1a27ae84d0..e2af3f5d43 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -59,6 +59,15 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency NormalizeArgs(args, templateInfo); + // Checked after NormalizeArgs so a NotSpecified UI resolved to React is caught too. React is only + // produced by ABP Studio's modern solution templates; the classic builders below have no React + // handling, so fail fast instead of emitting a solution with an unconfigured UI. + if (args.UiFramework == UiFramework.React) + { + throw new UserFriendlyException( + "The React UI is generated by ABP Studio's modern solution templates and is not supported by the classic template builder."); + } + await EventBus.PublishAsync(new ProjectCreationProgressEvent { Message = "Downloading the solution template" }, false);