V10/bugfix/variant permissions segments (#12890)

* Remove null check from MapperContext.SetCulture and .SetSegment

We need to be able to set these to null, since null = invariant / default segment

* show segment label on property

* Add ContentVariation to ContentPropertyDisplay

* Add ContentVariation to DocumentTypeDisplay

* Change variations to be on ContentTypeBasic.cs

* don't cache value

* show correct label and unlock text for culture and segment variations

* make lock overlay take up less space

Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
Mads Rasmussen
2022-08-24 16:17:56 +02:00
committed by Bjarke Berg
parent 026ece2132
commit 439878883a
15 changed files with 89 additions and 35 deletions

View File

@@ -56,6 +56,9 @@ internal class ContentPropertyDisplayMapper : ContentPropertyBasicMapper<Content
dest.HideLabel = valEditor?.HideLabel ?? false;
dest.LabelOnTop = originalProp.PropertyType?.LabelOnTop;
// Set variation, the frontend needs this to determine if the content varies by segment
dest.Variations = originalProp.PropertyType?.Variations ?? ContentVariation.Nothing;
// add the validation information
dest.Validation.Mandatory = originalProp.PropertyType?.Mandatory ?? false;
dest.Validation.MandatoryMessage = originalProp.PropertyType?.MandatoryMessage;

View File

@@ -323,6 +323,7 @@ public class ContentTypeMapDefinition : IMapDefinition
target.AllowCultureVariant = source.VariesByCulture();
target.AllowSegmentVariant = source.VariesBySegment();
target.ContentApps = _commonMapper.GetContentAppsForEntity(source);
target.Variations = source.Variations;
// sync templates
if (source.AllowedTemplates is not null)
@@ -419,6 +420,7 @@ public class ContentTypeMapDefinition : IMapDefinition
? string.Empty
: _hostingEnvironment.ToAbsolute("~/umbraco/images/thumbnails/" + source.Thumbnail);
target.UpdateDate = source.UpdateDate;
target.Variations = source.Variations;
}
// no MapAll - uses the IContentTypeBase map method, which has MapAll
@@ -751,6 +753,7 @@ public class ContentTypeMapDefinition : IMapDefinition
target.AllowedContentTypes = source.AllowedContentTypes?.OrderBy(c => c.SortOrder).Select(x => x.Id.Value);
target.CompositeContentTypes = source.ContentTypeComposition.Select(x => x.Alias);
target.LockedCompositeContentTypes = MapLockedCompositions(source);
target.Variations = source.Variations;
}
// no MapAll - relies on the non-generic method
@@ -794,6 +797,7 @@ public class ContentTypeMapDefinition : IMapDefinition
: _hostingEnvironment.ToAbsolute("~/umbraco/images/thumbnails/" + source.Thumbnail);
target.Trashed = source.Trashed;
target.Udi = source.Udi;
target.Variations = source.Variations;
}
// no MapAll - relies on the non-generic method

View File

@@ -26,24 +26,12 @@ public static class MapperContextExtensions
/// <summary>
/// Sets a context culture.
/// </summary>
public static void SetCulture(this MapperContext context, string? culture)
{
if (culture is not null)
{
context.Items[CultureKey] = culture;
}
}
public static void SetCulture(this MapperContext context, string? culture) => context.Items[CultureKey] = culture;
/// <summary>
/// Sets a context segment.
/// </summary>
public static void SetSegment(this MapperContext context, string? segment)
{
if (segment is not null)
{
context.Items[SegmentKey] = segment;
}
}
public static void SetSegment(this MapperContext context, string? segment) => context.Items[SegmentKey] = segment;
/// <summary>
/// Get included properties.