diff --git a/src/SeoToolkit.Umbraco.Common.Core/Controllers/SeoSettingsController.cs b/src/SeoToolkit.Umbraco.Common.Core/Controllers/SeoSettingsController.cs index e0cd9289..56cdf5b6 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Controllers/SeoSettingsController.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Controllers/SeoSettingsController.cs @@ -27,6 +27,7 @@ public IActionResult Get(int contentTypeId) return new JsonResult(new SeoSettingsViewModel { IsEnabled = _seoSettingsService.IsEnabled(contentTypeId), + SupressContentAppSavingNotification = _seoSettingsService.SupressContentAppSavingNotification(), //TODO from settings Displays = _displayCollection.Select(it => it.Get(contentTypeId)).WhereNotNull().ToArray() }); } diff --git a/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalAppSettingsModel.cs b/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalAppSettingsModel.cs index db8da1ef..f605665a 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalAppSettingsModel.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalAppSettingsModel.cs @@ -4,5 +4,6 @@ public class GlobalAppSettingsModel { public bool AutomaticSitemapsInRobotsTxt { get; set; } = true; public bool EnableSeoSettingsByDefault { get; set; } = false; // TODO: Change this in a major version to true; + public bool SupressContentAppSavingNotification { get; set; } } } diff --git a/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalConfig.cs b/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalConfig.cs index ffd06808..9c84ba96 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalConfig.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Models/Config/GlobalConfig.cs @@ -4,5 +4,6 @@ public class GlobalConfig { public bool AutomaticSitemapsInRobotsTxt { get; set; } public bool EnableSeoSettingsByDefault { get; set; } + public bool SupressContentAppSavingNotification { get; set; } } } diff --git a/src/SeoToolkit.Umbraco.Common.Core/Models/ViewModels/SeoSettingsViewModel.cs b/src/SeoToolkit.Umbraco.Common.Core/Models/ViewModels/SeoSettingsViewModel.cs index c1dca936..3c78827c 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Models/ViewModels/SeoSettingsViewModel.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Models/ViewModels/SeoSettingsViewModel.cs @@ -5,6 +5,7 @@ namespace SeoToolkit.Umbraco.Common.Core.Models.ViewModels public class SeoSettingsViewModel { public bool IsEnabled { get; set; } + public bool SupressContentAppSavingNotification { get; set; } public SeoDisplayViewModel[] Displays { get; set; } public SeoSettingsViewModel() diff --git a/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/ISeoSettingsService.cs b/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/ISeoSettingsService.cs index 3e520453..98b82b26 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/ISeoSettingsService.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/ISeoSettingsService.cs @@ -3,6 +3,7 @@ public interface ISeoSettingsService { bool IsEnabled(int contentTypeId); + bool SupressContentAppSavingNotification(); void ToggleSeoSettings(int contentTypeId, bool value); } } diff --git a/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/SeoSettingsService.cs b/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/SeoSettingsService.cs index 96ecd38a..c5593a9d 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/SeoSettingsService.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Services/SeoSettingsService/SeoSettingsService.cs @@ -1,7 +1,9 @@ using System; using SeoToolkit.Umbraco.Common.Core.Caching; using SeoToolkit.Umbraco.Common.Core.Constants; +using SeoToolkit.Umbraco.Common.Core.Models.Config; using SeoToolkit.Umbraco.Common.Core.Repositories.SeoSettingsRepository; +using SeoToolkit.Umbraco.Common.Core.Services.SettingsService; using Umbraco.Cms.Core.Cache; using Umbraco.Extensions; @@ -12,11 +14,13 @@ public class SeoSettingsService : ISeoSettingsService private readonly ISeoSettingsRepository _seoSettingsRepository; private readonly DistributedCache _distributedCache; private readonly IAppPolicyCache _cache; + private readonly ISettingsService _settingsService; - public SeoSettingsService(ISeoSettingsRepository seoSettingsRepository, AppCaches appCaches, DistributedCache distributedCache) + public SeoSettingsService(ISeoSettingsRepository seoSettingsRepository, AppCaches appCaches, DistributedCache distributedCache, ISettingsService settingsService) { _seoSettingsRepository = seoSettingsRepository; _distributedCache = distributedCache; + _settingsService = settingsService; _cache = appCaches.RuntimeCache; } @@ -26,6 +30,11 @@ public bool IsEnabled(int contentTypeId) () => _seoSettingsRepository.IsEnabled(contentTypeId), TimeSpan.FromMinutes(10)); } + public bool SupressContentAppSavingNotification() + { + return _settingsService.GetSettings().SupressContentAppSavingNotification; + } + public void ToggleSeoSettings(int contentTypeId, bool value) { _seoSettingsRepository.Toggle(contentTypeId, value); diff --git a/src/SeoToolkit.Umbraco.Common.Core/Services/SettingsService/GlobalConfigService.cs b/src/SeoToolkit.Umbraco.Common.Core/Services/SettingsService/GlobalConfigService.cs index c1393d97..fb87af7c 100644 --- a/src/SeoToolkit.Umbraco.Common.Core/Services/SettingsService/GlobalConfigService.cs +++ b/src/SeoToolkit.Umbraco.Common.Core/Services/SettingsService/GlobalConfigService.cs @@ -19,7 +19,8 @@ public override GlobalConfig GetSettings() return new GlobalConfig { AutomaticSitemapsInRobotsTxt = settings.AutomaticSitemapsInRobotsTxt, - EnableSeoSettingsByDefault = settings.EnableSeoSettingsByDefault + EnableSeoSettingsByDefault = settings.EnableSeoSettingsByDefault, + SupressContentAppSavingNotification = settings.SupressContentAppSavingNotification, }; } } diff --git a/src/SeoToolkit.Umbraco.Common/wwwroot/ContentApps/DocumentType/seoSettings.controller.js b/src/SeoToolkit.Umbraco.Common/wwwroot/ContentApps/DocumentType/seoSettings.controller.js index 83566211..df9fe137 100644 --- a/src/SeoToolkit.Umbraco.Common/wwwroot/ContentApps/DocumentType/seoSettings.controller.js +++ b/src/SeoToolkit.Umbraco.Common/wwwroot/ContentApps/DocumentType/seoSettings.controller.js @@ -13,7 +13,7 @@ vm.model = { enableSeoSettings: false } - + vm.model.supressSavingNotification = false; vm.setSeoSettings = function (value) { vm.model.enableSeoSettings = value; } @@ -34,6 +34,7 @@ function (response) { if (response.status === 200) { vm.model.enableSeoSettings = response.data.isEnabled; + vm.model.supressContentAppSavingNotification = response.data.supressContentAppSavingNotification; vm.displays = response.data.displays; vm.displays[0].active = true; @@ -51,7 +52,9 @@ if (response.status !== 200) { notificationsService.error("Something went wrong while saving SEO settings"); } else { - notificationsService.success("SEO settings saved!"); + if(!vm.model.supressContentAppSavingNotification){ + notificationsService.success("SEO settings saved!"); + } } }); } diff --git a/src/SeoToolkit.Umbraco.Site/appsettings.json b/src/SeoToolkit.Umbraco.Site/appsettings.json index f3c495f5..f1a583f4 100644 --- a/src/SeoToolkit.Umbraco.Site/appsettings.json +++ b/src/SeoToolkit.Umbraco.Site/appsettings.json @@ -28,7 +28,8 @@ }, "SeoToolkit": { "Global": { - "AutomaticSitemapsInRobotsTxt": false + "AutomaticSitemapsInRobotsTxt": false, + "SupressContentAppSavingNotification": false }, "SiteAudit": { "MinimumDelayBetweenRequest": 2,