Skip to content

Commit

Permalink
Code clean-up
Browse files Browse the repository at this point in the history
refactored code that has been deprecated in Umbraco 15.
  • Loading branch information
leekelleher committed Nov 23, 2024
1 parent 6196bb5 commit 7aa59ad
Show file tree
Hide file tree
Showing 47 changed files with 281 additions and 426 deletions.
3 changes: 0 additions & 3 deletions src/Umbraco.Cms.15.x/Views/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@using Umbraco.Extensions
@using Umbraco.Cms._15.x
@using Umbraco.Cms.Web.Common.PublishedModels
@using Umbraco.Cms.Web.Common.Views
@using Umbraco.Cms.Core.Models.PublishedContent
@using Microsoft.AspNetCore.Html
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Smidge
@inject Smidge.SmidgeHelper SmidgeHelper
14 changes: 14 additions & 0 deletions src/Umbraco.Cms.15.x/Views/_layout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@inherits UmbracoViewPage
@{
Layout = null;
}
<!doctype html>
<html>
<head>
<title>@Model.Name</title>
</head>
<body>
<h1>@Model.Name</h1>
@RenderBody()
</body>
</html>
5 changes: 5 additions & 0 deletions src/Umbraco.Cms.15.x/Views/homePage.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@inherits UmbracoViewPage
@{
Layout = "_layout.cshtml";
}
<h2>@Model.Name</h2>
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ internal sealed class ContentmentComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
#if NET8_0_OR_GREATER == false
builder
.ManifestFilters()
.Append<ContentmentManifestFilter>()
;
#endif

builder
.Services
.AddSingleton<ConfigurationEditorUtility>()
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Community.Contentment/ContentmentConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public static class Views

public const string ListItems = DataEditors.ListItemsDataEditor.DataEditorViewPath;

[Obsolete("To be removed in Contentment 7.0")]
public const string MacroPicker = DataEditors.MacroPickerDataEditor.DataEditorViewPath;

public const string Notes = DataEditors.NotesDataEditor.DataEditorViewPath;
Expand Down
27 changes: 0 additions & 27 deletions src/Umbraco.Community.Contentment/ContentmentManifestFilter.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ public sealed class CodeEditorDataEditor : DataEditor

private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IIOHelper _ioHelper;
private readonly ILocalizedTextService _localizedTextService;
private readonly IShortStringHelper _shortStringHelper;
private readonly IJsonSerializer _jsonSerializer;

public CodeEditorDataEditor(
IDataValueEditorFactory dataValueEditorFactory,
IWebHostEnvironment webHostEnvironment,
IIOHelper ioHelper,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper,
IJsonSerializer jsonSerializer)
: base(dataValueEditorFactory)
{
_webHostEnvironment = webHostEnvironment;
_ioHelper = ioHelper;
_localizedTextService = localizedTextService;
_shortStringHelper = shortStringHelper;
_jsonSerializer = jsonSerializer;
}
Expand All @@ -53,7 +50,6 @@ public CodeEditorDataEditor(

protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(
Attribute!,
_localizedTextService,
_shortStringHelper,
_jsonSerializer,
_ioHelper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public sealed class ContentBlocksDataEditor : IDataEditor
private readonly IShortStringHelper _shortStringHelper;
private readonly ConfigurationEditorUtility _utility;
private readonly IIOHelper _ioHelper;
private readonly ILocalizedTextService _localizedTextService;
private readonly IJsonSerializer _jsonSerializer;
private readonly IPropertyValidationService _propertyValidationService;

Expand All @@ -39,7 +38,6 @@ public ContentBlocksDataEditor(
IContentTypeService contentTypeService,
Lazy<PropertyEditorCollection> propertyEditors,
IDataTypeConfigurationCache dataTypeConfigurationCache,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper,
IJsonSerializer jsonSerializer,
ConfigurationEditorUtility utility,
Expand All @@ -49,7 +47,6 @@ public ContentBlocksDataEditor(
_contentService = contentService;
_contentTypeService = contentTypeService;
_dataTypeConfigurationCache = dataTypeConfigurationCache;
_localizedTextService = localizedTextService;
_shortStringHelper = shortStringHelper;
_jsonSerializer = jsonSerializer;
_propertyEditors = propertyEditors;
Expand Down Expand Up @@ -80,7 +77,6 @@ public IDataValueEditor GetValueEditor()
_contentTypeService,
_propertyEditors.Value,
_dataTypeConfigurationCache,
_localizedTextService,
_shortStringHelper,
_jsonSerializer,
_propertyValidationService)
Expand All @@ -92,47 +88,42 @@ public IDataValueEditor GetValueEditor()

public IDataValueEditor GetValueEditor(object? configuration)
{
var view = default(string);

if (configuration is Dictionary<string, object> config)
{
if (config.TryGetValue(ContentBlocksConfigurationEditor.DisplayMode, out var tmp1) == true)
{
var displayMode = default(IContentBlocksDisplayMode);

if (tmp1 is string str1 && str1?.InvariantStartsWith(Constants.Internals.EditorsPathRoot) == true)
{
displayMode = _utility.FindConfigurationEditor<IContentBlocksDisplayMode>(x => str1.InvariantEquals(x.View) == true);
}
else if (tmp1 is JArray array1 &&
array1.Count > 0 &&
array1[0] is JObject item1 &&
item1.Value<string>("key") is string key)
{
displayMode = _utility.GetConfigurationEditor<IContentBlocksDisplayMode>(key);
}

if (displayMode != null)
{
view = displayMode.View;
}
}
}
//var view = default(string);

//if (configuration is Dictionary<string, object> config)
//{
// if (config.TryGetValue(ContentBlocksConfigurationEditor.DisplayMode, out var tmp1) == true)
// {
// var displayMode = default(IContentBlocksDisplayMode);

// if (tmp1 is string str1 && str1?.InvariantStartsWith(Constants.Internals.EditorsPathRoot) == true)
// {
// displayMode = _utility.FindConfigurationEditor<IContentBlocksDisplayMode>(x => str1.InvariantEquals(x.View) == true);
// }
// else if (tmp1 is JArray array1 &&
// array1.Count > 0 &&
// array1[0] is JObject item1 &&
// item1.Value<string>("key") is string key)
// {
// displayMode = _utility.GetConfigurationEditor<IContentBlocksDisplayMode>(key);
// }

// if (displayMode != null)
// {
// view = displayMode.View;
// }
// }
//}

return new ContentBlocksDataValueEditor(
_contentTypeService,
_propertyEditors.Value,
_dataTypeConfigurationCache,
_localizedTextService,
_shortStringHelper,
_jsonSerializer,
_propertyValidationService)
{
#if NET8_0_OR_GREATER
ConfigurationObject = configuration,
#else
Configuration = configuration,
#endif
ValueType = ValueTypes.Json,
//View = _ioHelper.ResolveRelativeOrVirtualUrl(view ?? DataEditorViewPath),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ public ContentBlocksDataValueEditor(
IContentTypeService contentTypeService,
PropertyEditorCollection propertyEditors,
IDataTypeConfigurationCache dataTypeConfigurationCache,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper,
IJsonSerializer jsonSerializer,
IPropertyValidationService propertyValidationService)
: base(localizedTextService, shortStringHelper, jsonSerializer)
: base(shortStringHelper, jsonSerializer)
{
_dataTypeConfigurationCache = dataTypeConfigurationCache;
_elementTypes = new Lazy<Dictionary<Guid, IContentType>>(() => contentTypeService.GetAllElementTypes().ToDictionary(x => x.Key));
Expand Down
Loading

0 comments on commit 7aa59ad

Please sign in to comment.