From b1ea8e5c79f646388a4aedf327b85fff27bae39d Mon Sep 17 00:00:00 2001 From: Konstantin Savosteev Date: Thu, 6 Jun 2024 09:35:53 +0200 Subject: [PATCH] VCST-1279: add platform UI options to disable Platform UI (#2802) --- .../PlatformUIOptions.cs | 7 +++++++ .../Controllers/HomeController.cs | 16 +++++++++++++++- src/VirtoCommerce.Platform.Web/Startup.cs | 3 +++ src/VirtoCommerce.Platform.Web/appsettings.json | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/VirtoCommerce.Platform.Core/PlatformUIOptions.cs diff --git a/src/VirtoCommerce.Platform.Core/PlatformUIOptions.cs b/src/VirtoCommerce.Platform.Core/PlatformUIOptions.cs new file mode 100644 index 00000000000..2bf30d0c4c5 --- /dev/null +++ b/src/VirtoCommerce.Platform.Core/PlatformUIOptions.cs @@ -0,0 +1,7 @@ +namespace VirtoCommerce.Platform.Core +{ + public class PlatformUIOptions + { + public bool Enable { get; set; } = true; + } +} diff --git a/src/VirtoCommerce.Platform.Web/Controllers/HomeController.cs b/src/VirtoCommerce.Platform.Web/Controllers/HomeController.cs index b3dbb207755..eb152a6925f 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/HomeController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/HomeController.cs @@ -24,20 +24,34 @@ public class HomeController : Controller private readonly WebAnalyticsOptions _webAnalyticsOptions; private readonly LocalStorageModuleCatalogOptions _localStorageModuleCatalogOptions; private readonly LicenseProvider _licenseProvider; + private readonly PlatformUIOptions _platformUIOptions; private readonly ISettingsManager _settingsManager; - public HomeController(IOptions platformOptions, IOptions webAnalyticsOptions, IOptions localStorageModuleCatalogOptions, IOptions pushNotificationOptions, LicenseProvider licenseProvider, ISettingsManager settingsManager) + public HomeController( + IOptions platformOptions, + IOptions webAnalyticsOptions, + IOptions localStorageModuleCatalogOptions, + IOptions pushNotificationOptions, + IOptions platformUIOptions, + LicenseProvider licenseProvider, + ISettingsManager settingsManager) { _platformOptions = platformOptions.Value; _webAnalyticsOptions = webAnalyticsOptions.Value; _localStorageModuleCatalogOptions = localStorageModuleCatalogOptions.Value; _pushNotificationOptions = pushNotificationOptions.Value; + _platformUIOptions = platformUIOptions.Value; _licenseProvider = licenseProvider; _settingsManager = settingsManager; } public async Task Index() { + if (!_platformUIOptions.Enable) + { + return Forbid(); + } + var model = new IndexModel { PlatformVersion = new HtmlString(Core.Common.PlatformVersion.CurrentVersion.ToString()), diff --git a/src/VirtoCommerce.Platform.Web/Startup.cs b/src/VirtoCommerce.Platform.Web/Startup.cs index 4369153e61c..626d1588091 100644 --- a/src/VirtoCommerce.Platform.Web/Startup.cs +++ b/src/VirtoCommerce.Platform.Web/Startup.cs @@ -526,6 +526,9 @@ public void ConfigureServices(IServiceCollection services) break; } + // Platform UI options + services.AddOptions().Bind(Configuration.GetSection("VirtoCommerce:PlatformUI")); + // Add login page UI options var loginPageUIOptions = Configuration.GetSection("LoginPageUI"); services.AddOptions().Bind(loginPageUIOptions); diff --git a/src/VirtoCommerce.Platform.Web/appsettings.json b/src/VirtoCommerce.Platform.Web/appsettings.json index 564fc2e82b4..0e84f434fd2 100644 --- a/src/VirtoCommerce.Platform.Web/appsettings.json +++ b/src/VirtoCommerce.Platform.Web/appsettings.json @@ -40,6 +40,9 @@ "GraphQLPlayground": { "Enable": true }, + "PlatformUI": { + "Enable": true + }, "Hangfire": { "JobStorageType": "Database", //Set value to false to stop processing the background jobs.