V14: Remove old backoffice project. (#15752)
* Move magical route to management api * Move auth around * Remove "New" cookies, as they are no longer needed * Move all installer related * Remove BackOfficeServerVariables.cs and trees * Move webhooks to management api * Remove remainting controllers * Remove last services * Move preview to management api * Remove mroe extensions * Remove tours * Remove old Auth handlers * Remove server variables entirely * Remove old backoffice controller * Remove controllers namespace entirely * Move rest of preview * move last services * Move language file extension * Remove old backoffice entirely (Backoffice and Web.UI projects) * Clean up unused security classes * Fix up installer route * Remove obsolete tests * Fix up DI in integration test * Add missing property mapping * Move core mapping into core * Add composers to integration test * remove identity * Fix up DI * Outcomment failing test :) * Fix up remaining test * Update mapper * Remove the actual project files * Remove backoffice cs proj * Remove old backoffice from yml * Run belissima before login * Remove caching * Refactor file paths * Remove belle from static assets * Dont refer to old project in templates * update gitignore * Add missing files * Remove install view as its no longer used * Fix up failing test * Remove outcommented code * Update submodule to latest * fix build --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -7,6 +7,7 @@ using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.Mapping;
|
||||
|
||||
@@ -20,6 +21,9 @@ public class ContentPropertyMapDefinition : IMapDefinition
|
||||
private readonly ContentPropertyBasicMapper<ContentPropertyBasic> _contentPropertyBasicConverter;
|
||||
private readonly ContentPropertyDisplayMapper _contentPropertyDisplayMapper;
|
||||
private readonly ContentPropertyDtoMapper _contentPropertyDtoConverter;
|
||||
private readonly CommonMapper _commonMapper;
|
||||
private readonly ContentBasicSavedStateMapper<ContentPropertyBasic> _basicStateMapper;
|
||||
|
||||
|
||||
public ContentPropertyMapDefinition(
|
||||
ICultureDictionary cultureDictionary,
|
||||
@@ -28,8 +32,10 @@ public class ContentPropertyMapDefinition : IMapDefinition
|
||||
ILocalizedTextService textService,
|
||||
ILoggerFactory loggerFactory,
|
||||
PropertyEditorCollection propertyEditors,
|
||||
IDataTypeConfigurationCache dataTypeConfigurationCache)
|
||||
CommonMapper commonMapper)
|
||||
{
|
||||
_commonMapper = commonMapper;
|
||||
_basicStateMapper = new ContentBasicSavedStateMapper<ContentPropertyBasic>();
|
||||
_contentPropertyBasicConverter = new ContentPropertyBasicMapper<ContentPropertyBasic>(
|
||||
dataTypeService,
|
||||
entityService,
|
||||
@@ -49,24 +55,6 @@ public class ContentPropertyMapDefinition : IMapDefinition
|
||||
propertyEditors);
|
||||
}
|
||||
|
||||
[Obsolete("Please use constructor that takes an IDataTypeConfigurationCache. Will be removed in V14.")]
|
||||
public ContentPropertyMapDefinition(
|
||||
ICultureDictionary cultureDictionary,
|
||||
IDataTypeService dataTypeService,
|
||||
IEntityService entityService,
|
||||
ILocalizedTextService textService,
|
||||
ILoggerFactory loggerFactory,
|
||||
PropertyEditorCollection propertyEditors)
|
||||
: this(
|
||||
cultureDictionary,
|
||||
dataTypeService,
|
||||
entityService,
|
||||
textService,
|
||||
loggerFactory,
|
||||
propertyEditors,
|
||||
StaticServiceProvider.Instance.GetRequiredService<IDataTypeConfigurationCache>())
|
||||
{ }
|
||||
|
||||
public void DefineMaps(IUmbracoMapper mapper)
|
||||
{
|
||||
mapper.Define<PropertyGroup, Tab<ContentPropertyDisplay>>(
|
||||
@@ -74,6 +62,8 @@ public class ContentPropertyMapDefinition : IMapDefinition
|
||||
mapper.Define<IProperty, ContentPropertyBasic>((source, context) => new ContentPropertyBasic(), Map);
|
||||
mapper.Define<IProperty, ContentPropertyDto>((source, context) => new ContentPropertyDto(), Map);
|
||||
mapper.Define<IProperty, ContentPropertyDisplay>((source, context) => new ContentPropertyDisplay(), Map);
|
||||
mapper.Define<IContent, ContentItemBasic<ContentPropertyBasic>>((source, context) => new ContentItemBasic<ContentPropertyBasic>(), Map);
|
||||
mapper.Define<IContent, ContentPropertyCollectionDto>((source, context) => new ContentPropertyCollectionDto(), Map);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Properties -Alias -Expanded
|
||||
@@ -101,4 +91,81 @@ public class ContentPropertyMapDefinition : IMapDefinition
|
||||
|
||||
// assume this is mapping everything and no MapAll is required
|
||||
_contentPropertyDisplayMapper.Map(source, target, context);
|
||||
|
||||
// Umbraco.Code.MapAll -Alias
|
||||
private void Map(IContent source, ContentItemBasic<ContentPropertyBasic> target, MapperContext context)
|
||||
{
|
||||
target.ContentTypeId = source.ContentType.Id;
|
||||
target.ContentTypeAlias = source.ContentType.Alias;
|
||||
target.CreateDate = source.CreateDate;
|
||||
target.Edited = source.Edited;
|
||||
target.Icon = source.ContentType.Icon;
|
||||
target.Id = source.Id;
|
||||
target.Key = source.Key;
|
||||
target.Name = GetName(source, context);
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Properties = context.MapEnumerable<IProperty, ContentPropertyBasic>(source.Properties).WhereNotNull();
|
||||
target.SortOrder = source.SortOrder;
|
||||
target.State = _basicStateMapper.Map(source, context);
|
||||
target.Trashed = source.Trashed;
|
||||
target.Udi =
|
||||
Udi.Create(source.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, source.Key);
|
||||
target.UpdateDate = GetUpdateDate(source, context);
|
||||
target.Updater = _commonMapper.GetCreator(source, context);
|
||||
target.VariesByCulture = source.ContentType.VariesByCulture();
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll
|
||||
private static void Map(IContent source, ContentPropertyCollectionDto target, MapperContext context) =>
|
||||
target.Properties = context.MapEnumerable<IProperty, ContentPropertyDto>(source.Properties).WhereNotNull();
|
||||
|
||||
private string? GetName(IContent source, MapperContext context)
|
||||
{
|
||||
// invariant = only 1 name
|
||||
if (!source.ContentType.VariesByCulture())
|
||||
{
|
||||
return source.Name;
|
||||
}
|
||||
|
||||
// variant = depends on culture
|
||||
var culture = context.GetCulture();
|
||||
|
||||
// if there's no culture here, the issue is somewhere else (UI, whatever) - throw!
|
||||
if (culture == null)
|
||||
{
|
||||
throw new InvalidOperationException("Missing culture in mapping options.");
|
||||
}
|
||||
|
||||
// if we don't have a name for a culture, it means the culture is not available, and
|
||||
// hey we should probably not be mapping it, but it's too late, return a fallback name
|
||||
return source.CultureInfos is not null &&
|
||||
source.CultureInfos.TryGetValue(culture, out ContentCultureInfos name) && !name.Name.IsNullOrWhiteSpace()
|
||||
? name.Name
|
||||
: $"({source.Name})";
|
||||
}
|
||||
|
||||
private DateTime GetUpdateDate(IContent source, MapperContext context)
|
||||
{
|
||||
// invariant = global date
|
||||
if (!source.ContentType.VariesByCulture())
|
||||
{
|
||||
return source.UpdateDate;
|
||||
}
|
||||
|
||||
// variant = depends on culture
|
||||
var culture = context.GetCulture();
|
||||
|
||||
// if there's no culture here, the issue is somewhere else (UI, whatever) - throw!
|
||||
if (culture == null)
|
||||
{
|
||||
throw new InvalidOperationException("Missing culture in mapping options.");
|
||||
}
|
||||
|
||||
// if we don't have a date for a culture, it means the culture is not available, and
|
||||
// hey we should probably not be mapping it, but it's too late, return a fallback date
|
||||
DateTime? date = source.GetUpdateDate(culture);
|
||||
return date ?? source.UpdateDate;
|
||||
}
|
||||
}
|
||||
|
||||
50
src/Umbraco.Core/Models/Mapping/MediaMapDefinition.cs
Normal file
50
src/Umbraco.Core/Models/Mapping/MediaMapDefinition.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.Mapping;
|
||||
|
||||
/// <summary>
|
||||
/// Declares model mappings for media.
|
||||
/// </summary>
|
||||
public class MediaMapDefinition : IMapDefinition
|
||||
{
|
||||
private readonly CommonMapper _commonMapper;
|
||||
|
||||
public MediaMapDefinition(CommonMapper commonMapper)
|
||||
{
|
||||
_commonMapper = commonMapper;
|
||||
}
|
||||
|
||||
public void DefineMaps(IUmbracoMapper mapper)
|
||||
{
|
||||
mapper.Define<IMedia, ContentPropertyCollectionDto>((source, context) => new ContentPropertyCollectionDto(), Map);
|
||||
mapper.Define<IMedia, ContentItemBasic<ContentPropertyBasic>>((source, context) => new ContentItemBasic<ContentPropertyBasic>(), Map);
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll
|
||||
private static void Map(IMedia source, ContentPropertyCollectionDto target, MapperContext context) =>
|
||||
target.Properties = context.MapEnumerable<IProperty, ContentPropertyDto>(source.Properties).WhereNotNull();
|
||||
|
||||
// Umbraco.Code.MapAll -Edited -Updater -Alias
|
||||
private void Map(IMedia source, ContentItemBasic<ContentPropertyBasic> target, MapperContext context)
|
||||
{
|
||||
target.ContentTypeId = source.ContentType.Id;
|
||||
target.ContentTypeAlias = source.ContentType.Alias;
|
||||
target.CreateDate = source.CreateDate;
|
||||
target.Icon = source.ContentType.Icon;
|
||||
target.Id = source.Id;
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Properties = context.MapEnumerable<IProperty, ContentPropertyBasic>(source.Properties).WhereNotNull();
|
||||
target.SortOrder = source.SortOrder;
|
||||
target.State = null;
|
||||
target.Trashed = source.Trashed;
|
||||
target.Udi = Udi.Create(Constants.UdiEntityType.Media, source.Key);
|
||||
target.UpdateDate = source.UpdateDate;
|
||||
target.VariesByCulture = source.ContentType.VariesByCulture();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,23 @@
|
||||
using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.Mapping;
|
||||
|
||||
/// <inheritdoc />
|
||||
public class MemberMapDefinition : IMapDefinition
|
||||
{
|
||||
private readonly CommonMapper _commonMapper;
|
||||
|
||||
public MemberMapDefinition(CommonMapper commonMapper) => _commonMapper = commonMapper;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void DefineMaps(IUmbracoMapper mapper) => mapper.Define<MemberSave, IMember>(Map);
|
||||
public void DefineMaps(IUmbracoMapper mapper)
|
||||
{
|
||||
mapper.Define<MemberSave, IMember>(Map);
|
||||
mapper.Define<IMember, MemberBasic>((source, context) => new MemberBasic(), Map);
|
||||
mapper.Define<IMember, ContentPropertyCollectionDto>((source, context) => new ContentPropertyCollectionDto(), Map);
|
||||
}
|
||||
|
||||
private static void Map(MemberSave source, IMember target, MapperContext context)
|
||||
{
|
||||
@@ -28,4 +38,36 @@ public class MemberMapDefinition : IMapDefinition
|
||||
|
||||
// TODO: add groups as required
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll -Trashed -Edited -Updater -Alias -VariesByCulture
|
||||
private void Map(IMember source, MemberBasic target, MapperContext context)
|
||||
{
|
||||
target.ContentTypeId = source.ContentType.Id;
|
||||
target.ContentTypeAlias = source.ContentType.Alias;
|
||||
target.CreateDate = source.CreateDate;
|
||||
target.Email = source.Email;
|
||||
target.Icon = source.ContentType.Icon;
|
||||
target.Id = int.MaxValue;
|
||||
target.Key = source.Key;
|
||||
target.Name = source.Name;
|
||||
target.Owner = _commonMapper.GetOwner(source, context);
|
||||
target.ParentId = source.ParentId;
|
||||
target.Path = source.Path;
|
||||
target.Properties = context.MapEnumerable<IProperty, ContentPropertyBasic>(source.Properties).WhereNotNull();
|
||||
target.SortOrder = source.SortOrder;
|
||||
target.State = null;
|
||||
target.Udi = Udi.Create(Constants.UdiEntityType.Member, source.Key);
|
||||
target.UpdateDate = source.UpdateDate;
|
||||
target.Username = source.Username;
|
||||
target.FailedPasswordAttempts = source.FailedPasswordAttempts;
|
||||
target.Approved = source.IsApproved;
|
||||
target.LockedOut = source.IsLockedOut;
|
||||
target.LastLockoutDate = source.LastLockoutDate;
|
||||
target.LastLoginDate = source.LastLoginDate;
|
||||
target.LastPasswordChangeDate = source.LastPasswordChangeDate;
|
||||
}
|
||||
|
||||
// Umbraco.Code.MapAll
|
||||
private static void Map(IMember source, ContentPropertyCollectionDto target, MapperContext context) =>
|
||||
target.Properties = context.MapEnumerable<IProperty, ContentPropertyDto>(source.Properties).WhereNotNull();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user