Skip to content

Commit

Permalink
Merge branch 'v8/dev' into temp8-4427-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan committed Apr 1, 2019
2 parents 118f6c7 + b0c7a7b commit 58efda6
Show file tree
Hide file tree
Showing 26 changed files with 593 additions and 144 deletions.
22 changes: 22 additions & 0 deletions src/Umbraco.Core/CompositionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ public static void SetServerMessenger(this Composition composition, IServerMesse
composition.RegisterUnique(_ => registrar);
}

/// <summary>
/// Sets the database server messenger options.
/// </summary>
/// <param name="composition">The composition.</param>
/// <param name="factory">A function creating the options.</param>
/// <remarks>Use DatabaseServerRegistrarAndMessengerComposer.GetDefaultOptions to get the options that Umbraco would use by default.</remarks>
public static void SetDatabaseServerMessengerOptions(this Composition composition, Func<IFactory, DatabaseServerMessengerOptions> factory)
{
composition.RegisterUnique(factory);
}

/// <summary>
/// Sets the database server messenger options.
/// </summary>
/// <param name="composition">The composition.</param>
/// <param name="options">Options.</param>
/// <remarks>Use DatabaseServerRegistrarAndMessengerComposer.GetDefaultOptions to get the options that Umbraco would use by default.</remarks>
public static void SetDatabaseServerMessengerOptions(this Composition composition, DatabaseServerMessengerOptions options)
{
composition.RegisterUnique(_ => options);
}

/// <summary>
/// Sets the short string helper.
/// </summary>
Expand Down
16 changes: 11 additions & 5 deletions src/Umbraco.Core/ContentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Xml.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPoco.Expressions;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Models;
Expand Down Expand Up @@ -52,8 +53,8 @@ public static ContentStatus GetStatus(this IContent content, string culture = nu
return ContentStatus.Unpublished;
}



#endregion

/// <summary>
Expand Down Expand Up @@ -134,9 +135,14 @@ public static IEnumerable<Property> GetPropertiesForGroup(this IContentBase cont
/// <summary>
/// Sets the posted file value of a property.
/// </summary>
/// <remarks>This really is for FileUpload fields only, and should be obsoleted. For anything else,
/// you need to store the file by yourself using Store and then figure out
/// how to deal with auto-fill properties (if any) and thumbnails (if any) by yourself.</remarks>
public static void SetValue(this IContentBase content, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, string propertyTypeAlias, string filename, HttpPostedFileBase postedFile, string culture = null, string segment = null)
{
content.SetValue(contentTypeBaseServiceProvider, propertyTypeAlias, postedFile.FileName, postedFile.InputStream, culture, segment);
}

/// <summary>
/// Sets the posted file value of a property.
/// </summary>
public static void SetValue(this IContentBase content, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, string propertyTypeAlias, string filename, Stream filestream, string culture = null, string segment = null)
{
if (filename == null || filestream == null) return;
Expand Down
12 changes: 6 additions & 6 deletions src/Umbraco.Core/UriExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ public static class UriExtensions
/// <returns></returns>
/// <remarks>
/// There are some special routes we need to check to properly determine this:
///
///
/// If any route has an extension in the path like .aspx = back office
///
///
/// These are def back office:
/// /Umbraco/BackOffice = back office
/// /Umbraco/Preview = back office
/// If it's not any of the above, and there's no extension then we cannot determine if it's back office or front-end
/// so we can only assume that it is not back office. This will occur if people use an UmbracoApiController for the backoffice
/// but do not inherit from UmbracoAuthorizedApiController and do not use [IsBackOffice] attribute.
///
///
/// These are def front-end:
/// /Umbraco/Surface = front-end
/// /Umbraco/Api = front-end
/// But if we've got this far we'll just have to assume it's front-end anyways.
///
///
/// </remarks>
internal static bool IsBackOfficeRequest(this Uri url, string applicationPath, IGlobalSettings globalSettings)
{
Expand Down Expand Up @@ -152,9 +152,9 @@ internal static bool IsClientSideRequest(this Uri url)
var toInclude = new[] {".aspx", ".ashx", ".asmx", ".axd", ".svc"};
return toInclude.Any(ext.InvariantEquals) == false;
}
catch (ArgumentException ex)
catch (ArgumentException)
{
Current.Logger.Error(typeof(UriExtensions), ex, "Failed to determine if request was client side");
Current.Logger.Debug(typeof(UriExtensions), "Failed to determine if request was client side (invalid chars in path \"{Path}\"?)", url.LocalPath);
return false;
}
}
Expand Down
89 changes: 89 additions & 0 deletions src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Umbraco.Web.PublishedCache;
using Umbraco.Core.Composing;
using Moq;
using Newtonsoft.Json;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
Expand All @@ -32,6 +33,8 @@ public class PublishedContentTests : PublishedContentTestBase
protected override void Compose()
{
base.Compose();
_publishedSnapshotAccessorMock = new Mock<IPublishedSnapshotAccessor>();
Composition.RegisterUnique<IPublishedSnapshotAccessor>(_publishedSnapshotAccessorMock.Object);

Composition.RegisterUnique<IPublishedModelFactory>(f => new PublishedModelFactory(f.GetInstance<TypeLoader>().GetTypes<PublishedContentModel>()));
Composition.RegisterUnique<IPublishedContentTypeFactory, PublishedContentTypeFactory>();
Expand Down Expand Up @@ -87,6 +90,7 @@ protected override TypeLoader CreateTypeLoader(IAppPolicyCache runtimeCache, IGl
}

private readonly Guid _node1173Guid = Guid.NewGuid();
private Mock<IPublishedSnapshotAccessor> _publishedSnapshotAccessorMock;

protected override string GetXmlContent(int templateId)
{
Expand Down Expand Up @@ -792,6 +796,91 @@ public void IsDescendantOrSelf()
Assert.IsTrue(customDoc3.IsDescendantOrSelf(customDoc3));
}

[Test]
public void SiblingsAndSelf()
{
// Structure:
// - Root : 1046 (no parent)
// -- Level1.1: 1173 (parent 1046)
// --- Level1.1.1: 1174 (parent 1173)
// --- Level1.1.2: 117 (parent 1173)
// --- Level1.1.3: 1177 (parent 1173)
// --- Level1.1.4: 1178 (parent 1173)
// --- Level1.1.5: 1176 (parent 1173)
// -- Level1.2: 1175 (parent 1046)
// -- Level1.3: 4444 (parent 1046)
var root = GetNode(1046);
var level1_1 = GetNode(1173);
var level1_1_1 = GetNode(1174);
var level1_1_2 = GetNode(117);
var level1_1_3 = GetNode(1177);
var level1_1_4 = GetNode(1178);
var level1_1_5 = GetNode(1176);
var level1_2 = GetNode(1175);
var level1_3 = GetNode(4444);

_publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot.Content.GetAtRoot()).Returns(new []{root});

CollectionAssertAreEqual(new []{root}, root.SiblingsAndSelf());

CollectionAssertAreEqual( new []{level1_1, level1_2, level1_3}, level1_1.SiblingsAndSelf());
CollectionAssertAreEqual( new []{level1_1, level1_2, level1_3}, level1_2.SiblingsAndSelf());
CollectionAssertAreEqual( new []{level1_1, level1_2, level1_3}, level1_3.SiblingsAndSelf());

CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_4, level1_1_5}, level1_1_1.SiblingsAndSelf());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_4, level1_1_5}, level1_1_2.SiblingsAndSelf());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_4, level1_1_5}, level1_1_3.SiblingsAndSelf());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_4, level1_1_5}, level1_1_4.SiblingsAndSelf());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_4, level1_1_5}, level1_1_5.SiblingsAndSelf());

}

[Test]
public void Siblings()
{
// Structure:
// - Root : 1046 (no parent)
// -- Level1.1: 1173 (parent 1046)
// --- Level1.1.1: 1174 (parent 1173)
// --- Level1.1.2: 117 (parent 1173)
// --- Level1.1.3: 1177 (parent 1173)
// --- Level1.1.4: 1178 (parent 1173)
// --- Level1.1.5: 1176 (parent 1173)
// -- Level1.2: 1175 (parent 1046)
// -- Level1.3: 4444 (parent 1046)
var root = GetNode(1046);
var level1_1 = GetNode(1173);
var level1_1_1 = GetNode(1174);
var level1_1_2 = GetNode(117);
var level1_1_3 = GetNode(1177);
var level1_1_4 = GetNode(1178);
var level1_1_5 = GetNode(1176);
var level1_2 = GetNode(1175);
var level1_3 = GetNode(4444);

_publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot.Content.GetAtRoot()).Returns(new []{root});

CollectionAssertAreEqual(new IPublishedContent[0], root.Siblings());

CollectionAssertAreEqual( new []{level1_2, level1_3}, level1_1.Siblings());
CollectionAssertAreEqual( new []{level1_1, level1_3}, level1_2.Siblings());
CollectionAssertAreEqual( new []{level1_1, level1_2}, level1_3.Siblings());

CollectionAssertAreEqual( new []{ level1_1_2, level1_1_3, level1_1_4, level1_1_5}, level1_1_1.Siblings());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_3, level1_1_4, level1_1_5}, level1_1_2.Siblings());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_4, level1_1_5}, level1_1_3.Siblings());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_5}, level1_1_4.Siblings());
CollectionAssertAreEqual( new []{level1_1_1, level1_1_2, level1_1_3, level1_1_4}, level1_1_5.Siblings());

}

private void CollectionAssertAreEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
where T: IPublishedContent
{
var e = expected.Select(x => x.Id);
var a = actual.Select(x => x.Id);
CollectionAssert.AreEquivalent(e, a, $"\nExpected:\n{string.Join(", ", e)}\n\nActual:\n{string.Join(", ", a)}");
}

[Test]
public void FragmentProperty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function valPropertyMsg(serverValidationManager) {
if (!watcher) {
watcher = scope.$watch("currentProperty.value",
function (newValue, oldValue) {

if (!newValue || angular.equals(newValue, oldValue)) {
if (angular.equals(newValue, oldValue)) {
return;
}

Expand All @@ -78,10 +78,12 @@ function valPropertyMsg(serverValidationManager) {
// based on other errors. We'll also check if there's no other validation errors apart from valPropertyMsg, if valPropertyMsg
// is the only one, then we'll clear.

if ((errCount === 1 && angular.isArray(formCtrl.$error.valPropertyMsg)) || (formCtrl.$invalid && angular.isArray(formCtrl.$error.valServer))) {
if (errCount === 0 || (errCount === 1 && angular.isArray(formCtrl.$error.valPropertyMsg)) || (formCtrl.$invalid && angular.isArray(formCtrl.$error.valServer))) {
scope.errorMsg = "";
formCtrl.$setValidity('valPropertyMsg', true);
stopWatch();
} else if (showValidation && scope.errorMsg === "") {
formCtrl.$setValidity('valPropertyMsg', false);
scope.errorMsg = getErrorMsg();
}
}, true);
}
Expand Down Expand Up @@ -152,6 +154,7 @@ function valPropertyMsg(serverValidationManager) {
showValidation = true;
if (hasError && scope.errorMsg === "") {
scope.errorMsg = getErrorMsg();
startWatch();
}
else if (!hasError) {
scope.errorMsg = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ angular.module('umbraco.services')
nArray.push(item);

if(!item.sticky) {
$timeout(function() {
var found = _.find(nArray, function(i) {
return i.id === item.id;
});

if (found) {
var index = nArray.indexOf(found);
nArray.splice(index, 1);
}

}, 7000);
$timeout(
function() {
var found = _.find(nArray, function(i) {
return i.id === item.id;
});
if (found) {
var index = nArray.indexOf(found);
nArray.splice(index, 1);
}
}
, 10000);
}

return item;
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI.Client/src/less/belle.less
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
@import "components/umb-iconpicker.less";
@import "components/umb-insert-code-box.less";
@import "components/umb-packages.less";
@import "components/umb-logviewer.less";
@import "components/umb-package-local-install.less";
@import "components/umb-panel-group.less";
@import "components/umb-lightbox.less";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
font-size: 14px;
border: none;
position: relative;
margin-bottom: 0;
border-radius: 10px;
margin: 10px;

.close {
top: 0;
right: -6px;
opacity: 0.4;
}
}

.umb-notifications__notification.-extra-padding {
Expand Down
42 changes: 42 additions & 0 deletions src/Umbraco.Web.UI.Client/src/less/components/umb-logviewer.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* PACKAGE DETAILS */

.umb-logviewer {
display: flex;
flex-flow: row wrap;
}

@sidebarwidth: 350px; // Width of sidebar. Ugly hack because of old version of Less

.umb-logviewer__main-content {
flex: 1 1 auto;
margin-right: 20px;
width: calc(~'100%' - ~'@{sidebarwidth}' - ~'20px'); // Make sure that the main content area doesn't gets affected by inline styling
min-width: 500px;

.btn-link {
text-align: left;
}
}

.umb-logviewer__sidebar {
flex: 0 0 @sidebarwidth;
}

@media (max-width: 768px) {

.umb-logviewer {
flex-direction: column;
}

.umb-logviewer__main-content {
flex: 1 1 auto;
width: 100%;
margin-bottom: 30px;
margin-right: 0;
}

.umb-logviewer__sidebar {
flex: 1 1 auto;
width: 100%;
}
}
12 changes: 11 additions & 1 deletion src/Umbraco.Web.UI.Client/src/less/modals.less
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@
bottom: 0px;
left: 0px;
right: 0px;
position: absolute;;
position: absolute;
}

.--notInFront .umb-modalcolumn::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
background: rgba(0,0,0,.4);
}

/* re-align loader */
Expand Down
Loading

0 comments on commit 58efda6

Please sign in to comment.