Skip to content

Commit a263a4c

Browse files
authored
Add ui disable (#1254)
1 parent 379caae commit a263a4c

5 files changed

Lines changed: 23 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public sealed record MyUIOptions
5656
[JsonPropertyName("collaborationService")]
5757
public string CollaborationService { get; set; }
5858

59+
[JsonPropertyName("disable")]
60+
public bool Disable { get; set; }
61+
5962
public sealed class MapOptions
6063
{
6164
[JsonPropertyName("type")]

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using Microsoft.Extensions.FileProviders;
99
using Microsoft.Net.Http.Headers;
10+
using Squidex.Areas.Api.Controllers.UI;
1011
using Squidex.Areas.Frontend.Middlewares;
1112
using Squidex.Hosting.Web;
1213
using Squidex.Pipeline.Squid;
@@ -17,8 +18,14 @@ namespace Squidex.Areas.Frontend;
1718

1819
public static class Startup
1920
{
20-
public static void UseFrontend(this IApplicationBuilder app)
21+
public static void UseFrontend(this IApplicationBuilder app, IConfiguration config)
2122
{
23+
var uiOptions = config.GetSection("ui").Get<MyUIOptions>();
24+
if (uiOptions is { Disable: true })
25+
{
26+
return;
27+
}
28+
2229
var environment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
2330

2431
var fileProvider = environment.WebRootFileProvider;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ namespace Squidex.Config.Domain;
1919

2020
public static class FontendServices
2121
{
22-
public static void AddSquidexFrontend(this IServiceCollection services)
22+
public static void AddSquidexFrontend(this IServiceCollection services, IConfiguration config)
2323
{
24+
var uiOptions = config.GetSection("ui").Get<MyUIOptions>();
25+
if (uiOptions is { Disable: true })
26+
{
27+
return;
28+
}
29+
2430
services.Configure<MyUIOptions>((services, options) =>
2531
{
2632
var jsonOptions = services.GetRequiredService<JsonSerializerOptions>();

backend/src/Squidex/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void ConfigureServices(IServiceCollection services)
4343
services.AddSquidexContents(config);
4444
services.AddSquidexControllerServices(config);
4545
services.AddSquidexEventSourcing(config);
46-
services.AddSquidexFrontend();
46+
services.AddSquidexFrontend(config);
4747
services.AddSquidexGraphQL();
4848
services.AddSquidexHealthChecks(config);
4949
services.AddSquidexHistory(config);
@@ -119,7 +119,7 @@ public void Configure(IApplicationBuilder app)
119119
builder.Use404();
120120
});
121121

122-
app.UseFrontend();
122+
app.UseFrontend(config);
123123
app.UsePlugins();
124124
}
125125
}

backend/src/Squidex/appsettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@
149149
},
150150

151151
"ui": {
152+
// Admin UI disable
153+
"disable": false,
154+
152155
// Regex suggestions for the UI
153156
"regexSuggestions": {
154157
// Regex for emails.

0 commit comments

Comments
 (0)