Skip to content

Commit

Permalink
Added option to supress the "SEO settings have been saved" notificati…
Browse files Browse the repository at this point in the history
…on (#285)

* Added seo warning

* Added an option to supress the SEO settings saved notification

* Removed logging

---------

Co-authored-by: Ambert van Unen <AvanUnen@ilionx.com>
Co-authored-by: Ambert <ambert@webmeesterlijk.nl>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent 7bc3c74 commit cc1ba69
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class GlobalConfig
{
public bool AutomaticSitemapsInRobotsTxt { get; set; }
public bool EnableSeoSettingsByDefault { get; set; }
public bool SupressContentAppSavingNotification { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public interface ISeoSettingsService
{
bool IsEnabled(int contentTypeId);
bool SupressContentAppSavingNotification();
void ToggleSeoSettings(int contentTypeId, bool value);
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,11 +14,13 @@ public class SeoSettingsService : ISeoSettingsService
private readonly ISeoSettingsRepository _seoSettingsRepository;
private readonly DistributedCache _distributedCache;
private readonly IAppPolicyCache _cache;
private readonly ISettingsService<GlobalConfig> _settingsService;

public SeoSettingsService(ISeoSettingsRepository seoSettingsRepository, AppCaches appCaches, DistributedCache distributedCache)
public SeoSettingsService(ISeoSettingsRepository seoSettingsRepository, AppCaches appCaches, DistributedCache distributedCache, ISettingsService<GlobalConfig> settingsService)
{
_seoSettingsRepository = seoSettingsRepository;
_distributedCache = distributedCache;
_settingsService = settingsService;
_cache = appCaches.RuntimeCache;
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public override GlobalConfig GetSettings()
return new GlobalConfig
{
AutomaticSitemapsInRobotsTxt = settings.AutomaticSitemapsInRobotsTxt,
EnableSeoSettingsByDefault = settings.EnableSeoSettingsByDefault
EnableSeoSettingsByDefault = settings.EnableSeoSettingsByDefault,
SupressContentAppSavingNotification = settings.SupressContentAppSavingNotification,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
vm.model = {
enableSeoSettings: false
}

vm.model.supressSavingNotification = false;
vm.setSeoSettings = function (value) {
vm.model.enableSeoSettings = value;
}
Expand All @@ -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;

Expand All @@ -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!");
}
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeoToolkit.Umbraco.Site/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
},
"SeoToolkit": {
"Global": {
"AutomaticSitemapsInRobotsTxt": false
"AutomaticSitemapsInRobotsTxt": false,
"SupressContentAppSavingNotification": false
},
"SiteAudit": {
"MinimumDelayBetweenRequest": 2,
Expand Down

0 comments on commit cc1ba69

Please sign in to comment.