Merge branch 'v8/dev' into v8/contrib
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
using Umbraco.Core;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Dashboards;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Dashboards
|
||||
{
|
||||
[Weight(10)]
|
||||
public class ContentDashboard : IDashboard
|
||||
{
|
||||
private readonly IContentDashboardSettings _dashboardSettings;
|
||||
private readonly IUserService _userService;
|
||||
private IAccessRule[] _accessRulesFromConfig;
|
||||
|
||||
public string Alias => "contentIntro";
|
||||
|
||||
public string[] Sections => new [] { "content" };
|
||||
public string[] Sections => new[] { "content" };
|
||||
|
||||
public string View => "views/dashboard/default/startupdashboardintro.html";
|
||||
|
||||
@@ -17,13 +23,54 @@ namespace Umbraco.Web.Dashboards
|
||||
{
|
||||
get
|
||||
{
|
||||
var rules = new IAccessRule[]
|
||||
var rules = AccessRulesFromConfig;
|
||||
|
||||
if (rules.Length == 0)
|
||||
{
|
||||
new AccessRule {Type = AccessRuleType.Deny, Value = Constants.Security.TranslatorGroupAlias},
|
||||
new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias}
|
||||
};
|
||||
rules = new IAccessRule[]
|
||||
{
|
||||
new AccessRule {Type = AccessRuleType.Deny, Value = Constants.Security.TranslatorGroupAlias},
|
||||
new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias}
|
||||
};
|
||||
}
|
||||
|
||||
return rules;
|
||||
}
|
||||
}
|
||||
|
||||
private IAccessRule[] AccessRulesFromConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_accessRulesFromConfig is null)
|
||||
{
|
||||
var rules = new List<IAccessRule>();
|
||||
|
||||
if (_dashboardSettings.AllowContentDashboardAccessToAllUsers)
|
||||
{
|
||||
var allUserGroups = _userService.GetAllUserGroups();
|
||||
|
||||
foreach (var userGroup in allUserGroups)
|
||||
{
|
||||
rules.Add(new AccessRule
|
||||
{
|
||||
Type = AccessRuleType.Grant,
|
||||
Value = userGroup.Alias
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_accessRulesFromConfig = rules.ToArray();
|
||||
}
|
||||
|
||||
return _accessRulesFromConfig;
|
||||
}
|
||||
}
|
||||
|
||||
public ContentDashboard(IContentDashboardSettings dashboardSettings, IUserService userService)
|
||||
{
|
||||
_dashboardSettings = dashboardSettings;
|
||||
_userService = userService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Dashboards;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Services;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
@@ -52,8 +53,9 @@ namespace Umbraco.Web.Editors
|
||||
var allowedSections = string.Join(",", user.AllowedSections);
|
||||
var language = user.Language;
|
||||
var version = UmbracoVersion.SemanticVersion.ToSemanticString();
|
||||
var isAdmin = user.IsAdmin();
|
||||
|
||||
var url = string.Format(baseUrl + "{0}?section={0}&allowed={1}&lang={2}&version={3}", section, allowedSections, language, version);
|
||||
var url = string.Format(baseUrl + "{0}?section={0}&allowed={1}&lang={2}&version={3}&admin={4}", section, allowedSections, language, version, isAdmin);
|
||||
var key = "umbraco-dynamic-dashboard-" + language + allowedSections.Replace(",", "-") + section;
|
||||
|
||||
var content = AppCaches.RuntimeCache.GetCacheItem<JObject>(key);
|
||||
|
||||
@@ -319,7 +319,10 @@ namespace Umbraco.Web.Scheduling
|
||||
// create a new token source since this is a new process
|
||||
_shutdownTokenSource = new CancellationTokenSource();
|
||||
_shutdownToken = _shutdownTokenSource.Token;
|
||||
_runningTask = Task.Run(async () => await Pump().ConfigureAwait(false), _shutdownToken);
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
_runningTask = Task.Run(async () => await Pump().ConfigureAwait(false), _shutdownToken);
|
||||
}
|
||||
|
||||
_logger.Debug<BackgroundTaskRunner, string>("{LogPrefix} Starting", _logPrefix);
|
||||
}
|
||||
@@ -544,10 +547,14 @@ namespace Umbraco.Web.Scheduling
|
||||
try
|
||||
{
|
||||
if (bgTask.IsAsync)
|
||||
{
|
||||
// configure await = false since we don't care about the context, we're on a background thread.
|
||||
await bgTask.RunAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
bgTask.Run();
|
||||
}
|
||||
}
|
||||
finally // ensure we disposed - unless latched again ie wants to re-run
|
||||
{
|
||||
@@ -710,14 +717,20 @@ namespace Umbraco.Web.Scheduling
|
||||
// with a single aspnet thread during shutdown and we don't want to delay other calls to IRegisteredObject.Stop.
|
||||
if (!immediate)
|
||||
{
|
||||
return Task.Run(StopInitial, CancellationToken.None);
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
return Task.Run(StopInitial, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_terminated) return Task.CompletedTask;
|
||||
return Task.Run(StopImmediate, CancellationToken.None);
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
return Task.Run(StopImmediate, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user