Skip to content

Commit

Permalink
Added XML configuration support for cleanup policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Johnson committed Oct 26, 2021
1 parent d865448 commit a1ac730
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ internal class ContentElement : UmbracoConfigurationElement, IContentSection
[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);

Expand Down Expand Up @@ -61,6 +64,8 @@ internal class ContentElement : UmbracoConfigurationElement, IContentSection

IEnumerable<string> IContentSection.AllowedUploadFiles => AllowedUploadFiles;

IContentVersionCleanupPolicySettings IContentSection.ContentVersionCleanupPolicySettings => ContentVersionCleanupPolicy;

bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;

string IContentSection.LoginBackgroundImage => LoginBackgroundImage;
Expand Down
Original file line number Diff line number Diff line change
@@ -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"];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface IContentSection : IUmbracoConfigurationSection

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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface IContentVersionCleanupPolicySettings
{
bool EnableCleanup { get; }
int KeepAllVersionsNewerThanDays { get; }
int KeepLatestVersionPerDayForDays { get; }
}
}
2 changes: 2 additions & 0 deletions src/Umbraco.Core/Umbraco.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI/config/umbracoSettings.Release.config
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit a1ac730

Please sign in to comment.