Merge branch 'netcore/dev' into temp-7667
This commit is contained in:
@@ -43,6 +43,8 @@ If you only see a build.bat-file, you're probably on the wrong branch. If you sw
|
||||
|
||||
You might run into [Powershell quirks](#powershell-quirks).
|
||||
|
||||
If it runs without errors; Hooray! Now you can continue with [the next step](CONTRIBUTING.md#how-do-i-begin) and open the solution and build it.
|
||||
|
||||
### Build Infrastructure
|
||||
|
||||
The Umbraco Build infrastructure relies on a PowerShell object. The object can be retrieved with:
|
||||
|
||||
@@ -28,7 +28,7 @@ This project and everyone participating in it, is governed by the [our Code of C
|
||||
[Working with the code](#working-with-the-code)
|
||||
* [Building Umbraco from source code](#building-umbraco-from-source-code)
|
||||
* [Working with the source code](#working-with-the-source-code)
|
||||
* [Making changes after the PR was opened](#making-changes-after-the-pr-was-opened)
|
||||
* [Making changes after the PR is open](#making-changes-after-the-pr-is-open)
|
||||
* [Which branch should I target for my contributions?](#which-branch-should-i-target-for-my-contributions)
|
||||
* [Keeping your Umbraco fork in sync with the main repository](#keeping-your-umbraco-fork-in-sync-with-the-main-repository)
|
||||
|
||||
@@ -65,7 +65,7 @@ Great question! The short version goes like this:
|
||||
* **Change** - make your changes, experiment, have fun, explore and learn, and don't be afraid. We welcome all contributions and will [happily give feedback](#questions)
|
||||
* **Commit** - done? Yay! 🎉 **Important:** create a new branch now and name it after the issue you're fixing, we usually follow the format: `temp-12345`. This means it's a temporary branch for the particular issue you're working on, in this case `12345`. When you have a branch, commit your changes. Don't commit to `v8/contrib`, create a new branch first.
|
||||
* **Push** - great, now you can push the changes up to your fork on GitHub
|
||||
* **Create pull request** - exciting! You're ready to show us your changes (or not quite ready, you just need some feedback to progress - you can now make use of GitHub's draft pull request status, detailed [here] (https://github.blog/2019-02-14-introducing-draft-pull-requests/)). GitHub has picked up on the new branch you've pushed and will offer to create a Pull Request. Click that green button and away you go.
|
||||
* **Create pull request** - exciting! You're ready to show us your changes (or not quite ready, you just need some feedback to progress - you can now make use of GitHub's draft pull request status, detailed [here](https://github.blog/2019-02-14-introducing-draft-pull-requests/)). GitHub has picked up on the new branch you've pushed and will offer to create a Pull Request. Click that green button and away you go.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -10,6 +11,7 @@ namespace Umbraco.Core.Configuration
|
||||
public IHostingSettings HostingSettings { get; } = new HostingSettings();
|
||||
|
||||
public ICoreDebug CoreDebug { get; } = new CoreDebug();
|
||||
public IMachineKeyConfig MachineKeyConfig { get; } = new MachineKeyConfig();
|
||||
|
||||
public IUmbracoSettingsSection UmbracoSettings { get; }
|
||||
|
||||
@@ -27,6 +29,7 @@ namespace Umbraco.Core.Configuration
|
||||
configs.AddPasswordConfigurations();
|
||||
|
||||
configs.Add(() => CoreDebug);
|
||||
configs.Add(() => MachineKeyConfig);
|
||||
configs.Add<IConnectionStrings>(() => new ConnectionStrings(ioHelper));
|
||||
configs.AddCoreConfigs(ioHelper);
|
||||
return configs;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Configuration
|
||||
{
|
||||
public class MachineKeyConfig : IMachineKeyConfig
|
||||
{
|
||||
//TODO all the machineKey stuff should be replaced: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey?view=aspnetcore-3.1
|
||||
|
||||
public bool HasMachineKey
|
||||
{
|
||||
get
|
||||
{
|
||||
var machineKeySection =
|
||||
ConfigurationManager.GetSection("system.web/machineKey") as ConfigurationSection;
|
||||
return !(machineKeySection?.ElementInformation?.Source is null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Web.Cache
|
||||
{
|
||||
macroRepoCache.Result.Clear(RepositoryCacheKeys.GetKey<IMacro>(payload.Id));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
base.Refresh(json);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Umbraco.Core.Collections
|
||||
if (_items.TryGetValue(key, out value))
|
||||
yield return value;
|
||||
else if (throwOnMissing)
|
||||
throw new Exception(MissingDependencyError);
|
||||
throw new Exception($"{MissingDependencyError} Error in type {typeof(TItem).Name}, with key {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,12 @@ namespace Umbraco.Core.Composing
|
||||
foreach (var type in types)
|
||||
EnsureType(type, "register");
|
||||
|
||||
// register them
|
||||
// register them - ensuring that each item is registered with the same lifetime as the collection.
|
||||
// NOTE: Previously each one was not registered with the same lifetime which would mean that if there
|
||||
// was a dependency on an individual item, it would resolve a brand new transient instance which isn't what
|
||||
// we would expect to happen. The same item should be resolved from the container as the collection.
|
||||
foreach (var type in types)
|
||||
register.Register(type);
|
||||
register.Register(type, CollectionLifetime);
|
||||
|
||||
_registeredTypes = types;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IMachineKeyConfig
|
||||
{
|
||||
bool HasMachineKey { get;}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Core
|
||||
|
||||
public void AddDateTime(DateTime d)
|
||||
{
|
||||
_writer.Write(d.Ticks);;
|
||||
_writer.Write(d.Ticks);
|
||||
}
|
||||
|
||||
public void AddString(string s)
|
||||
|
||||
@@ -22,11 +22,6 @@ namespace Umbraco.Core.Hosting
|
||||
string MapPath(string path);
|
||||
string ToAbsolute(string virtualPath, string root);
|
||||
|
||||
/// <summary>
|
||||
/// Terminates the current application. The application restarts the next time a request is received for it.
|
||||
/// </summary>
|
||||
void LazyRestartApplication();
|
||||
|
||||
void RegisterObject(IRegisteredObject registeredObject);
|
||||
void UnregisterObject(IRegisteredObject registeredObject);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
{
|
||||
@@ -13,13 +14,13 @@ namespace Umbraco.Core.Manifest
|
||||
private static volatile bool _isRestarting;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
|
||||
private readonly List<FileSystemWatcher> _fws = new List<FileSystemWatcher>();
|
||||
|
||||
public ManifestWatcher(ILogger logger, IHostingEnvironment hostingEnvironment)
|
||||
public ManifestWatcher(ILogger logger, IUmbracoApplicationLifetime umbracoApplicationLifetime)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_umbracoApplicationLifetime = umbracoApplicationLifetime;
|
||||
}
|
||||
|
||||
public void Start(params string[] packageFolders)
|
||||
@@ -57,7 +58,7 @@ namespace Umbraco.Core.Manifest
|
||||
|
||||
_isRestarting = true;
|
||||
_logger.Info<ManifestWatcher>("Manifest has changed, app pool is restarting ({Path})", e.FullPath);
|
||||
_hostingEnvironment.LazyRestartApplication();
|
||||
_umbracoApplicationLifetime.Restart();
|
||||
Dispose(); // uh? if the app restarts then this should be disposed anyways?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Umbraco.Web.Models
|
||||
/// <summary>
|
||||
/// The model used when rendering Partial View Macros
|
||||
/// </summary>
|
||||
public class PartialViewMacroModel
|
||||
public class PartialViewMacroModel : IContentModel
|
||||
{
|
||||
|
||||
public PartialViewMacroModel(IPublishedContent page,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Umbraco.Net
|
||||
{
|
||||
public interface IUmbracoApplicationLifetime
|
||||
{
|
||||
/// <summary>
|
||||
/// A value indicating whether the application is restarting after the current request.
|
||||
/// </summary>
|
||||
bool IsRestarting { get; }
|
||||
/// <summary>
|
||||
/// Terminates the current application. The application restarts the next time a request is received for it.
|
||||
/// </summary>
|
||||
void Restart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Umbraco.Net
|
||||
{
|
||||
public interface IUserAgentProvider
|
||||
{
|
||||
string GetUserAgent();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.Packaging
|
||||
{
|
||||
public class ConflictingPackageData
|
||||
public class ConflictingPackageData
|
||||
{
|
||||
private readonly IMacroService _macroService;
|
||||
private readonly IFileService _fileService;
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Packaging
|
||||
return stylesheetNodes
|
||||
.Select(n =>
|
||||
{
|
||||
var xElement = n.Element("Name") ?? n.Element("name"); ;
|
||||
var xElement = n.Element("Name") ?? n.Element("name");
|
||||
if (xElement == null)
|
||||
throw new FormatException("Missing \"Name\" element");
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models.Packaging
|
||||
/// <remarks>
|
||||
/// This is used only for conversions and will not 'get' a PackageDefinition from the repository with a valid ID
|
||||
/// </remarks>
|
||||
internal static PackageDefinition FromCompiledPackage(CompiledPackage compiled)
|
||||
public static PackageDefinition FromCompiledPackage(CompiledPackage compiled)
|
||||
{
|
||||
return new PackageDefinition
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Core.Packaging
|
||||
{
|
||||
var packagesXml = EnsureStorage(out _);
|
||||
if (packagesXml?.Root == null)
|
||||
yield break;;
|
||||
yield break;
|
||||
|
||||
foreach (var packageXml in packagesXml.Root.Elements("package"))
|
||||
yield return _parser.ToPackageDefinition(packageXml);
|
||||
@@ -518,7 +518,6 @@ namespace Umbraco.Core.Packaging
|
||||
private XElement GetStylesheetXml(string name, bool includeProperties)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
|
||||
;
|
||||
var sts = _fileService.GetStylesheetByName(name);
|
||||
if (sts == null) return null;
|
||||
var stylesheetXml = new XElement("Stylesheet");
|
||||
|
||||
@@ -51,7 +51,10 @@ namespace Umbraco.Core.Services
|
||||
IEnumerable<TItem> GetComposedOf(int id); // composition axis
|
||||
|
||||
IEnumerable<TItem> GetChildren(int id);
|
||||
IEnumerable<TItem> GetChildren(Guid id);
|
||||
|
||||
bool HasChildren(int id);
|
||||
bool HasChildren(Guid id);
|
||||
|
||||
void Save(TItem item, int userId = Constants.Security.SuperUserId);
|
||||
void Save(IEnumerable<TItem> items, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public static class UmbracoContextAccessorExtensions
|
||||
{
|
||||
public static IUmbracoContext GetRequiredUmbracoContext(this IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
if (umbracoContextAccessor == null) throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
|
||||
var umbracoContext = umbracoContextAccessor.UmbracoContext;
|
||||
|
||||
if(umbracoContext is null) throw new InvalidOperationException("UmbracoContext is null");
|
||||
|
||||
return umbracoContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ namespace Umbraco.Core.Xml
|
||||
var child = parent.SelectSingleNode(name);
|
||||
if (child != null)
|
||||
{
|
||||
child.InnerXml = "<![CDATA[" + value + "]]>"; ;
|
||||
child.InnerXml = "<![CDATA[" + value + "]]>";
|
||||
return child;
|
||||
}
|
||||
return AddCDataNode(xd, name, value);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Core.Compose
|
||||
{
|
||||
@@ -12,18 +13,18 @@ namespace Umbraco.Core.Compose
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
|
||||
|
||||
// if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for
|
||||
// package.manifest chances and restarts the application on any change
|
||||
private ManifestWatcher _mw;
|
||||
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger, IIOHelper ioHelper, IHostingEnvironment hostingEnvironment)
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger, IIOHelper ioHelper, IUmbracoApplicationLifetime umbracoApplicationLifetime)
|
||||
{
|
||||
_runtimeState = runtimeState;
|
||||
_logger = logger;
|
||||
_ioHelper = ioHelper;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_umbracoApplicationLifetime = umbracoApplicationLifetime;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Core.Compose
|
||||
var appPlugins = _ioHelper.MapPath("~/App_Plugins/");
|
||||
if (Directory.Exists(appPlugins) == false) return;
|
||||
|
||||
_mw = new ManifestWatcher(_logger, _hostingEnvironment);
|
||||
_mw = new ManifestWatcher(_logger, _umbracoApplicationLifetime);
|
||||
_mw.Start(Directory.GetDirectories(appPlugins));
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,18 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
public interface IPublishedContentQuery
|
||||
{
|
||||
|
||||
|
||||
|
||||
IPublishedContent Content(int id);
|
||||
IPublishedContent Content(Guid id);
|
||||
IPublishedContent Content(Udi id);
|
||||
IPublishedContent Content(object id);
|
||||
IPublishedContent ContentSingleAtXPath(string xpath, params XPathVariable[] vars);
|
||||
IEnumerable<IPublishedContent> Content(IEnumerable<int> ids);
|
||||
IEnumerable<IPublishedContent> Content(IEnumerable<Guid> ids);
|
||||
|
||||
IEnumerable<IPublishedContent> Content(IEnumerable<object> ids);
|
||||
IEnumerable<IPublishedContent> ContentAtXPath(string xpath, params XPathVariable[] vars);
|
||||
IEnumerable<IPublishedContent> ContentAtXPath(XPathExpression xpath, params XPathVariable[] vars);
|
||||
IEnumerable<IPublishedContent> ContentAtRoot();
|
||||
@@ -26,7 +32,10 @@ namespace Umbraco.Web
|
||||
IPublishedContent Media(int id);
|
||||
IPublishedContent Media(Guid id);
|
||||
IPublishedContent Media(Udi id);
|
||||
|
||||
IPublishedContent Media(object id);
|
||||
IEnumerable<IPublishedContent> Media(IEnumerable<int> ids);
|
||||
IEnumerable<IPublishedContent> Media(IEnumerable<object> ids);
|
||||
IEnumerable<IPublishedContent> Media(IEnumerable<Guid> ids);
|
||||
IEnumerable<IPublishedContent> MediaAtRoot();
|
||||
|
||||
|
||||
+19
-30
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Cookie;
|
||||
@@ -11,9 +10,9 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Migrations.Install;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install
|
||||
@@ -22,25 +21,28 @@ namespace Umbraco.Web.Install
|
||||
{
|
||||
private static HttpClient _httpClient;
|
||||
private readonly DatabaseBuilder _databaseBuilder;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
private readonly IConnectionStrings _connectionStrings;
|
||||
private readonly IInstallationService _installationService;
|
||||
private readonly ICookieManager _cookieManager;
|
||||
private readonly IUserAgentProvider _userAgentProvider;
|
||||
private readonly IUmbracoDatabaseFactory _umbracoDatabaseFactory;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private InstallationType? _installationType;
|
||||
|
||||
public InstallHelper(IHttpContextAccessor httpContextAccessor,
|
||||
DatabaseBuilder databaseBuilder,
|
||||
public InstallHelper(DatabaseBuilder databaseBuilder,
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoVersion umbracoVersion,
|
||||
IConnectionStrings connectionStrings,
|
||||
IInstallationService installationService,
|
||||
ICookieManager cookieManager)
|
||||
ICookieManager cookieManager,
|
||||
IUserAgentProvider userAgentProvider,
|
||||
IUmbracoDatabaseFactory umbracoDatabaseFactory,
|
||||
IJsonSerializer jsonSerializer)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_logger = logger;
|
||||
_globalSettings = globalSettings;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
@@ -48,6 +50,9 @@ namespace Umbraco.Web.Install
|
||||
_connectionStrings = connectionStrings ?? throw new ArgumentNullException(nameof(connectionStrings));
|
||||
_installationService = installationService;
|
||||
_cookieManager = cookieManager;
|
||||
_userAgentProvider = userAgentProvider;
|
||||
_umbracoDatabaseFactory = umbracoDatabaseFactory;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
}
|
||||
|
||||
public InstallationType GetInstallationType()
|
||||
@@ -57,11 +62,9 @@ namespace Umbraco.Web.Install
|
||||
|
||||
public async Task InstallStatus(bool isCompleted, string errorMsg)
|
||||
{
|
||||
|
||||
var httpContext = _httpContextAccessor.GetRequiredHttpContext();
|
||||
try
|
||||
{
|
||||
var userAgent = httpContext.Request.UserAgent;
|
||||
var userAgent = _userAgentProvider.GetUserAgent();
|
||||
|
||||
// Check for current install Id
|
||||
var installId = Guid.NewGuid();
|
||||
@@ -88,7 +91,7 @@ namespace Umbraco.Web.Install
|
||||
{
|
||||
// we don't have DatabaseProvider anymore... doing it differently
|
||||
//dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
|
||||
dbProvider = GetDbProviderString(Current.SqlContext);
|
||||
dbProvider = _umbracoDatabaseFactory.SqlContext.SqlSyntax.DbProvider;
|
||||
}
|
||||
|
||||
var installLog = new InstallLog(installId: installId, isUpgrade: IsBrandNewInstall == false,
|
||||
@@ -105,23 +108,6 @@ namespace Umbraco.Web.Install
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetDbProviderString(ISqlContext sqlContext)
|
||||
{
|
||||
var dbProvider = string.Empty;
|
||||
|
||||
// we don't have DatabaseProvider anymore...
|
||||
//dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
|
||||
//
|
||||
// doing it differently
|
||||
var syntax = sqlContext.SqlSyntax;
|
||||
if (syntax is SqlCeSyntaxProvider)
|
||||
dbProvider = "SqlServerCE";
|
||||
else if (syntax is SqlServerSyntaxProvider)
|
||||
dbProvider = (syntax as SqlServerSyntaxProvider).ServerVersion.IsAzure ? "SqlAzure" : "SqlServer";
|
||||
|
||||
return dbProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this is a brand new install meaning that there is no configured version and there is no configured database connection
|
||||
/// </summary>
|
||||
@@ -162,7 +148,10 @@ namespace Umbraco.Web.Install
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
|
||||
{
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
packages = response.Content.ReadAsAsync<IEnumerable<Package>>().Result.ToList();
|
||||
|
||||
|
||||
var json = response.Content.ReadAsStringAsync().Result;
|
||||
packages = _jsonSerializer.Deserialize<IEnumerable<Package>>(json).ToList();
|
||||
}
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
+7
-6
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Configuration;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Install.Models;
|
||||
@@ -12,13 +12,15 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
"ConfigureMachineKey", "machinekey", 2,
|
||||
"Updating some security settings...",
|
||||
PerformsAppRestart = true)]
|
||||
internal class ConfigureMachineKey : InstallSetupStep<bool?>
|
||||
public class ConfigureMachineKey : InstallSetupStep<bool?>
|
||||
{
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IMachineKeyConfig _machineKeyConfig;
|
||||
|
||||
public ConfigureMachineKey(IIOHelper ioHelper)
|
||||
public ConfigureMachineKey(IIOHelper ioHelper, IMachineKeyConfig machineKeyConfig)
|
||||
{
|
||||
_ioHelper = ioHelper;
|
||||
_machineKeyConfig = machineKeyConfig;
|
||||
}
|
||||
|
||||
public override string View => HasMachineKey() == false ? base.View : "";
|
||||
@@ -27,10 +29,9 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
/// Don't display the view or execute if a machine key already exists
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static bool HasMachineKey()
|
||||
private bool HasMachineKey()
|
||||
{
|
||||
var section = (MachineKeySection) WebConfigurationManager.GetSection("system.web/machineKey");
|
||||
return section.ElementInformation.Source != null;
|
||||
return _machineKeyConfig.HasMachineKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
+6
-19
@@ -1,44 +1,31 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Cache;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Install.Models;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
{
|
||||
[InstallSetupStep(InstallationType.NewInstall | InstallationType.Upgrade,
|
||||
"UmbracoVersion", 50, "Installation is complete!, get ready to be redirected to your new CMS.",
|
||||
"UmbracoVersion", 50, "Installation is complete! Get ready to be redirected to your new CMS.",
|
||||
PerformsAppRestart = true)]
|
||||
internal class SetUmbracoVersionStep : InstallSetupStep<object>
|
||||
public class SetUmbracoVersionStep : InstallSetupStep<object>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly InstallHelper _installHelper;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public SetUmbracoVersionStep(IHttpContextAccessor httpContextAccessor, InstallHelper installHelper, IGlobalSettings globalSettings, IUserService userService, IUmbracoVersion umbracoVersion, IIOHelper ioHelper)
|
||||
public SetUmbracoVersionStep(IUmbracoContextAccessor umbracoContextAccessor, InstallHelper installHelper, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_installHelper = installHelper;
|
||||
_globalSettings = globalSettings;
|
||||
_userService = userService;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
public override Task<InstallSetupResult> ExecuteAsync(object model)
|
||||
{
|
||||
var security = new WebSecurity(_httpContextAccessor, _userService, _globalSettings, _ioHelper);
|
||||
|
||||
var security = _umbracoContextAccessor.GetRequiredUmbracoContext().Security;
|
||||
if (security.IsAuthenticated() == false && _globalSettings.ConfigurationStatus.IsNullOrWhiteSpace())
|
||||
{
|
||||
security.PerformLogin(-1);
|
||||
+5
-5
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
@@ -20,14 +18,16 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
private readonly InstallHelper _installHelper;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
|
||||
private readonly IContentService _contentService;
|
||||
private readonly IPackagingService _packageService;
|
||||
|
||||
public StarterKitDownloadStep(IContentService contentService, IPackagingService packageService, InstallHelper installHelper, IUmbracoContextAccessor umbracoContextAccessor, IUmbracoVersion umbracoVersion)
|
||||
public StarterKitDownloadStep(IContentService contentService, IPackagingService packageService, InstallHelper installHelper, IUmbracoContextAccessor umbracoContextAccessor, IUmbracoVersion umbracoVersion, IUmbracoApplicationLifetime umbracoApplicationLifetime)
|
||||
{
|
||||
_installHelper = installHelper;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
_umbracoApplicationLifetime = umbracoApplicationLifetime;
|
||||
_contentService = contentService;
|
||||
_packageService = packageService;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
var (packageFile, packageId) = await DownloadPackageFilesAsync(starterKitId.Value);
|
||||
|
||||
UmbracoApplication.Restart();
|
||||
_umbracoApplicationLifetime.Restart();
|
||||
|
||||
return new InstallSetupResult(new Dictionary<string, object>
|
||||
{
|
||||
+7
-6
@@ -2,9 +2,8 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Net;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
@@ -14,13 +13,13 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
PerformsAppRestart = true)]
|
||||
internal class StarterKitInstallStep : InstallSetupStep<object>
|
||||
{
|
||||
private readonly IHttpContextAccessor _httContextAccessor;
|
||||
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IPackagingService _packagingService;
|
||||
|
||||
public StarterKitInstallStep(IHttpContextAccessor httContextAccessor, IUmbracoContextAccessor umbracoContextAccessor, IPackagingService packagingService)
|
||||
public StarterKitInstallStep(IUmbracoApplicationLifetime umbracoApplicationLifetime, IUmbracoContextAccessor umbracoContextAccessor, IPackagingService packagingService)
|
||||
{
|
||||
_httContextAccessor = httContextAccessor;
|
||||
_umbracoApplicationLifetime = umbracoApplicationLifetime;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_packagingService = packagingService;
|
||||
}
|
||||
@@ -34,7 +33,9 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
InstallBusinessLogic(packageId);
|
||||
|
||||
UmbracoApplication.Restart(_httContextAccessor.GetRequiredHttpContext());
|
||||
_umbracoApplicationLifetime.Restart();
|
||||
|
||||
|
||||
|
||||
return Task.FromResult<InstallSetupResult>(null);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace Umbraco.Web.Media.Exif
|
||||
public ExifBitConverter(ByteOrder from, ByteOrder to)
|
||||
: base(from, to)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Umbraco.Web.Media.Exif
|
||||
public ExifEnumProperty(ExifTag tag, T value)
|
||||
: this(tag, value, false)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public override ExifInterOperability Interoperability
|
||||
@@ -210,13 +210,13 @@ namespace Umbraco.Web.Media.Exif
|
||||
public ExifPointSubjectArea(ExifTag tag, ushort[] value)
|
||||
: base(tag, value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public ExifPointSubjectArea(ExifTag tag, ushort x, ushort y)
|
||||
: base(tag, new ushort[] { x, y })
|
||||
: base(tag, new ushort[] {x, y})
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,13 +239,13 @@ namespace Umbraco.Web.Media.Exif
|
||||
public ExifCircularSubjectArea(ExifTag tag, ushort[] value)
|
||||
: base(tag, value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public ExifCircularSubjectArea(ExifTag tag, ushort x, ushort y, ushort d)
|
||||
: base(tag, new ushort[] { x, y, d })
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,13 +269,13 @@ namespace Umbraco.Web.Media.Exif
|
||||
public ExifRectangularSubjectArea(ExifTag tag, ushort[] value)
|
||||
: base(tag, value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public ExifRectangularSubjectArea(ExifTag tag, ushort x, ushort y, ushort w, ushort h)
|
||||
: base(tag, new ushort[] { x, y, w, h })
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,13 +303,13 @@ namespace Umbraco.Web.Media.Exif
|
||||
public GPSLatitudeLongitude(ExifTag tag, MathEx.UFraction32[] value)
|
||||
: base(tag, value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public GPSLatitudeLongitude(ExifTag tag, float d, float m, float s)
|
||||
: base(tag, new MathEx.UFraction32[] { new MathEx.UFraction32(d), new MathEx.UFraction32(m), new MathEx.UFraction32(s) })
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,13 +331,13 @@ namespace Umbraco.Web.Media.Exif
|
||||
public GPSTimeStamp(ExifTag tag, MathEx.UFraction32[] value)
|
||||
: base(tag, value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public GPSTimeStamp(ExifTag tag, float h, float m, float s)
|
||||
: base(tag, new MathEx.UFraction32[] { new MathEx.UFraction32(h), new MathEx.UFraction32(m), new MathEx.UFraction32(s) })
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Web.Media.Exif
|
||||
public JFIFVersion(ExifTag tag, ushort value)
|
||||
: base(tag, value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
public JPEGSection(JPEGMarker marker)
|
||||
: this(marker, new byte[0], new byte[0])
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -403,37 +403,37 @@ namespace Umbraco.Web.Media.Exif
|
||||
public Fraction32(int numerator, int denominator)
|
||||
: this(numerator, denominator, 0)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public Fraction32(int numerator)
|
||||
: this(numerator, (int)1)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public Fraction32(Fraction32 f)
|
||||
: this(f.Numerator, f.Denominator, f.Error)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public Fraction32(float value)
|
||||
: this((double)value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public Fraction32(double value)
|
||||
: this(FromDouble(value))
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public Fraction32(string s)
|
||||
: this(FromString(s))
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1033,37 +1033,37 @@ namespace Umbraco.Web.Media.Exif
|
||||
public UFraction32(uint numerator, uint denominator)
|
||||
: this(numerator, denominator, 0)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public UFraction32(uint numerator)
|
||||
: this(numerator, (uint)1)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public UFraction32(UFraction32 f)
|
||||
: this(f.Numerator, f.Denominator, f.Error)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public UFraction32(float value)
|
||||
: this((double)value)
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public UFraction32(double value)
|
||||
: this(FromDouble(value))
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public UFraction32(string s)
|
||||
: this(FromString(s))
|
||||
{
|
||||
;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
if (string.IsNullOrEmpty(dataType.Configuration))
|
||||
{
|
||||
config.Format = "YYYY-MM-DD";
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -158,7 +158,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
protected override void PersistUpdatedItem(IMacro entity)
|
||||
{
|
||||
entity.UpdatingEntity();
|
||||
;
|
||||
var dto = MacroFactory.BuildDto(entity);
|
||||
|
||||
Database.Update(dto);
|
||||
|
||||
@@ -219,7 +219,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
//Save updated entity to db
|
||||
|
||||
template.UpdateDate = DateTime.Now;
|
||||
;
|
||||
var dto = TemplateFactory.BuildDto(template, NodeObjectTypeId, templateDto.PrimaryKey);
|
||||
|
||||
Database.Update(dto.NodeDto);
|
||||
|
||||
@@ -77,12 +77,13 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
string ConvertIntegerToOrderableString { get; }
|
||||
string ConvertDateToOrderableString { get; }
|
||||
string ConvertDecimalToOrderableString { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default isolation level for the database
|
||||
/// </summary>
|
||||
IsolationLevel DefaultIsolationLevel { get; }
|
||||
|
||||
string DbProvider { get; }
|
||||
IEnumerable<string> GetTablesInSchema(IDatabase db);
|
||||
IEnumerable<ColumnInfo> GetColumnsInSchema(IDatabase db);
|
||||
|
||||
|
||||
@@ -175,6 +175,8 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
return items.Select(x => new Tuple<string, string, string, string>(x.TableName, x.ColumnName, x.Name, x.Definition));
|
||||
}
|
||||
|
||||
public override string DbProvider => ServerVersion.IsAzure ? "SqlAzure" : "SqlServer";
|
||||
|
||||
public override IEnumerable<string> GetTablesInSchema(IDatabase db)
|
||||
{
|
||||
var items = db.Fetch<dynamic>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = (SELECT SCHEMA_NAME())");
|
||||
|
||||
@@ -202,6 +202,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
}
|
||||
|
||||
public abstract IsolationLevel DefaultIsolationLevel { get; }
|
||||
public abstract string DbProvider { get; }
|
||||
|
||||
public virtual IEnumerable<string> GetTablesInSchema(IDatabase db)
|
||||
{
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
value = new ImageCropperValue { Src = sourceString };
|
||||
}
|
||||
|
||||
value.ApplyConfiguration(propertyType.DataType.ConfigurationAs<ImageCropperConfiguration>());
|
||||
value?.ApplyConfiguration(propertyType.DataType.ConfigurationAs<ImageCropperConfiguration>());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -14,35 +14,85 @@ using Umbraco.Web.PublishedCache;
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// A class used to query for published content, media items
|
||||
/// A class used to query for published content, media items
|
||||
/// </summary>
|
||||
public class PublishedContentQuery : IPublishedContentQuery
|
||||
{
|
||||
private readonly IExamineManager _examineManager;
|
||||
private readonly IPublishedSnapshot _publishedSnapshot;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IExamineManager _examineManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PublishedContentQuery"/> class.
|
||||
/// Initializes a new instance of the <see cref="PublishedContentQuery" /> class.
|
||||
/// </summary>
|
||||
public PublishedContentQuery(IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, IExamineManager examineManager)
|
||||
public PublishedContentQuery(IPublishedSnapshot publishedSnapshot,
|
||||
IVariationContextAccessor variationContextAccessor, IExamineManager examineManager)
|
||||
{
|
||||
_publishedSnapshot = publishedSnapshot ?? throw new ArgumentNullException(nameof(publishedSnapshot));
|
||||
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
|
||||
_variationContextAccessor = variationContextAccessor ??
|
||||
throw new ArgumentNullException(nameof(variationContextAccessor));
|
||||
_examineManager = examineManager ?? throw new ArgumentNullException(nameof(examineManager));
|
||||
}
|
||||
|
||||
#region Convert Helpers
|
||||
|
||||
private static bool ConvertIdObjectToInt(object id, out int intId)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case string s:
|
||||
return int.TryParse(s, out intId);
|
||||
|
||||
case int i:
|
||||
intId = i;
|
||||
return true;
|
||||
|
||||
default:
|
||||
intId = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ConvertIdObjectToGuid(object id, out Guid guidId)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case string s:
|
||||
return Guid.TryParse(s, out guidId);
|
||||
|
||||
case Guid g:
|
||||
guidId = g;
|
||||
return true;
|
||||
|
||||
default:
|
||||
guidId = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private static bool ConvertIdObjectToUdi(object id, out Udi guidId)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case string s:
|
||||
return UdiParser.TryParse(s, out guidId);
|
||||
|
||||
case Udi u:
|
||||
guidId = u;
|
||||
return true;
|
||||
|
||||
default:
|
||||
guidId = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Content
|
||||
|
||||
public IPublishedContent Content(int id)
|
||||
{
|
||||
return ItemById(id, _publishedSnapshot.Content);
|
||||
}
|
||||
public IPublishedContent Content(int id) => ItemById(id, _publishedSnapshot.Content);
|
||||
|
||||
public IPublishedContent Content(Guid id)
|
||||
{
|
||||
return ItemById(id, _publishedSnapshot.Content);
|
||||
}
|
||||
public IPublishedContent Content(Guid id) => ItemById(id, _publishedSnapshot.Content);
|
||||
|
||||
public IPublishedContent Content(Udi id)
|
||||
{
|
||||
@@ -50,49 +100,45 @@ namespace Umbraco.Web
|
||||
return ItemById(udi.Guid, _publishedSnapshot.Content);
|
||||
}
|
||||
|
||||
public IPublishedContent ContentSingleAtXPath(string xpath, params XPathVariable[] vars)
|
||||
public IPublishedContent Content(object id)
|
||||
{
|
||||
return ItemByXPath(xpath, vars, _publishedSnapshot.Content);
|
||||
if (ConvertIdObjectToInt(id, out var intId))
|
||||
return Content(intId);
|
||||
if (ConvertIdObjectToGuid(id, out var guidId))
|
||||
return Content(guidId);
|
||||
if (ConvertIdObjectToUdi(id, out var udiId))
|
||||
return Content(udiId);
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> Content(IEnumerable<int> ids)
|
||||
{
|
||||
return ItemsByIds(_publishedSnapshot.Content, ids);
|
||||
}
|
||||
public IPublishedContent ContentSingleAtXPath(string xpath, params XPathVariable[] vars) =>
|
||||
ItemByXPath(xpath, vars, _publishedSnapshot.Content);
|
||||
|
||||
public IEnumerable<IPublishedContent> Content(IEnumerable<Guid> ids)
|
||||
{
|
||||
return ItemsByIds(_publishedSnapshot.Content, ids);
|
||||
}
|
||||
public IEnumerable<IPublishedContent> Content(IEnumerable<int> ids) =>
|
||||
ItemsByIds(_publishedSnapshot.Content, ids);
|
||||
|
||||
public IEnumerable<IPublishedContent> ContentAtXPath(string xpath, params XPathVariable[] vars)
|
||||
{
|
||||
return ItemsByXPath(xpath, vars, _publishedSnapshot.Content);
|
||||
}
|
||||
public IEnumerable<IPublishedContent> Content(IEnumerable<Guid> ids) =>
|
||||
ItemsByIds(_publishedSnapshot.Content, ids);
|
||||
|
||||
public IEnumerable<IPublishedContent> ContentAtXPath(XPathExpression xpath, params XPathVariable[] vars)
|
||||
public IEnumerable<IPublishedContent> Content(IEnumerable<object> ids)
|
||||
{
|
||||
return ItemsByXPath(xpath, vars, _publishedSnapshot.Content);
|
||||
return ids.Select(Content).WhereNotNull();
|
||||
}
|
||||
public IEnumerable<IPublishedContent> ContentAtXPath(string xpath, params XPathVariable[] vars) =>
|
||||
ItemsByXPath(xpath, vars, _publishedSnapshot.Content);
|
||||
|
||||
public IEnumerable<IPublishedContent> ContentAtRoot()
|
||||
{
|
||||
return ItemsAtRoot(_publishedSnapshot.Content);
|
||||
}
|
||||
public IEnumerable<IPublishedContent> ContentAtXPath(XPathExpression xpath, params XPathVariable[] vars) =>
|
||||
ItemsByXPath(xpath, vars, _publishedSnapshot.Content);
|
||||
|
||||
public IEnumerable<IPublishedContent> ContentAtRoot() => ItemsAtRoot(_publishedSnapshot.Content);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Media
|
||||
|
||||
public IPublishedContent Media(int id)
|
||||
{
|
||||
return ItemById(id, _publishedSnapshot.Media);
|
||||
}
|
||||
public IPublishedContent Media(int id) => ItemById(id, _publishedSnapshot.Media);
|
||||
|
||||
public IPublishedContent Media(Guid id)
|
||||
{
|
||||
return ItemById(id, _publishedSnapshot.Media);
|
||||
}
|
||||
public IPublishedContent Media(Guid id) => ItemById(id, _publishedSnapshot.Media);
|
||||
|
||||
public IPublishedContent Media(Udi id)
|
||||
{
|
||||
@@ -100,21 +146,26 @@ namespace Umbraco.Web
|
||||
return ItemById(udi.Guid, _publishedSnapshot.Media);
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> Media(IEnumerable<int> ids)
|
||||
public IPublishedContent Media(object id)
|
||||
{
|
||||
return ItemsByIds(_publishedSnapshot.Media, ids);
|
||||
if (ConvertIdObjectToInt(id, out var intId))
|
||||
return Media(intId);
|
||||
if (ConvertIdObjectToGuid(id, out var guidId))
|
||||
return Media(guidId);
|
||||
if (ConvertIdObjectToUdi(id, out var udiId))
|
||||
return Media(udiId);
|
||||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> Media(IEnumerable<Guid> ids)
|
||||
public IEnumerable<IPublishedContent> Media(IEnumerable<int> ids) => ItemsByIds(_publishedSnapshot.Media, ids);
|
||||
public IEnumerable<IPublishedContent> Media(IEnumerable<object> ids)
|
||||
{
|
||||
return ItemsByIds(_publishedSnapshot.Media, ids);
|
||||
return ids.Select(Media).WhereNotNull();
|
||||
}
|
||||
|
||||
public IEnumerable<IPublishedContent> MediaAtRoot()
|
||||
{
|
||||
return ItemsAtRoot(_publishedSnapshot.Media);
|
||||
}
|
||||
public IEnumerable<IPublishedContent> Media(IEnumerable<Guid> ids) => ItemsByIds(_publishedSnapshot.Media, ids);
|
||||
|
||||
public IEnumerable<IPublishedContent> MediaAtRoot() => ItemsAtRoot(_publishedSnapshot.Media);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -155,44 +206,45 @@ namespace Umbraco.Web
|
||||
return ids.Select(eachId => ItemById(eachId, cache)).WhereNotNull();
|
||||
}
|
||||
|
||||
private static IEnumerable<IPublishedContent> ItemsByXPath(string xpath, XPathVariable[] vars, IPublishedCache cache)
|
||||
private static IEnumerable<IPublishedContent> ItemsByXPath(string xpath, XPathVariable[] vars,
|
||||
IPublishedCache cache)
|
||||
{
|
||||
var doc = cache.GetByXPath(xpath, vars);
|
||||
return doc;
|
||||
}
|
||||
|
||||
private static IEnumerable<IPublishedContent> ItemsByXPath(XPathExpression xpath, XPathVariable[] vars, IPublishedCache cache)
|
||||
private static IEnumerable<IPublishedContent> ItemsByXPath(XPathExpression xpath, XPathVariable[] vars,
|
||||
IPublishedCache cache)
|
||||
{
|
||||
var doc = cache.GetByXPath(xpath, vars);
|
||||
return doc;
|
||||
}
|
||||
|
||||
private static IEnumerable<IPublishedContent> ItemsAtRoot(IPublishedCache cache)
|
||||
{
|
||||
return cache.GetAtRoot();
|
||||
}
|
||||
private static IEnumerable<IPublishedContent> ItemsAtRoot(IPublishedCache cache) => cache.GetAtRoot();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Search
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishedSearchResult> Search(string term, string culture = "*", string indexName = Constants.UmbracoIndexes.ExternalIndexName)
|
||||
{
|
||||
return Search(term, 0, 0, out _, culture, indexName);
|
||||
}
|
||||
public IEnumerable<PublishedSearchResult> Search(string term, string culture = "*",
|
||||
string indexName = Constants.UmbracoIndexes.ExternalIndexName) =>
|
||||
Search(term, 0, 0, out _, culture, indexName);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishedSearchResult> Search(string term, int skip, int take, out long totalRecords, string culture = "*", string indexName = Constants.UmbracoIndexes.ExternalIndexName)
|
||||
public IEnumerable<PublishedSearchResult> Search(string term, int skip, int take, out long totalRecords,
|
||||
string culture = "*", string indexName = Constants.UmbracoIndexes.ExternalIndexName)
|
||||
{
|
||||
if (skip < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(skip), skip, "The value must be greater than or equal to zero.");
|
||||
throw new ArgumentOutOfRangeException(nameof(skip), skip,
|
||||
"The value must be greater than or equal to zero.");
|
||||
}
|
||||
|
||||
if (take < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(take), take, "The value must be greater than or equal to zero.");
|
||||
throw new ArgumentOutOfRangeException(nameof(take), take,
|
||||
"The value must be greater than or equal to zero.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(indexName))
|
||||
@@ -202,7 +254,8 @@ namespace Umbraco.Web
|
||||
|
||||
if (!_examineManager.TryGetIndex(indexName, out var index) || !(index is IUmbracoIndex umbIndex))
|
||||
{
|
||||
throw new InvalidOperationException($"No index found by name {indexName} or is not of type {typeof(IUmbracoIndex)}");
|
||||
throw new InvalidOperationException(
|
||||
$"No index found by name {indexName} or is not of type {typeof(IUmbracoIndex)}");
|
||||
}
|
||||
|
||||
var query = umbIndex.GetSearcher().CreateQuery(IndexTypes.Content);
|
||||
@@ -216,13 +269,16 @@ namespace Umbraco.Web
|
||||
else if (string.IsNullOrWhiteSpace(culture))
|
||||
{
|
||||
// Only search invariant
|
||||
queryExecutor = query.Field(UmbracoExamineFieldNames.VariesByCultureFieldName, "n") // Must not vary by culture
|
||||
queryExecutor = query
|
||||
.Field(UmbracoExamineFieldNames.VariesByCultureFieldName, "n") // Must not vary by culture
|
||||
.And().ManagedQuery(term);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only search the specified culture
|
||||
var fields = umbIndex.GetCultureAndInvariantFields(culture).ToArray(); // Get all index fields suffixed with the culture name supplied
|
||||
var fields =
|
||||
umbIndex.GetCultureAndInvariantFields(culture)
|
||||
.ToArray(); // Get all index fields suffixed with the culture name supplied
|
||||
queryExecutor = query.ManagedQuery(term, fields);
|
||||
}
|
||||
|
||||
@@ -232,26 +288,28 @@ namespace Umbraco.Web
|
||||
|
||||
totalRecords = results.TotalItemCount;
|
||||
|
||||
return new CultureContextualSearchResults(results.Skip(skip).ToPublishedSearchResults(_publishedSnapshot.Content), _variationContextAccessor, culture);
|
||||
return new CultureContextualSearchResults(
|
||||
results.Skip(skip).ToPublishedSearchResults(_publishedSnapshot.Content), _variationContextAccessor,
|
||||
culture);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query)
|
||||
{
|
||||
return Search(query, 0, 0, out _);
|
||||
}
|
||||
public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query) => Search(query, 0, 0, out _);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query, int skip, int take, out long totalRecords)
|
||||
public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query, int skip, int take,
|
||||
out long totalRecords)
|
||||
{
|
||||
if (skip < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(skip), skip, "The value must be greater than or equal to zero.");
|
||||
throw new ArgumentOutOfRangeException(nameof(skip), skip,
|
||||
"The value must be greater than or equal to zero.");
|
||||
}
|
||||
|
||||
if (take < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(take), take, "The value must be greater than or equal to zero.");
|
||||
throw new ArgumentOutOfRangeException(nameof(take), take,
|
||||
"The value must be greater than or equal to zero.");
|
||||
}
|
||||
|
||||
var results = skip == 0 && take == 0
|
||||
@@ -264,15 +322,17 @@ namespace Umbraco.Web
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to contextualize the values in the search results when enumerating over them so that the correct culture values are used
|
||||
/// This is used to contextualize the values in the search results when enumerating over them so that the correct
|
||||
/// culture values are used
|
||||
/// </summary>
|
||||
private class CultureContextualSearchResults : IEnumerable<PublishedSearchResult>
|
||||
{
|
||||
private readonly IEnumerable<PublishedSearchResult> _wrapped;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly string _culture;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IEnumerable<PublishedSearchResult> _wrapped;
|
||||
|
||||
public CultureContextualSearchResults(IEnumerable<PublishedSearchResult> wrapped, IVariationContextAccessor variationContextAccessor, string culture)
|
||||
public CultureContextualSearchResults(IEnumerable<PublishedSearchResult> wrapped,
|
||||
IVariationContextAccessor variationContextAccessor, string culture)
|
||||
{
|
||||
_wrapped = wrapped;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
@@ -287,24 +347,23 @@ namespace Umbraco.Web
|
||||
_variationContextAccessor.VariationContext = new VariationContext(_culture);
|
||||
|
||||
//now the IPublishedContent returned will be contextualized to the culture specified and will be reset when the enumerator is disposed
|
||||
return new CultureContextualSearchResultsEnumerator(_wrapped.GetEnumerator(), _variationContextAccessor, originalContext);
|
||||
return new CultureContextualSearchResultsEnumerator(_wrapped.GetEnumerator(), _variationContextAccessor,
|
||||
originalContext);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
/// <summary>
|
||||
/// Resets the variation context when this is disposed
|
||||
/// Resets the variation context when this is disposed
|
||||
/// </summary>
|
||||
private class CultureContextualSearchResultsEnumerator : IEnumerator<PublishedSearchResult>
|
||||
{
|
||||
private readonly IEnumerator<PublishedSearchResult> _wrapped;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly VariationContext _originalContext;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IEnumerator<PublishedSearchResult> _wrapped;
|
||||
|
||||
public CultureContextualSearchResultsEnumerator(IEnumerator<PublishedSearchResult> wrapped, IVariationContextAccessor variationContextAccessor, VariationContext originalContext)
|
||||
public CultureContextualSearchResultsEnumerator(IEnumerator<PublishedSearchResult> wrapped,
|
||||
IVariationContextAccessor variationContextAccessor, VariationContext originalContext)
|
||||
{
|
||||
_wrapped = wrapped;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
@@ -318,10 +377,7 @@ namespace Umbraco.Web
|
||||
_variationContextAccessor.VariationContext = _originalContext;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return _wrapped.MoveNext();
|
||||
}
|
||||
public bool MoveNext() => _wrapped.MoveNext();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
}
|
||||
|
||||
public override System.Data.IsolationLevel DefaultIsolationLevel => System.Data.IsolationLevel.RepeatableRead;
|
||||
public override string DbProvider => "SqlServerCE";
|
||||
|
||||
public override string FormatColumnRename(string tableName, string oldName, string newName)
|
||||
{
|
||||
|
||||
@@ -1313,7 +1313,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var member = args.Entity;
|
||||
|
||||
// refresh the edited data
|
||||
OnRepositoryRefreshed(db, member, true);
|
||||
OnRepositoryRefreshed(db, member, false);
|
||||
}
|
||||
|
||||
private void OnRepositoryRefreshed(IUmbracoDatabase db, IContentBase content, bool published)
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace Umbraco.TestData
|
||||
private readonly PropertyEditorCollection _propertyEditors;
|
||||
private readonly IShortStringHelper _shortStringHelper;
|
||||
|
||||
public UmbracoTestDataController(IScopeProvider scopeProvider, PropertyEditorCollection propertyEditors, IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, ILogger logger, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper, IShortStringHelper shortStringHelper)
|
||||
: base(umbracoContextAccessor, databaseFactory, services, appCaches, logger, profilingLogger, umbracoHelper)
|
||||
public UmbracoTestDataController(IScopeProvider scopeProvider, PropertyEditorCollection propertyEditors, IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, ILogger logger, IProfilingLogger profilingLogger, IShortStringHelper shortStringHelper)
|
||||
: base(umbracoContextAccessor, databaseFactory, services, appCaches, logger, profilingLogger)
|
||||
{
|
||||
_scopeProvider = scopeProvider;
|
||||
_propertyEditors = propertyEditors;
|
||||
@@ -223,7 +223,7 @@ namespace Umbraco.TestData
|
||||
{
|
||||
var content = Services.ContentService.Create(faker.Commerce.ProductName(), currParent, docType.Alias);
|
||||
content.SetValue("review", faker.Rant.Review());
|
||||
content.SetValue("desc", string.Join(", ", Enumerable.Range(0, 5).Select(x => faker.Commerce.ProductAdjective()))); ;
|
||||
content.SetValue("desc", string.Join(", ", Enumerable.Range(0, 5).Select(x => faker.Commerce.ProductAdjective())));
|
||||
content.SetValue("media", imageIds[random.Next(0, imageIds.Count - 1)]);
|
||||
|
||||
Services.ContentService.Save(content);
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace Umbraco.Tests.Composing
|
||||
var col2 = factory.GetInstance<TestCollection>();
|
||||
AssertCollection(col2, typeof(Resolved1), typeof(Resolved2));
|
||||
|
||||
AssertSameCollection(col1, col2);
|
||||
AssertSameCollection(factory, col1, col2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -416,11 +416,11 @@ namespace Umbraco.Tests.Composing
|
||||
{
|
||||
col1A = factory.GetInstance<TestCollection>();
|
||||
col1B = factory.GetInstance<TestCollection>();
|
||||
}
|
||||
|
||||
AssertCollection(col1A, typeof(Resolved1), typeof(Resolved2));
|
||||
AssertCollection(col1B, typeof(Resolved1), typeof(Resolved2));
|
||||
AssertSameCollection(col1A, col1B);
|
||||
AssertCollection(col1A, typeof(Resolved1), typeof(Resolved2));
|
||||
AssertCollection(col1B, typeof(Resolved1), typeof(Resolved2));
|
||||
AssertSameCollection(factory, col1A, col1B);
|
||||
}
|
||||
|
||||
TestCollection col2;
|
||||
|
||||
@@ -455,7 +455,7 @@ namespace Umbraco.Tests.Composing
|
||||
Assert.IsInstanceOf(expected[i], colA[i]);
|
||||
}
|
||||
|
||||
private static void AssertSameCollection(IEnumerable<Resolved> col1, IEnumerable<Resolved> col2)
|
||||
private static void AssertSameCollection(IFactory factory, IEnumerable<Resolved> col1, IEnumerable<Resolved> col2)
|
||||
{
|
||||
Assert.AreSame(col1, col2);
|
||||
|
||||
@@ -463,8 +463,19 @@ namespace Umbraco.Tests.Composing
|
||||
var col2A = col2.ToArray();
|
||||
|
||||
Assert.AreEqual(col1A.Length, col2A.Length);
|
||||
|
||||
// Ensure each item in each collection is the same but also
|
||||
// resolve each item from the factory to ensure it's also the same since
|
||||
// it should have the same lifespan.
|
||||
for (var i = 0; i < col1A.Length; i++)
|
||||
{
|
||||
Assert.AreSame(col1A[i], col2A[i]);
|
||||
|
||||
var itemA = factory.GetInstance(col1A[i].GetType());
|
||||
var itemB = factory.GetInstance(col2A[i].GetType());
|
||||
|
||||
Assert.AreSame(itemA, itemB);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertNotSameCollection(IEnumerable<Resolved> col1, IEnumerable<Resolved> col2)
|
||||
@@ -475,8 +486,11 @@ namespace Umbraco.Tests.Composing
|
||||
var col2A = col2.ToArray();
|
||||
|
||||
Assert.AreEqual(col1A.Length, col2A.Length);
|
||||
|
||||
for (var i = 0; i < col1A.Length; i++)
|
||||
{
|
||||
Assert.AreNotSame(col1A[i], col2A[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Umbraco.Tests.Logging
|
||||
|
||||
//Query @Level='Warning' BUT we pass in array of LogLevels for Debug & Info (Expect to get 0 results)
|
||||
string[] logLevelMismatch = { "Debug", "Information" };
|
||||
var filterLevelQuery = _logViewer.GetLogs(_logTimePeriod, pageNumber: 1, filterExpression: "@Level='Warning'", logLevels: logLevelMismatch); ;
|
||||
var filterLevelQuery = _logViewer.GetLogs(_logTimePeriod, pageNumber: 1, filterExpression: "@Level='Warning'", logLevels: logLevelMismatch);
|
||||
Assert.AreEqual(0, filterLevelQuery.TotalItems);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,6 @@ namespace Umbraco.Tests.Routing
|
||||
var routeData = new RouteData() { Route = route };
|
||||
var umbracoContext = GetUmbracoContext("~/dummy-page", template.Id, routeData, true);
|
||||
var httpContext = GetHttpContextFactory(url, routeData).HttpContext;
|
||||
var httpContextAccessor = TestHelper.GetHttpContextAccessor(httpContext);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
frequest.PublishedContent = umbracoContext.Content.GetById(1172);
|
||||
@@ -149,12 +148,12 @@ namespace Umbraco.Tests.Routing
|
||||
|
||||
var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of<ILogger>(), context =>
|
||||
{
|
||||
return new CustomDocumentController(Factory.GetInstance<IGlobalSettings>(),
|
||||
umbracoContextAccessor,
|
||||
Factory.GetInstance<ServiceContext>(),
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
new UmbracoHelper(Mock.Of<IPublishedContent>(), Mock.Of<ITagQuery>(), Mock.Of<ICultureDictionaryFactory>(), Mock.Of<IUmbracoComponentRenderer>(), Mock.Of<IPublishedContentQuery>()));
|
||||
|
||||
return new CustomDocumentController(Factory.GetInstance<IGlobalSettings>(),
|
||||
umbracoContextAccessor,
|
||||
Factory.GetInstance<ServiceContext>(),
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>());
|
||||
}), ShortStringHelper);
|
||||
|
||||
handler.GetHandlerForRoute(httpContext.Request.RequestContext, frequest);
|
||||
@@ -191,8 +190,8 @@ namespace Umbraco.Tests.Routing
|
||||
/// </summary>
|
||||
public class CustomDocumentController : RenderMvcController
|
||||
{
|
||||
public CustomDocumentController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper)
|
||||
: base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger, umbracoHelper)
|
||||
public CustomDocumentController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger)
|
||||
: base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
{
|
||||
public class TestControllerActivator : TestControllerActivatorBase
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, IUmbracoContextAccessor, UmbracoHelper, ApiController> _factory;
|
||||
private readonly Func<HttpRequestMessage, IUmbracoContextAccessor, ApiController> _factory;
|
||||
|
||||
public TestControllerActivator(Func<HttpRequestMessage, IUmbracoContextAccessor, UmbracoHelper, ApiController> factory)
|
||||
public TestControllerActivator(Func<HttpRequestMessage, IUmbracoContextAccessor, ApiController> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
protected override ApiController CreateController(Type controllerType, HttpRequestMessage msg, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
protected override ApiController CreateController(Type controllerType, HttpRequestMessage msg, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
return _factory(msg, umbracoContextAccessor, helper);
|
||||
return _factory(msg, umbracoContextAccessor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,15 +154,9 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
urlHelper.Setup(provider => provider.GetUrl(It.IsAny<IPublishedContent>(), It.IsAny<UrlMode>(), It.IsAny<string>(), It.IsAny<Uri>()))
|
||||
.Returns(UrlInfo.Url("/hello/world/1234"));
|
||||
|
||||
var umbHelper = new UmbracoHelper(Mock.Of<IPublishedContent>(),
|
||||
Mock.Of<ITagQuery>(),
|
||||
Mock.Of<ICultureDictionaryFactory>(),
|
||||
Mock.Of<IUmbracoComponentRenderer>(),
|
||||
Mock.Of<IPublishedContentQuery>());
|
||||
|
||||
return CreateController(controllerType, request, umbracoContextAccessor, umbHelper);
|
||||
return CreateController(controllerType, request, umbracoContextAccessor);
|
||||
}
|
||||
|
||||
protected abstract ApiController CreateController(Type controllerType, HttpRequestMessage msg, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper);
|
||||
protected abstract ApiController CreateController(Type controllerType, HttpRequestMessage msg, IUmbracoContextAccessor umbracoContextAccessor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
{
|
||||
public class TestRunner
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, IUmbracoContextAccessor, UmbracoHelper, ApiController> _controllerFactory;
|
||||
private readonly Func<HttpRequestMessage, IUmbracoContextAccessor, ApiController> _controllerFactory;
|
||||
|
||||
public TestRunner(Func<HttpRequestMessage, IUmbracoContextAccessor, UmbracoHelper, ApiController> controllerFactory)
|
||||
public TestRunner(Func<HttpRequestMessage, IUmbracoContextAccessor, ApiController> controllerFactory)
|
||||
{
|
||||
_controllerFactory = controllerFactory;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
|
||||
/// </summary>
|
||||
public class TestStartup
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, IUmbracoContextAccessor, UmbracoHelper, ApiController> _controllerFactory;
|
||||
private readonly Func<HttpRequestMessage, IUmbracoContextAccessor, ApiController> _controllerFactory;
|
||||
private readonly Action<HttpConfiguration> _initialize;
|
||||
|
||||
public TestStartup(Action<HttpConfiguration> initialize, Func<HttpRequestMessage, IUmbracoContextAccessor, UmbracoHelper, ApiController> controllerFactory)
|
||||
public TestStartup(Action<HttpConfiguration> initialize, Func<HttpRequestMessage, IUmbracoContextAccessor, ApiController> controllerFactory)
|
||||
{
|
||||
_controllerFactory = controllerFactory;
|
||||
_initialize = initialize;
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
|
||||
// ReSharper disable once UnusedVariable
|
||||
var helper = new UmbracoHelper(Mock.Of<IPublishedContent>(),
|
||||
Mock.Of<ITagQuery>(),
|
||||
Mock.Of<ICultureDictionaryFactory>(),
|
||||
Mock.Of<IUmbracoComponentRenderer>(),
|
||||
Mock.Of<IPublishedContentQuery>());
|
||||
@@ -106,11 +105,9 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
var memberTypeService = Mock.Of<IMemberTypeService>();
|
||||
var membershipProvider = new MembersMembershipProvider(memberService, memberTypeService, Mock.Of<IUmbracoVersion>(), TestHelper.GetHostingEnvironment(), TestHelper.GetIpResolver());
|
||||
var membershipHelper = new MembershipHelper(Mock.Of<IHttpContextAccessor>(), Mock.Of<IPublishedMemberCache>(), membershipProvider, Mock.Of<RoleProvider>(), memberService, memberTypeService, Mock.Of<IPublicAccessService>(), AppCaches.Disabled, logger, ShortStringHelper, Mock.Of<IEntityService>());
|
||||
var umbracoHelper = new UmbracoHelper(Mock.Of<IPublishedContent>(), Mock.Of<ITagQuery>(), Mock.Of<ICultureDictionaryFactory>(),
|
||||
Mock.Of<IUmbracoComponentRenderer>(), Mock.Of<IPublishedContentQuery>());
|
||||
var umbracoMapper = new UmbracoMapper(new MapDefinitionCollection(new[] { Mock.Of<IMapDefinition>() }));
|
||||
|
||||
var umbracoApiController = new FakeUmbracoApiController(Mock.Of<IGlobalSettings>(), Mock.Of<IUmbracoContextAccessor>(), Mock.Of<ISqlContext>(), ServiceContext.CreatePartial(), AppCaches.NoCache, logger, Mock.Of<IRuntimeState>(), umbracoHelper, umbracoMapper, Mock.Of<IPublishedUrlProvider>());
|
||||
var umbracoApiController = new FakeUmbracoApiController(Mock.Of<IGlobalSettings>(), Mock.Of<IUmbracoContextAccessor>(), Mock.Of<ISqlContext>(), ServiceContext.CreatePartial(), AppCaches.NoCache, logger, Mock.Of<IRuntimeState>(), umbracoMapper, Mock.Of<IPublishedUrlProvider>());
|
||||
|
||||
Assert.Pass();
|
||||
}
|
||||
@@ -118,7 +115,7 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
|
||||
internal class FakeUmbracoApiController : UmbracoApiController
|
||||
{
|
||||
public FakeUmbracoApiController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, umbracoMapper, publishedUrlProvider) { }
|
||||
public FakeUmbracoApiController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async System.Threading.Tasks.Task GetCurrentUser_Fips()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
//setup some mocks
|
||||
var userServiceMock = Mock.Get(ServiceContext.UserService);
|
||||
@@ -87,7 +87,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IUmbracoSettingsSection>(),
|
||||
Factory.GetInstance<IIOHelper>(),
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async Task PostSave_Validate_Existing_Content()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var contentServiceMock = Mock.Get(ServiceContext.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => null); //do not find it
|
||||
@@ -269,7 +269,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IPublishedUrlProvider>());
|
||||
@@ -293,7 +292,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async Task PostSave_Validate_At_Least_One_Variant_Flagged_For_Saving()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
var controller = new ContentController(
|
||||
@@ -306,7 +305,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IPublishedUrlProvider>());
|
||||
@@ -335,7 +333,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async Task PostSave_Validate_Properties_Exist()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var contentServiceMock = Mock.Get(ServiceContext.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => GetMockedContent());
|
||||
@@ -351,7 +349,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IPublishedUrlProvider>());
|
||||
@@ -383,7 +380,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
{
|
||||
var content = GetMockedContent();
|
||||
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var contentServiceMock = Mock.Get(ServiceContext.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => content);
|
||||
@@ -401,7 +398,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IPublishedUrlProvider>());
|
||||
@@ -425,7 +421,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
{
|
||||
var content = GetMockedContent();
|
||||
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var contentServiceMock = Mock.Get(ServiceContext.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => content);
|
||||
@@ -443,7 +439,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IPublishedUrlProvider>()
|
||||
@@ -474,7 +469,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
{
|
||||
var content = GetMockedContent();
|
||||
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var contentServiceMock = Mock.Get(ServiceContext.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => content);
|
||||
@@ -492,7 +487,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
Factory.GetInstance<IPublishedUrlProvider>()
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
public class Plugin1Controller : PluginController
|
||||
{
|
||||
public Plugin1Controller(IUmbracoContextAccessor umbracoContextAccessor)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null, null)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
public class Plugin2Controller : PluginController
|
||||
{
|
||||
public Plugin2Controller(IUmbracoContextAccessor umbracoContextAccessor)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null, null)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
public class Plugin3Controller : PluginController
|
||||
{
|
||||
public Plugin3Controller(IUmbracoContextAccessor umbracoContextAccessor)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null, null)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
public class Plugin4Controller : PluginController
|
||||
{
|
||||
public Plugin4Controller(IUmbracoContextAccessor umbracoContextAccessor)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null, null)
|
||||
: base(umbracoContextAccessor, null, null, null, null, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async System.Threading.Tasks.Task Save_User()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var userServiceMock = Mock.Get(ServiceContext.UserService);
|
||||
|
||||
@@ -86,7 +86,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
@@ -149,7 +148,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async System.Threading.Tasks.Task GetPagedUsers_Empty()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
var usersController = new UsersController(
|
||||
Factory.GetInstance<IGlobalSettings>(),
|
||||
@@ -159,7 +158,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
@@ -183,7 +181,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[Test]
|
||||
public async System.Threading.Tasks.Task GetPagedUsers_10()
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
//setup some mocks
|
||||
var userServiceMock = Mock.Get(ServiceContext.UserService);
|
||||
@@ -202,7 +200,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
@@ -266,7 +263,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Action<Tuple<HttpResponseMessage, string>> verification,
|
||||
object routeDefaults = null, string url = null)
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper)
|
||||
ApiController CtrlFactory(HttpRequestMessage message, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
{
|
||||
//setup some mocks
|
||||
var userServiceMock = Mock.Get(ServiceContext.UserService);
|
||||
@@ -280,7 +277,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<AppCaches>(),
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper,
|
||||
Factory.GetInstance<IMediaFileSystem>(),
|
||||
ShortStringHelper,
|
||||
Factory.GetInstance<UmbracoMapper>(),
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -26,6 +27,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
[UmbracoTest(WithApplication = true)]
|
||||
public class SurfaceControllerTests : UmbracoTestBase
|
||||
{
|
||||
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
@@ -55,7 +57,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
|
||||
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
|
||||
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor);
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor, Mock.Of<IPublishedContentQuery>());
|
||||
|
||||
var result = ctrl.Index();
|
||||
|
||||
@@ -85,7 +87,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
|
||||
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbCtx);
|
||||
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor);
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor, Mock.Of<IPublishedContentQuery>());
|
||||
|
||||
Assert.IsNotNull(ctrl.UmbracoContext);
|
||||
}
|
||||
@@ -118,14 +120,9 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
|
||||
var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
|
||||
|
||||
var helper = new UmbracoHelper(
|
||||
content.Object,
|
||||
Mock.Of<ITagQuery>(),
|
||||
Mock.Of<ICultureDictionaryFactory>(),
|
||||
Mock.Of<IUmbracoComponentRenderer>(),
|
||||
Mock.Of<IPublishedContentQuery>(query => query.Content(2) == content.Object));
|
||||
var publishedContentQuery = Mock.Of<IPublishedContentQuery>(query => query.Content(2) == content.Object);
|
||||
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor, helper);
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor,publishedContentQuery);
|
||||
var result = ctrl.GetContent(2) as PublishedContentResult;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
@@ -171,7 +168,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
var routeData = new RouteData();
|
||||
routeData.DataTokens.Add(Core.Constants.Web.UmbracoRouteDefinitionDataToken, routeDefinition);
|
||||
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor, new UmbracoHelper());
|
||||
var ctrl = new TestSurfaceController(umbracoContextAccessor, Mock.Of<IPublishedContentQuery>());
|
||||
ctrl.ControllerContext = new ControllerContext(Mock.Of<HttpContextBase>(), routeData, ctrl);
|
||||
|
||||
var result = ctrl.GetContentFromCurrentPage() as PublishedContentResult;
|
||||
@@ -181,9 +178,12 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
|
||||
public class TestSurfaceController : SurfaceController
|
||||
{
|
||||
public TestSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, UmbracoHelper helper = null)
|
||||
: base(umbracoContextAccessor, null, ServiceContext.CreatePartial(), AppCaches.Disabled, null, null, helper)
|
||||
private readonly IPublishedContentQuery _publishedContentQuery;
|
||||
|
||||
public TestSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IPublishedContentQuery publishedContentQuery)
|
||||
: base(umbracoContextAccessor, null, ServiceContext.CreatePartial(), AppCaches.Disabled, null, null)
|
||||
{
|
||||
_publishedContentQuery = publishedContentQuery;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
@@ -194,7 +194,7 @@ namespace Umbraco.Tests.Web.Mvc
|
||||
|
||||
public ActionResult GetContent(int id)
|
||||
{
|
||||
var content = Umbraco.Content(id);
|
||||
var content = _publishedContentQuery.Content(id);
|
||||
|
||||
return new PublishedContentResult(content);
|
||||
}
|
||||
|
||||
@@ -24,234 +24,6 @@ namespace Umbraco.Tests.Web
|
||||
Current.Reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------- Int32 conversion tests
|
||||
[Test]
|
||||
public static void Converting_Boxed_34_To_An_Int_Returns_34()
|
||||
{
|
||||
// Arrange
|
||||
const int sample = 34;
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
sample,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(34));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_String_54_To_An_Int_Returns_54()
|
||||
{
|
||||
// Arrange
|
||||
const string sample = "54";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
sample,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(54));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_Hello_To_An_Int_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
sample,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_Unsupported_Object_To_An_Int_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var clearlyWillNotConvertToInt = new StringBuilder(0);
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToInt(
|
||||
clearlyWillNotConvertToInt,
|
||||
out int result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
// ------- GUID conversion tests
|
||||
[Test]
|
||||
public static void Converting_Boxed_Guid_To_A_Guid_Returns_Original_Guid_Value()
|
||||
{
|
||||
// Arrange
|
||||
Guid sample = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
sample,
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_String_Guid_To_A_Guid_Returns_Original_Guid_Value()
|
||||
{
|
||||
// Arrange
|
||||
Guid sample = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
sample.ToString(),
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_Hello_To_A_Guid_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
sample,
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(new Guid("00000000-0000-0000-0000-000000000000")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Converting_Unsupported_Object_To_A_Guid_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var clearlyWillNotConvertToGuid = new StringBuilder(0);
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToGuid(
|
||||
clearlyWillNotConvertToGuid,
|
||||
out Guid result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.EqualTo(new Guid("00000000-0000-0000-0000-000000000000")));
|
||||
}
|
||||
|
||||
// ------- UDI Conversion Tests
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public static void Converting_Boxed_Udi_To_A_Udi_Returns_Original_Udi_Value()
|
||||
{
|
||||
// Arrange
|
||||
UdiParser.ResetUdiTypes();
|
||||
Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
sample,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success);
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_String_Udi_To_A_Udi_Returns_Original_Udi_Value()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
UdiParser.ResetUdiTypes();
|
||||
Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
sample.ToString(),
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(success, "Conversion of UDI failed.");
|
||||
Assert.That(result, Is.EqualTo(sample));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public void Converting_Hello_To_A_Udi_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
SetUpDependencyContainer();
|
||||
UdiParser.ResetUdiTypes();
|
||||
const string sample = "Hello";
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
sample,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// This requires PluginManager.Current to be initialised before running.
|
||||
/// </remarks>
|
||||
[Test]
|
||||
public static void Converting_Unsupported_Object_To_A_Udi_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
UdiParser.ResetUdiTypes();
|
||||
|
||||
var clearlyWillNotConvertToGuid = new StringBuilder(0);
|
||||
|
||||
// Act
|
||||
bool success = UmbracoHelper.ConvertIdObjectToUdi(
|
||||
clearlyWillNotConvertToGuid,
|
||||
out Udi result
|
||||
);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(success);
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
|
||||
private void SetUpDependencyContainer()
|
||||
{
|
||||
// FIXME: bad in a unit test - but Udi has a static ctor that wants it?!
|
||||
|
||||
+11
@@ -133,6 +133,17 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se
|
||||
}
|
||||
};
|
||||
|
||||
scope.currentSectionInOverflow = function () {
|
||||
if (scope.overflowingSections === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var currentSection = scope.sections.filter(s => s.alias === scope.currentSection);
|
||||
|
||||
return (scope.sections.indexOf(currentSection[0]) >= scope.maxSections);
|
||||
|
||||
};
|
||||
|
||||
loadSections();
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -18,9 +18,9 @@
|
||||
|
||||
function link(scope, element, attrs, ctrl) {
|
||||
|
||||
scope.close = function() {
|
||||
if(scope.onClose) {
|
||||
scope.onClose();
|
||||
scope.close = function () {
|
||||
if (scope.onClose) {
|
||||
scope.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -42,7 +42,7 @@
|
||||
$scope.page.isNew = Object.toBoolean(newVal);
|
||||
|
||||
//We fetch all ancestors of the node to generate the footer breadcrumb navigation
|
||||
if (content.parentId && content.parentId !== -1) {
|
||||
if (content.parentId && content.parentId !== -1 && content.parentId !== -20) {
|
||||
loadBreadcrumb();
|
||||
if (!watchingCulture) {
|
||||
$scope.$watch('culture',
|
||||
@@ -287,6 +287,8 @@
|
||||
$scope.page.showSaveButton = true;
|
||||
// add ellipsis to the save button if it opens the variant overlay
|
||||
$scope.page.saveButtonEllipsis = content.variants && content.variants.length > 1 ? "true" : "false";
|
||||
} else {
|
||||
$scope.page.showSaveButton = false;
|
||||
}
|
||||
|
||||
// create the pubish combo button
|
||||
|
||||
+3
@@ -328,6 +328,9 @@
|
||||
// invariant nodes
|
||||
scope.currentUrls = scope.node.urls;
|
||||
}
|
||||
|
||||
// figure out if multiple cultures apply across the content urls
|
||||
scope.currentUrlsHaveMultipleCultures = _.keys(_.groupBy(scope.currentUrls, url => url.culture)).length > 1;
|
||||
}
|
||||
|
||||
// load audit trail and redirects when on the info tab
|
||||
|
||||
+11
-6
@@ -99,13 +99,18 @@ Use this directive to render a ui component for selecting child items to a paren
|
||||
@param {string} parentName (<code>binding</code>): The parent name.
|
||||
@param {string} parentIcon (<code>binding</code>): The parent icon.
|
||||
@param {number} parentId (<code>binding</code>): The parent id.
|
||||
@param {callback} onRemove (<code>binding</code>): Callback when the remove button is clicked on an item.
|
||||
@param {callback} onRemove (<code>binding</code>): Callback when removing an item.
|
||||
<h3>The callback returns:</h3>
|
||||
<ul>
|
||||
<li><code>child</code>: The selected item.</li>
|
||||
<li><code>$index</code>: The selected item index.</li>
|
||||
</ul>
|
||||
@param {callback} onAdd (<code>binding</code>): Callback when the add button is clicked.
|
||||
@param {callback} onAdd (<code>binding</code>): Callback when adding an item.
|
||||
<h3>The callback returns:</h3>
|
||||
<ul>
|
||||
<li><code>$event</code>: The select event.</li>
|
||||
</ul>
|
||||
@param {callback} onSort (<code>binding</code>): Callback when sorting an item.
|
||||
<h3>The callback returns:</h3>
|
||||
<ul>
|
||||
<li><code>$event</code>: The select event.</li>
|
||||
@@ -174,16 +179,15 @@ Use this directive to render a ui component for selecting child items to a paren
|
||||
eventBindings.push(scope.$watch('parentName', function(newValue, oldValue){
|
||||
|
||||
if (newValue === oldValue) { return; }
|
||||
if ( oldValue === undefined || newValue === undefined) { return; }
|
||||
if (oldValue === undefined || newValue === undefined) { return; }
|
||||
|
||||
syncParentName();
|
||||
|
||||
}));
|
||||
|
||||
eventBindings.push(scope.$watch('parentIcon', function(newValue, oldValue){
|
||||
|
||||
if (newValue === oldValue) { return; }
|
||||
if ( oldValue === undefined || newValue === undefined) { return; }
|
||||
if (oldValue === undefined || newValue === undefined) { return; }
|
||||
|
||||
syncParentIcon();
|
||||
}));
|
||||
@@ -191,6 +195,7 @@ Use this directive to render a ui component for selecting child items to a paren
|
||||
// sortable options for allowed child content types
|
||||
scope.sortableOptions = {
|
||||
axis: "y",
|
||||
cancel: ".unsortable",
|
||||
containment: "parent",
|
||||
distance: 10,
|
||||
opacity: 0.7,
|
||||
@@ -199,7 +204,7 @@ Use this directive to render a ui component for selecting child items to a paren
|
||||
zIndex: 6000,
|
||||
update: function (e, ui) {
|
||||
if(scope.onSort) {
|
||||
scope.onSort();
|
||||
scope.onSort();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+26
-6
@@ -24,8 +24,7 @@ function valPropertyMsg(serverValidationManager, localizationService) {
|
||||
var hasError = false;
|
||||
|
||||
//create properties on our custom scope so we can use it in our template
|
||||
scope.errorMsg = "";
|
||||
|
||||
scope.errorMsg = "";
|
||||
|
||||
//the property form controller api
|
||||
var formCtrl = ctrl[0];
|
||||
@@ -34,11 +33,15 @@ function valPropertyMsg(serverValidationManager, localizationService) {
|
||||
//the property controller api
|
||||
var umbPropCtrl = ctrl[2];
|
||||
//the variants controller api
|
||||
var umbVariantCtrl = ctrl[3];
|
||||
var umbVariantCtrl = ctrl[3];
|
||||
|
||||
var currentProperty = umbPropCtrl.property;
|
||||
scope.currentProperty = currentProperty;
|
||||
|
||||
var currentCulture = currentProperty.culture;
|
||||
|
||||
// validation object won't exist when editor loads outside the content form (ie in settings section when modifying a content type)
|
||||
var isMandatory = currentProperty.validation ? currentProperty.validation.mandatory : undefined;
|
||||
|
||||
var labels = {};
|
||||
localizationService.localize("errors_propertyHasErrors").then(function (data) {
|
||||
@@ -91,23 +94,25 @@ function valPropertyMsg(serverValidationManager, localizationService) {
|
||||
if (!watcher) {
|
||||
watcher = scope.$watch("currentProperty.value",
|
||||
function (newValue, oldValue) {
|
||||
|
||||
if (angular.equals(newValue, oldValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var errCount = 0;
|
||||
|
||||
for (var e in formCtrl.$error) {
|
||||
if (angular.isArray(formCtrl.$error[e])) {
|
||||
errCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we are explicitly checking for valServer errors here, since we shouldn't auto clear
|
||||
// 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 === 0 || (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);
|
||||
} else if (showValidation && scope.errorMsg === "") {
|
||||
@@ -136,6 +141,21 @@ function valPropertyMsg(serverValidationManager, localizationService) {
|
||||
}
|
||||
//if there are any errors in the current property form that are not valPropertyMsg
|
||||
else if (_.without(_.keys(formCtrl.$error), "valPropertyMsg").length > 0) {
|
||||
|
||||
// errors exist, but if the property is NOT mandatory and has no value, the errors should be cleared
|
||||
if (isMandatory !== undefined && isMandatory === false && !currentProperty.value) {
|
||||
hasError = false;
|
||||
showValidation = false;
|
||||
scope.errorMsg = "";
|
||||
|
||||
// if there's no value, the controls can be reset, which clears the error state on formCtrl
|
||||
for (let control of formCtrl.$getControls()) {
|
||||
control.$setValidity();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
hasError = true;
|
||||
//update the validation message if we don't already have one assigned.
|
||||
if (showValidation && scope.errorMsg === "") {
|
||||
|
||||
@@ -525,7 +525,7 @@ When building a custom infinite editor view you can use the same components as a
|
||||
|
||||
function rollback(editor) {
|
||||
editor.view = "views/common/infiniteeditors/rollback/rollback.html";
|
||||
if (!editor.size) editor.size = "small";
|
||||
if (!editor.size) editor.size = "medium";
|
||||
open(editor);
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ When building a custom infinite editor view you can use the same components as a
|
||||
* @methodOf umbraco.services.editorService
|
||||
*
|
||||
* @description
|
||||
* Opens the user group picker in infinite editing, the submit callback returns the saved template
|
||||
* Opens the template editor in infinite editing, the submit callback returns the saved template
|
||||
* @param {Object} editor rendering options
|
||||
* @param {String} editor.id The template id
|
||||
* @param {Callback} editor.submit Submits the editor
|
||||
|
||||
@@ -103,14 +103,21 @@
|
||||
|
||||
|
||||
|
||||
|
||||
.umb-toggle.umb-toggle--disabled.umb-toggle--checked,
|
||||
.umb-toggle.umb-toggle--disabled {
|
||||
.umb-toggle__toggle {
|
||||
cursor: not-allowed;
|
||||
border-color: @gray-5;
|
||||
background-color: @gray-9;
|
||||
border-color: @gray-9;
|
||||
}
|
||||
.umb-toggle__icon--left {
|
||||
color: @gray-6;
|
||||
}
|
||||
.umb-toggle__icon--right {
|
||||
color: @gray-6;
|
||||
}
|
||||
.umb-toggle__handler {
|
||||
background-color: @gray-5;
|
||||
background-color: @gray-10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,23 +16,24 @@
|
||||
.umb-child-selector__child.-placeholder {
|
||||
border: 1px dashed @gray-8;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
|
||||
color:@ui-action-type;
|
||||
width: 100%;
|
||||
color: @ui-action-type;
|
||||
|
||||
&:hover {
|
||||
color:@ui-action-type-hover;
|
||||
border-color:@ui-action-type-hover;
|
||||
text-decoration:none;
|
||||
color: @ui-action-type-hover;
|
||||
border-color: @ui-action-type-hover;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.umb-child-selector__children-container {
|
||||
margin-left: 30px;
|
||||
.umb-child-selector__child {
|
||||
cursor: move;
|
||||
}
|
||||
margin-left: 30px;
|
||||
|
||||
.umb-child-selector__child.ui-sortable-handle {
|
||||
cursor: move;
|
||||
}
|
||||
}
|
||||
|
||||
.umb-child-selector__child-description {
|
||||
@@ -65,5 +66,6 @@
|
||||
}
|
||||
|
||||
.umb-child-selector__child-remove {
|
||||
cursor: pointer;
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
@@ -162,5 +162,6 @@
|
||||
&.umb-form-check--disabled {
|
||||
cursor: not-allowed !important;
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
background-color: transparent;
|
||||
border-color: @ui-action-discreet-border;
|
||||
transition: background-color .1s linear, border-color .1s linear, color .1s linear, width .1s ease-in-out, padding-left .1s ease-in-out;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&:focus-within, &:hover {
|
||||
@@ -39,6 +40,7 @@
|
||||
background-color: white;
|
||||
color: @ui-action-discreet-border-hover;
|
||||
border-color: @ui-action-discreet-border-hover;
|
||||
cursor: unset;
|
||||
}
|
||||
|
||||
input:focus, &:focus-within input, &.--has-value input {
|
||||
|
||||
@@ -135,6 +135,8 @@
|
||||
|
||||
|
||||
.umb-nested-content__header-bar:hover .umb-nested-content__icons,
|
||||
.umb-nested-content__header-bar:focus .umb-nested-content__icons,
|
||||
.umb-nested-content__header-bar:focus-within .umb-nested-content__icons,
|
||||
.umb-nested-content__item--active > .umb-nested-content__header-bar .umb-nested-content__icons {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
.umb-node-preview__icon {
|
||||
display: flex;
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
min-height: 25px;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 20px;
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
opacity: 0;
|
||||
transition: opacity 120ms;
|
||||
}
|
||||
.umb-property:focus-within .umb-property-actions__toggle,
|
||||
.umb-property:hover .umb-property-actions__toggle,
|
||||
.umb-property .umb-property-actions__toggle:focus {
|
||||
opacity: 1;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
.umb-property-file-upload {
|
||||
|
||||
.umb-upload-button-big {
|
||||
max-width: (@propertyEditorLimitedWidth - 40);
|
||||
display: block;
|
||||
padding: 20px;
|
||||
opacity: 1;
|
||||
|
||||
@@ -418,7 +418,7 @@
|
||||
// --------------------------------------------------
|
||||
// Limit width of specific property editors
|
||||
.umb-property-editor--limit-width {
|
||||
max-width: 800px;
|
||||
max-width: @propertyEditorLimitedWidth;
|
||||
}
|
||||
|
||||
// Horizontal dividers
|
||||
|
||||
@@ -722,6 +722,10 @@
|
||||
//
|
||||
// File upload
|
||||
// --------------------------------------------------
|
||||
.umb-fileupload {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.umb-fileupload .preview {
|
||||
border-radius: 5px;
|
||||
border: 1px solid @gray-6;
|
||||
|
||||
@@ -164,4 +164,13 @@
|
||||
|
||||
.mce-fullscreen {
|
||||
position: absolute;
|
||||
|
||||
.mce-in {
|
||||
position: fixed;
|
||||
top: 35px !important;
|
||||
}
|
||||
|
||||
umb-editor__overlay, .umb-editor {
|
||||
position: fixed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ ul.sections {
|
||||
transition: opacity .1s linear, box-shadow .1s;
|
||||
}
|
||||
|
||||
&.current a {
|
||||
&.current > a {
|
||||
color: @ui-active;
|
||||
|
||||
&::after {
|
||||
@@ -76,6 +76,13 @@ ul.sections {
|
||||
transition: opacity .1s linear;
|
||||
}
|
||||
|
||||
&.current {
|
||||
i {
|
||||
opacity: 1;
|
||||
background: @ui-active;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover i {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@ -244,6 +244,7 @@
|
||||
@paddingSmall: 2px 10px; // 26px
|
||||
@paddingMini: 0 6px; // 22px
|
||||
|
||||
@propertyEditorLimitedWidth: 800px;
|
||||
|
||||
// Disabled this to keep consistency throughout the backoffice UI. Untill a better solution is thought up, this will do.
|
||||
@baseBorderRadius: 3px; // 2px;
|
||||
|
||||
@@ -257,6 +257,7 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
evts.push(eventsService.on("app.ready", function (evt, data) {
|
||||
$scope.authenticated = true;
|
||||
ensureInit();
|
||||
ensureMainCulture();
|
||||
}));
|
||||
|
||||
// event for infinite editors
|
||||
@@ -279,8 +280,22 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For multi language sites, this ensures that mculture is set to either the last selected language or the default one
|
||||
*/
|
||||
function ensureMainCulture() {
|
||||
if ($location.search().mculture) {
|
||||
return;
|
||||
}
|
||||
var language = lastLanguageOrDefault();
|
||||
if (!language) {
|
||||
return;
|
||||
}
|
||||
// trigger a language selection in the next digest cycle
|
||||
$timeout(function () {
|
||||
$scope.selectLanguage(language);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the current state of the application, this configures the scope variables that control the main tree and language drop down
|
||||
@@ -385,28 +400,19 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
|
||||
if ($scope.languages.length > 1) {
|
||||
//if there's already one set, check if it exists
|
||||
var currCulture = null;
|
||||
var language = null;
|
||||
var mainCulture = $location.search().mculture;
|
||||
if (mainCulture) {
|
||||
currCulture = _.find($scope.languages, function (l) {
|
||||
language = _.find($scope.languages, function (l) {
|
||||
return l.culture.toLowerCase() === mainCulture.toLowerCase();
|
||||
});
|
||||
}
|
||||
if (!currCulture) {
|
||||
// no culture in the request, let's look for one in the cookie that's set when changing language
|
||||
var defaultCulture = $cookies.get("UMB_MCULTURE");
|
||||
if (!defaultCulture || !_.find($scope.languages, function (l) {
|
||||
return l.culture.toLowerCase() === defaultCulture.toLowerCase();
|
||||
})) {
|
||||
// no luck either, look for the default language
|
||||
var defaultLang = _.find($scope.languages, function (l) {
|
||||
return l.isDefault;
|
||||
});
|
||||
if (defaultLang) {
|
||||
defaultCulture = defaultLang.culture;
|
||||
}
|
||||
if (!language) {
|
||||
language = lastLanguageOrDefault();
|
||||
|
||||
if (language) {
|
||||
$location.search("mculture", language.culture);
|
||||
}
|
||||
$location.search("mculture", defaultCulture ? defaultCulture : null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +437,25 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function lastLanguageOrDefault() {
|
||||
if (!$scope.languages || $scope.languages.length <= 1) {
|
||||
return null;
|
||||
}
|
||||
// see if we can find a culture in the cookie set when changing language
|
||||
var lastCulture = $cookies.get("UMB_MCULTURE");
|
||||
var language = lastCulture ? _.find($scope.languages, function (l) {
|
||||
return l.culture.toLowerCase() === lastCulture.toLowerCase();
|
||||
}) : null;
|
||||
if (!language) {
|
||||
// no luck, look for the default language
|
||||
language = _.find($scope.languages, function (l) {
|
||||
return l.isDefault;
|
||||
});
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
function nodeExpandedHandler(args) {
|
||||
//store the reference to the expanded node path
|
||||
if (args.node) {
|
||||
|
||||
+3
-1
@@ -56,7 +56,8 @@
|
||||
"validation_validateAsEmail",
|
||||
"validation_validateAsNumber",
|
||||
"validation_validateAsUrl",
|
||||
"validation_enterCustomValidation"
|
||||
"validation_enterCustomValidation",
|
||||
"validation_fieldIsMandatory"
|
||||
];
|
||||
|
||||
localizationService.localizeMany(labels)
|
||||
@@ -66,6 +67,7 @@
|
||||
vm.labels.validateAsNumber = data[1];
|
||||
vm.labels.validateAsUrl = data[2];
|
||||
vm.labels.customValidation = data[3];
|
||||
vm.labels.fieldIsMandatory = data[4];
|
||||
|
||||
vm.validationTypes = [
|
||||
{
|
||||
|
||||
+6
-5
@@ -84,14 +84,15 @@
|
||||
|
||||
<h5><localize key="validation_validation"></localize></h5>
|
||||
|
||||
<label>
|
||||
<localize key="validation_fieldIsMandatory"></localize>
|
||||
</label>
|
||||
|
||||
<umb-toggle data-element="validation_mandatory"
|
||||
checked="model.property.validation.mandatory"
|
||||
on-click="vm.toggleValidation()">
|
||||
on-click="vm.toggleValidation()"
|
||||
label-on="{{vm.labels.fieldIsMandatory}}"
|
||||
label-off="{{vm.labels.fieldIsMandatory}}"
|
||||
show-labels="true"
|
||||
label-position="right"
|
||||
focus-when="{{vm.focusOnMandatoryField}}"
|
||||
class="mb1">
|
||||
</umb-toggle>
|
||||
|
||||
<input type="text"
|
||||
|
||||
+2
-2
@@ -130,8 +130,8 @@
|
||||
}
|
||||
|
||||
// diff requires a string
|
||||
property.value = property.value ? property.value : "";
|
||||
oldProperty.value = oldProperty.value ? oldProperty.value : "";
|
||||
property.value = property.value ? property.value + "" : "";
|
||||
oldProperty.value = oldProperty.value ? oldProperty.value + "" : "";
|
||||
|
||||
var diffProperty = {
|
||||
"alias": property.alias,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li data-element="section-expand" class="expand" ng-class="{ 'open': showTray === true }" ng-show="needTray">
|
||||
<li data-element="section-expand" class="expand" ng-class="{ 'open': showTray === true, current: currentSectionInOverflow() }" ng-show="needTray">
|
||||
<a href="#" ng-click="trayClick()" prevent-default>
|
||||
<span class="section__name"><i></i><i></i><i></i></span>
|
||||
</a>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
<!-- Dom element not found error -->
|
||||
<div ng-if="elementNotFound && !loadingStep">
|
||||
<umb-tour-step class="tc">
|
||||
<umb-tour-step class="tc" on-close="model.endTour()">
|
||||
<umb-tour-step-header>
|
||||
<h4 class="bold color-red">Oh, we got lost!</h4>
|
||||
</umb-tour-step-header>
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
<div class="umb-tour-step umb-tour-step--{{size}}">
|
||||
|
||||
|
||||
<div ng-if="hideClose !== true">
|
||||
<button class="icon-wrong umb-tour-step__close" ng-click="close()">
|
||||
<button type="button" class="icon-wrong umb-tour-step__close" hotkey="esc" ng-click="close()">
|
||||
<span class="sr-only">
|
||||
<localize key="general_close">Close</localize>
|
||||
</span>
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
<ul class="nav nav-stacked" style="margin-bottom: 0;">
|
||||
<li ng-repeat="url in currentUrls">
|
||||
<a href="{{url.text}}" target="_blank" ng-if="url.isUrl">
|
||||
<span ng-if="node.variants.length === 1 && url.culture" style="font-size: 13px; color: #cccccc; width: 50px;display: inline-block">{{url.culture}}</span>
|
||||
<span ng-if="currentUrlsHaveMultipleCultures && url.culture" style="font-size: 13px; color: #cccccc; width: 50px;display: inline-block">{{url.culture}}</span>
|
||||
<i class="icon icon-out"></i>
|
||||
<span>{{url.text}}</span>
|
||||
</a>
|
||||
<div ng-if="!url.isUrl" style="margin-top: 4px;">
|
||||
|
||||
<span ng-if="node.variants.length === 1 && url.culture" style="font-size: 13px; color: #cccccc; width: 50px;display: inline-block">{{url.culture}}</span>
|
||||
<span ng-if="currentUrlsHaveMultipleCultures && url.culture" style="font-size: 13px; color: #cccccc; width: 50px;display: inline-block">{{url.culture}}</span>
|
||||
<em>{{url.text}}</em>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -19,18 +19,20 @@
|
||||
<div class="umb-child-selector__child" ng-repeat="selectedChild in selectedChildren">
|
||||
<div class="umb-child-selector__child-description">
|
||||
<div class="umb-child-selector__child-icon-holder">
|
||||
<i class="umb-child-selector__child-icon {{ selectedChild.icon }}"></i>
|
||||
<i class="umb-child-selector__child-icon {{selectedChild.icon}}" aria-hidden="true"></i>
|
||||
</div>
|
||||
<span class="umb-child-selector__child-name"> {{ selectedChild.name }}</span>
|
||||
<span class="umb-child-selector__child-name">{{selectedChild.name}}</span>
|
||||
</div>
|
||||
<div class="umb-child-selector__child-actions">
|
||||
<i class="umb-child-selector__child-remove icon-trash" ng-click="removeChild(selectedChild, $index)"></i>
|
||||
<button type="button" class="umb-child-selector__child-remove" ng-click="removeChild(selectedChild, $index)">
|
||||
<i class="icon-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="" class="umb-child-selector__child -placeholder" ng-click="addChild($event)" hotkey="alt+shift+c">
|
||||
<button type="button" class="umb-child-selector__child -placeholder unsortable" ng-click="addChild($event)" hotkey="alt+shift+c">
|
||||
<div class="umb-child-selector__child-name -blue"><strong><localize key="shortcuts_addChild">Add Child</localize></strong></div>
|
||||
</a>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<div class="umb-user-preview">
|
||||
|
||||
<div class="umb-user-preview__avatar">
|
||||
<umb-avatar
|
||||
size="xxs"
|
||||
color="secondary"
|
||||
name="{{name}}"
|
||||
img-src="{{avatars[0]}}"
|
||||
img-srcset="{{avatars[1]}} 2x, {{avatars[2]}} 3x">
|
||||
<umb-avatar size="xxs"
|
||||
color="secondary"
|
||||
name="{{name}}"
|
||||
img-src="{{avatars[0]}}"
|
||||
img-srcset="{{avatars[1]}} 2x, {{avatars[2]}} 3x">
|
||||
</umb-avatar>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +14,6 @@
|
||||
</div>
|
||||
|
||||
<div class="umb-user-preview__actions">
|
||||
<a class="umb-user-preview__action umb-user-preview__action--red" title="Remove" href="" ng-if="allowRemove" ng-click="onRemove()"><localize key="general_remove">Remove</localize></a>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
<button type="button" class="umb-user-preview__action umb-user-preview__action--red btn-link" title="Remove" ng-if="allowRemove" ng-click="onRemove()"><localize key="general_remove">Remove</localize></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,10 +22,14 @@ function contentCreateController($scope,
|
||||
function initialize() {
|
||||
$scope.loading = true;
|
||||
$scope.allowedTypes = null;
|
||||
$scope.countTypes = contentTypeResource.getCount;
|
||||
|
||||
var getAllowedTypes = contentTypeResource.getAllowedTypes($scope.currentNode.id).then(function (data) {
|
||||
$scope.allowedTypes = iconHelper.formatContentTypeIcons(data);
|
||||
if ($scope.allowedTypes.length === 0) {
|
||||
contentTypeResource.getCount().then(function(count) {
|
||||
$scope.countTypes = count;
|
||||
});
|
||||
}
|
||||
});
|
||||
var getCurrentUser = authResource.getCurrentUser().then(function (currentUser) {
|
||||
if (currentUser.allowedSections.indexOf("settings") > -1) {
|
||||
|
||||
@@ -220,7 +220,7 @@ function startupLatestEditsController($scope) {
|
||||
}
|
||||
angular.module("umbraco").controller("Umbraco.Dashboard.StartupLatestEditsController", startupLatestEditsController);
|
||||
|
||||
function MediaFolderBrowserDashboardController($rootScope, $scope, $location, contentTypeResource, userService) {
|
||||
function MediaFolderBrowserDashboardController($scope, $routeParams, $location, contentTypeResource, userService) {
|
||||
|
||||
var currentUser = {};
|
||||
|
||||
@@ -251,6 +251,8 @@ function MediaFolderBrowserDashboardController($rootScope, $scope, $location, co
|
||||
view: dt.view
|
||||
};
|
||||
|
||||
// tell the list view to list content at root
|
||||
$routeParams.id = -1;
|
||||
});
|
||||
|
||||
} else if (currentUser.startMediaIds.length > 0){
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<umb-box>
|
||||
<umb-box-content>
|
||||
<h3><localize key="settingsDashboardVideos_trainingHeadline">Hours of Umbraco training videos are only a click away</localize></h3>
|
||||
<h3 class="bold"><localize key="settingsDashboardVideos_trainingHeadline">Hours of Umbraco training videos are only a click away</localize></h3>
|
||||
<localize key="settingsDashboardVideos_trainingDescription">
|
||||
<p>Want to master Umbraco? Spend a couple of minutes learning some best practices by watching one of these videos about using Umbraco. And visit <a href="http://umbraco.tv" target="_blank">umbraco.tv</a> for even more Umbraco videos</p>
|
||||
</localize>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user