Skip to content

Commit

Permalink
Merge branch 'v8/dev' into temp8-4217-datatype-edits-updates-content-…
Browse files Browse the repository at this point in the history
…editor
  • Loading branch information
Stephan committed Apr 1, 2019
2 parents 054bc28 + c185672 commit 4906231
Show file tree
Hide file tree
Showing 40 changed files with 1,461 additions and 995 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 @@ -32,16 +32,27 @@ angular.module("umbraco.directives")
restrict: 'E',
scope:{
key: '@',
tokens: '='
tokens: '=',
watchTokens: '@'
},
replace: true,

link: function (scope, element, attrs) {
var key = scope.key;
var tokens = scope.tokens ? scope.tokens : null;
localizationService.localize(key, tokens).then(function(value){
element.html(value);
scope.text = "";

// A render function to be able to update tokens as values update.
function render() {
element.html(localizationService.tokenReplace(scope.text, scope.tokens || null));
}

localizationService.localize(key).then(function(value){
scope.text = value;
render();
});
if (scope.watchTokens === 'true') {
scope.$watch("tokens", render, true);
}
}
};
})
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 @@ -43,16 +43,11 @@ angular.module('umbraco.services')

var entry = dictionary[value];
if (entry) {
if (tokens) {
for (var i = 0; i < tokens.length; i++) {
entry = entry.replace("%" + i + "%", tokens[i]);
}
}
return entry;
return service.tokenReplace(entry, tokens);
}
return "[" + value + "]";
}

var service = {
// array to hold the localized resource string entries
dictionary: [],
Expand Down Expand Up @@ -127,7 +122,29 @@ angular.module('umbraco.services')
}
return value;
},



/**
* @ngdoc method
* @name umbraco.services.localizationService#tokenReplace
* @methodOf umbraco.services.localizationService
*
* @description
* Helper to replace tokens
* @param {String} value the text-string to manipulate
* @param {Array} tekens An array of tokens values
* @returns {String} Replaced test-string
*/
tokenReplace: function (text, tokens) {
if (tokens) {
for (var i = 0; i < tokens.length; i++) {
text = text.replace("%" + i + "%", tokens[i]);
}
}
return text;
},


/**
* @ngdoc method
* @name umbraco.services.localizationService#localize
Expand All @@ -146,8 +163,7 @@ angular.module('umbraco.services')
*/
localize: function (value, tokens) {
return service.initLocalizedResources().then(function (dic) {
var val = _lookup(value, tokens, dic);
return val;
return _lookup(value, tokens, dic);
});
},

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
Loading

0 comments on commit 4906231

Please sign in to comment.