Skip to content

Commit

Permalink
VCST-1279: add platform UI options to disable Platform UI (#2802)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksavosteev authored Jun 6, 2024
1 parent 78889b6 commit b1ea8e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/VirtoCommerce.Platform.Core/PlatformUIOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace VirtoCommerce.Platform.Core
{
public class PlatformUIOptions
{
public bool Enable { get; set; } = true;
}
}
16 changes: 15 additions & 1 deletion src/VirtoCommerce.Platform.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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> platformOptions, IOptions<WebAnalyticsOptions> webAnalyticsOptions, IOptions<LocalStorageModuleCatalogOptions> localStorageModuleCatalogOptions, IOptions<PushNotificationOptions> pushNotificationOptions, LicenseProvider licenseProvider, ISettingsManager settingsManager)
public HomeController(
IOptions<PlatformOptions> platformOptions,
IOptions<WebAnalyticsOptions> webAnalyticsOptions,
IOptions<LocalStorageModuleCatalogOptions> localStorageModuleCatalogOptions,
IOptions<PushNotificationOptions> pushNotificationOptions,
IOptions<PlatformUIOptions> 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<ActionResult> Index()
{
if (!_platformUIOptions.Enable)
{
return Forbid();
}

var model = new IndexModel
{
PlatformVersion = new HtmlString(Core.Common.PlatformVersion.CurrentVersion.ToString()),
Expand Down
3 changes: 3 additions & 0 deletions src/VirtoCommerce.Platform.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ public void ConfigureServices(IServiceCollection services)
break;
}

// Platform UI options
services.AddOptions<PlatformUIOptions>().Bind(Configuration.GetSection("VirtoCommerce:PlatformUI"));

// Add login page UI options
var loginPageUIOptions = Configuration.GetSection("LoginPageUI");
services.AddOptions<LoginPageUIOptions>().Bind(loginPageUIOptions);
Expand Down
3 changes: 3 additions & 0 deletions src/VirtoCommerce.Platform.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"GraphQLPlayground": {
"Enable": true
},
"PlatformUI": {
"Enable": true
},
"Hangfire": {
"JobStorageType": "Database",
//Set value to false to stop processing the background jobs.
Expand Down

0 comments on commit b1ea8e5

Please sign in to comment.