Browse Source

Add ui disable (#1254)

pull/1260/head
Noah 10 months ago
committed by GitHub
parent
commit
a263a4c031
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 3
      backend/src/Squidex/Areas/Api/Controllers/UI/MyUIOptions.cs
  2. 9
      backend/src/Squidex/Areas/Frontend/Startup.cs
  3. 8
      backend/src/Squidex/Config/Domain/FontendServices.cs
  4. 4
      backend/src/Squidex/Startup.cs
  5. 3
      backend/src/Squidex/appsettings.json

3
backend/src/Squidex/Areas/Api/Controllers/UI/MyUIOptions.cs

@ -56,6 +56,9 @@ public sealed record MyUIOptions
[JsonPropertyName("collaborationService")]
public string CollaborationService { get; set; }
[JsonPropertyName("disable")]
public bool Disable { get; set; }
public sealed class MapOptions
{
[JsonPropertyName("type")]

9
backend/src/Squidex/Areas/Frontend/Startup.cs

@ -7,6 +7,7 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Net.Http.Headers;
using Squidex.Areas.Api.Controllers.UI;
using Squidex.Areas.Frontend.Middlewares;
using Squidex.Hosting.Web;
using Squidex.Pipeline.Squid;
@ -17,8 +18,14 @@ namespace Squidex.Areas.Frontend;
public static class Startup
{
public static void UseFrontend(this IApplicationBuilder app)
public static void UseFrontend(this IApplicationBuilder app, IConfiguration config)
{
var uiOptions = config.GetSection("ui").Get<MyUIOptions>();
if (uiOptions is { Disable: true })
{
return;
}
var environment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
var fileProvider = environment.WebRootFileProvider;

8
backend/src/Squidex/Config/Domain/FontendServices.cs

@ -19,8 +19,14 @@ namespace Squidex.Config.Domain;
public static class FontendServices
{
public static void AddSquidexFrontend(this IServiceCollection services)
public static void AddSquidexFrontend(this IServiceCollection services, IConfiguration config)
{
var uiOptions = config.GetSection("ui").Get<MyUIOptions>();
if (uiOptions is { Disable: true })
{
return;
}
services.Configure<MyUIOptions>((services, options) =>
{
var jsonOptions = services.GetRequiredService<JsonSerializerOptions>();

4
backend/src/Squidex/Startup.cs

@ -43,7 +43,7 @@ public sealed class Startup(IConfiguration config)
services.AddSquidexContents(config);
services.AddSquidexControllerServices(config);
services.AddSquidexEventSourcing(config);
services.AddSquidexFrontend();
services.AddSquidexFrontend(config);
services.AddSquidexGraphQL();
services.AddSquidexHealthChecks(config);
services.AddSquidexHistory(config);
@ -119,7 +119,7 @@ public sealed class Startup(IConfiguration config)
builder.Use404();
});
app.UseFrontend();
app.UseFrontend(config);
app.UsePlugins();
}
}

3
backend/src/Squidex/appsettings.json

@ -149,6 +149,9 @@
},
"ui": {
// Admin UI disable
"disable": false,
// Regex suggestions for the UI
"regexSuggestions": {
// Regex for emails.

Loading…
Cancel
Save