Added XML configuration support for cleanup policy

This commit is contained in:
Paul Johnson
2021-10-18 15:26:38 +01:00
parent d865448177
commit a1ac730633
6 changed files with 36 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("notifications", IsRequired = true)]
internal NotificationsElement Notifications => (NotificationsElement) base["notifications"];
[ConfigurationProperty("contentVersionCleanupPolicy", IsRequired = false)]
internal ContentVersionCleanupPolicyElement ContentVersionCleanupPolicy => (ContentVersionCleanupPolicyElement) this["contentVersionCleanupPolicy"];
[ConfigurationProperty("PreviewBadge")]
internal InnerTextConfigurationElement<string> PreviewBadge => GetOptionalTextElement("PreviewBadge", DefaultPreviewBadge);
@@ -61,6 +64,8 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
IEnumerable<string> IContentSection.AllowedUploadFiles => AllowedUploadFiles;
IContentVersionCleanupPolicySettings IContentSection.ContentVersionCleanupPolicySettings => ContentVersionCleanupPolicy;
bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;
string IContentSection.LoginBackgroundImage => LoginBackgroundImage;

View File

@@ -0,0 +1,16 @@
using System.Configuration;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class ContentVersionCleanupPolicyElement : UmbracoConfigurationElement, IContentVersionCleanupPolicySettings
{
[ConfigurationProperty("enable", DefaultValue = false)]
public bool EnableCleanup => (bool)this["enable"];
[ConfigurationProperty("keepAllVersionsNewerThanDays", DefaultValue = 2)]
public int KeepAllVersionsNewerThanDays => (int)this["keepAllVersionsNewerThanDays"];
[ConfigurationProperty("keepLatestVersionPerDayForDays", DefaultValue = 30)]
public int KeepLatestVersionPerDayForDays => (int)this["keepLatestVersionPerDayForDays"];
}
}

View File

@@ -25,6 +25,8 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
IEnumerable<string> AllowedUploadFiles { get; }
IContentVersionCleanupPolicySettings ContentVersionCleanupPolicySettings { get; }
/// <summary>
/// Gets a value indicating whether to show deprecated property editors in
/// a datatype list of available editors.

View File

@@ -0,0 +1,9 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IContentVersionCleanupPolicySettings
{
bool EnableCleanup { get; }
int KeepAllVersionsNewerThanDays { get; }
int KeepLatestVersionPerDayForDays { get; }
}
}

View File

@@ -130,6 +130,8 @@
<Compile Include="AssemblyExtensions.cs" />
<Compile Include="Collections\StackQueue.cs" />
<Compile Include="Configuration\ICoreDebug.cs" />
<Compile Include="Configuration\UmbracoSettings\ContentVersionCleanupPolicyElement.cs" />
<Compile Include="Configuration\UmbracoSettings\IContentVersionCleanupPolicySettings.cs" />
<Compile Include="Constants-CharArrays.cs" />
<Compile Include="Collections\EventClearingObservableCollection.cs" />
<Compile Include="Constants-Sql.cs" />

View File

@@ -190,6 +190,8 @@
<!-- You can specify your own logo for the login screen here. This path is relative to the ~/umbraco path. The default location is: /umbraco/assets/img/application/umbraco_logo_white.svg -->
<loginLogoImage>assets/img/application/umbraco_logo_white.svg</loginLogoImage>
<contentVersionCleanupPolicy enable="true" keepAllVersionsNewerThanDays="2" keepLatestVersionPerDayForDays="30" />
</content>
<security>