Merge branch 'netcore/dev' into netcore/temp/remove-backofficeusermanager-static-events

This commit is contained in:
Kenn Jacobsen
2021-03-01 20:15:54 +01:00
53 changed files with 372 additions and 341 deletions

View File

@@ -1,47 +0,0 @@
using System;
using Umbraco.Cms.Core.Web;
namespace Umbraco.Cms.Core.Editors
{
public sealed class EditorModelEventArgs<T> : EditorModelEventArgs
{
private readonly EditorModelEventArgs _baseArgs;
private T _model;
public EditorModelEventArgs(EditorModelEventArgs baseArgs)
: base(baseArgs.Model, baseArgs.UmbracoContext)
{
_baseArgs = baseArgs;
Model = (T)baseArgs.Model;
}
public EditorModelEventArgs(T model, IUmbracoContext umbracoContext)
: base(model, umbracoContext)
{
Model = model;
}
public new T Model
{
get => _model;
set
{
_model = value;
if (_baseArgs != null)
_baseArgs.Model = _model;
}
}
}
public class EditorModelEventArgs : EventArgs
{
public EditorModelEventArgs(object model, IUmbracoContext umbracoContext)
{
Model = model;
UmbracoContext = umbracoContext;
}
public object Model { get; set; }
public IUmbracoContext UmbracoContext { get; }
}
}

View File

@@ -54,7 +54,7 @@ namespace Umbraco.Cms.Infrastructure
}
else
{
await client.SendAsync(mailMessage);
client.Send(mailMessage);
}
await client.DisconnectAsync(true);

View File

@@ -106,22 +106,39 @@ namespace Umbraco.Cms.Core.Packaging
private IEnumerable<string> RunPackageActions(PackageDefinition packageDefinition, IEnumerable<PackageAction> actions)
{
foreach (var n in actions)
var actionsElement = XElement.Parse(packageDefinition.Actions);
foreach (PackageAction action in actions)
{
//if there is an undo section then save it to the definition so we can run it at uninstallation
var undo = n.Undo;
var undo = action.Undo;
if (undo)
packageDefinition.Actions += n.XmlData.ToString();
{
actionsElement.Add(action.XmlData);
}
//Run the actions tagged only for 'install'
if (n.RunAt != ActionRunAt.Install) continue;
if (action.RunAt != ActionRunAt.Install)
{
continue;
}
if (n.Alias.IsNullOrWhiteSpace()) continue;
if (action.Alias.IsNullOrWhiteSpace())
{
continue;
}
//run the actions and report errors
if (!_packageActionRunner.RunPackageAction(packageDefinition.Name, n.Alias, n.XmlData, out var err))
foreach (var e in err) yield return e;
if (!_packageActionRunner.RunPackageAction(packageDefinition.Name, action.Alias, action.XmlData, out var err))
{
foreach (var e in err)
{
yield return e;
}
}
}
packageDefinition.Actions = actionsElement.ToString();
}
private IEnumerable<string> UndoPackageActions(IPackageInfo packageDefinition, IEnumerable<PackageAction> actions)

View File

@@ -32,7 +32,7 @@ namespace Umbraco.Cms.Core.Services.Implement
private readonly IHostingEnvironment _hostingEnvironment;
private const string PartialViewHeader = "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage";
private const string PartialViewMacroHeader = "@inherits Umbraco.Web.Common.Macros.PartialViewMacroPage";
private const string PartialViewMacroHeader = "@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage";
public FileService(IScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory,
IStylesheetRepository stylesheetRepository, IScriptRepository scriptRepository, ITemplateRepository templateRepository,

View File

@@ -506,7 +506,7 @@ context('Content', () => {
const pickerDocTypeName = 'Content picker doc type';
const pickerDocTypeAlias = AliasHelper.toAlias(pickerDocTypeName);
const pickedDocTypeName = 'Picked content document type';
const pickedDocTypeAlias = AliasHelper.toAlias(pickedDocTypeName);
cy.deleteAllContent();
cy.umbracoEnsureDocumentTypeNameNotExists(pickerDocTypeName);
cy.umbracoEnsureTemplateNameNotExists(pickerDocTypeName);
@@ -515,6 +515,7 @@ context('Content', () => {
// Create the content type and content we'll be picking from.
const pickedDocType = new DocumentTypeBuilder()
.withName(pickedDocTypeName)
.withAlias(pickedDocTypeAlias)
.withAllowAsRoot(true)
.addGroup()
.addTextBoxProperty()
@@ -559,19 +560,13 @@ context('Content', () => {
cy.saveDocumentType(pickerDocType);
// Edit it the template to allow us to verify the rendered view.
cy.editTemplate(pickerDocTypeName, `@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.ContentPickerDocType>
@using ContentModels = Umbraco.Web.PublishedModels;
cy.editTemplate(pickerDocTypeName, `@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentPickerDocType>
@{
Layout = null;
var pickedItem = Model.Picker as PickedContentDocumentType;
}
@{
IPublishedContent typedContentPicker = Model.Value<IPublishedContent>("picker");
if (typedContentPicker != null)
{
<p>@typedContentPicker.Value("text")</p>
}
}`);
<p>@pickedItem.Text</p>`);
// Create content with content picker
cy.get('.umb-tree-root-link').rightclick();

View File

@@ -36,9 +36,6 @@
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Perfolizer, Version=0.2.1.0, Culture=neutral, PublicKeyToken=e864f2ec9c0b6d4c">
<HintPath>C:\Users\Berg\.nuget\packages\perfolizer\0.2.1\lib\netstandard2.0\Perfolizer.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -111,4 +108,4 @@
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>

View File

@@ -338,7 +338,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
switch (type)
{
case Constants.Trees.PartialViews:
if (IsDirectory(virtualPath, Constants.SystemDirectories.PartialViews))
if (IsDirectory(_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.PartialViews, virtualPath))))
{
_fileService.DeletePartialViewFolder(virtualPath);
return Ok();
@@ -350,7 +350,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return new UmbracoProblemResult("No Partial View or folder found with the specified path", HttpStatusCode.NotFound);
case Constants.Trees.PartialViewMacros:
if (IsDirectory(virtualPath, Constants.SystemDirectories.MacroPartials))
if (IsDirectory(_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.MacroPartials, virtualPath))))
{
_fileService.DeletePartialViewMacroFolder(virtualPath);
return Ok();
@@ -362,7 +362,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return new UmbracoProblemResult("No Partial View Macro or folder found with the specified path", HttpStatusCode.NotFound);
case Constants.Trees.Scripts:
if (IsDirectory(virtualPath, _globalSettings.UmbracoScriptsPath))
if (IsDirectory(_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoScriptsPath, virtualPath))))
{
_fileService.DeleteScriptFolder(virtualPath);
return Ok();
@@ -374,7 +374,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
return new UmbracoProblemResult("No Script or folder found with the specified path", HttpStatusCode.NotFound);
case Constants.Trees.Stylesheets:
if (IsDirectory(virtualPath, _globalSettings.UmbracoCssPath))
if (IsDirectory(_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoCssPath, virtualPath))))
{
_fileService.DeleteStyleSheetFolder(virtualPath);
return Ok();
@@ -665,9 +665,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return value;
}
private bool IsDirectory(string virtualPath, string systemDirectory)
private bool IsDirectory(string path)
{
var path = _hostingEnvironment.MapPathContentRoot(systemDirectory + "/" + virtualPath);
var dirInfo = new DirectoryInfo(path);
return dirInfo.Attributes == FileAttributes.Directory;
}

View File

@@ -1,75 +0,0 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Filters;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.Editors;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
namespace Umbraco.Cms.Web.BackOffice.Filters
{
/// <summary>
/// Used to emit events for editor models in the back office
/// </summary>
public sealed class EditorModelEventManager
{
public static event TypedEventHandler<ActionExecutedContext, EditorModelEventArgs<ContentItemDisplay>> SendingContentModel;
public static event TypedEventHandler<ActionExecutedContext, EditorModelEventArgs<MediaItemDisplay>> SendingMediaModel;
public static event TypedEventHandler<ActionExecutedContext, EditorModelEventArgs<MemberDisplay>> SendingMemberModel;
public static event TypedEventHandler<ActionExecutedContext, EditorModelEventArgs<UserDisplay>> SendingUserModel;
public static event TypedEventHandler<ActionExecutedContext, EditorModelEventArgs<IEnumerable<Tab<IDashboardSlim>>>> SendingDashboardSlimModel;
private static void OnSendingDashboardModel(ActionExecutedContext sender, EditorModelEventArgs<IEnumerable<Tab<IDashboardSlim>>> e)
{
var handler = SendingDashboardSlimModel;
handler?.Invoke(sender, e);
}
private static void OnSendingUserModel(ActionExecutedContext sender, EditorModelEventArgs<UserDisplay> e)
{
var handler = SendingUserModel;
handler?.Invoke(sender, e);
}
private static void OnSendingContentModel(ActionExecutedContext sender, EditorModelEventArgs<ContentItemDisplay> e)
{
var handler = SendingContentModel;
handler?.Invoke(sender, e);
}
private static void OnSendingMediaModel(ActionExecutedContext sender, EditorModelEventArgs<MediaItemDisplay> e)
{
var handler = SendingMediaModel;
handler?.Invoke(sender, e);
}
private static void OnSendingMemberModel(ActionExecutedContext sender, EditorModelEventArgs<MemberDisplay> e)
{
var handler = SendingMemberModel;
handler?.Invoke(sender, e);
}
/// <summary>
/// Based on the type, emit's a specific event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void EmitEvent(ActionExecutedContext sender, EditorModelEventArgs e)
{
if (e.Model is ContentItemDisplay)
OnSendingContentModel(sender, new EditorModelEventArgs<ContentItemDisplay>(e));
if (e.Model is MediaItemDisplay)
OnSendingMediaModel(sender, new EditorModelEventArgs<MediaItemDisplay>(e));
if (e.Model is MemberDisplay)
OnSendingMemberModel(sender, new EditorModelEventArgs<MemberDisplay>(e));
if (e.Model is UserDisplay)
OnSendingUserModel(sender, new EditorModelEventArgs<UserDisplay>(e));
if (e.Model is IEnumerable<Tab<IDashboardSlim>>)
OnSendingDashboardModel(sender, new EditorModelEventArgs<IEnumerable<Tab<IDashboardSlim>>>(e));
}
}
}

View File

@@ -1,7 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.Editors;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Web;
using Umbraco.Extensions;
@@ -25,14 +29,18 @@ namespace Umbraco.Cms.Web.BackOffice.Filters
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
private readonly IEventAggregator _eventAggregator;
public OutgoingEditorModelEventFilter(
IUmbracoContextAccessor umbracoContextAccessor,
IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IEventAggregator eventAggregator)
{
_umbracoContextAccessor = umbracoContextAccessor
?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
_backOfficeSecurityAccessor = backOfficeSecurityAccessor
?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor));
_eventAggregator = eventAggregator
?? throw new ArgumentNullException(nameof(eventAggregator));
}
public void OnActionExecuted(ActionExecutedContext context)
@@ -40,18 +48,30 @@ namespace Umbraco.Cms.Web.BackOffice.Filters
if (context.Result == null) return;
var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
var user = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
if (user == null) return;
var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser;
if (currentUser == null) return;
if (context.Result is ObjectResult objectContent)
{
var model = objectContent.Value;
if (model != null)
switch (model)
{
var args = new EditorModelEventArgs(model, umbracoContext);
EditorModelEventManager.EmitEvent(context, args);
objectContent.Value = args.Model;
case ContentItemDisplay content:
_eventAggregator.Publish(new SendingContentNotification(content, umbracoContext));
break;
case MediaItemDisplay media:
_eventAggregator.Publish(new SendingMediaNotification(media, umbracoContext));
break;
case MemberDisplay member:
_eventAggregator.Publish(new SendingMemberNotification(member, umbracoContext));
break;
case UserDisplay user:
_eventAggregator.Publish(new SendingUserNotification(user, umbracoContext));
break;
case IEnumerable<Tab<IDashboardSlim>> dashboards:
_eventAggregator.Publish(new SendingDashboardsNotification(dashboards, umbracoContext));
break;
}
}
}

View File

@@ -0,0 +1,19 @@
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Web;
namespace Umbraco.Cms.Web.BackOffice.Filters
{
public class SendingContentNotification : INotification
{
public IUmbracoContext UmbracoContext { get; }
public ContentItemDisplay Content { get; }
public SendingContentNotification(ContentItemDisplay content, IUmbracoContext umbracoContext)
{
Content = content;
UmbracoContext = umbracoContext;
}
}
}

View File

@@ -0,0 +1,21 @@
using System.Collections.Generic;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Web;
namespace Umbraco.Cms.Web.BackOffice.Filters
{
public class SendingDashboardsNotification : INotification
{
public IUmbracoContext UmbracoContext { get; }
public IEnumerable<Tab<IDashboardSlim>> Dashboards { get; }
public SendingDashboardsNotification(IEnumerable<Tab<IDashboardSlim>> dashboards, IUmbracoContext umbracoContext)
{
Dashboards = dashboards;
UmbracoContext = umbracoContext;
}
}
}

View File

@@ -0,0 +1,19 @@
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Web;
namespace Umbraco.Cms.Web.BackOffice.Filters
{
public class SendingMediaNotification : INotification
{
public IUmbracoContext UmbracoContext { get; }
public MediaItemDisplay Media { get; }
public SendingMediaNotification(MediaItemDisplay media, IUmbracoContext umbracoContext)
{
Media = media;
UmbracoContext = umbracoContext;
}
}
}

View File

@@ -0,0 +1,19 @@
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Web;
namespace Umbraco.Cms.Web.BackOffice.Filters
{
public class SendingMemberNotification : INotification
{
public IUmbracoContext UmbracoContext { get; }
public MemberDisplay Member { get; }
public SendingMemberNotification(MemberDisplay member, IUmbracoContext umbracoContext)
{
Member = member;
UmbracoContext = umbracoContext;
}
}
}

View File

@@ -0,0 +1,19 @@
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Web;
namespace Umbraco.Cms.Web.BackOffice.Filters
{
public class SendingUserNotification : INotification
{
public IUmbracoContext UmbracoContext { get; }
public UserDisplay User { get; }
public SendingUserNotification(UserDisplay user, IUmbracoContext umbracoContext)
{
User = user;
UmbracoContext = umbracoContext;
}
}
}

View File

@@ -265,7 +265,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
}
var controller = (TreeControllerBase)result.Value;
var rootNodeResult = controller.GetRootNode(querystring);
var rootNodeResult = await controller.GetRootNode(querystring);
if (!(rootNodeResult.Result is null))
{
return rootNodeResult.Result;
@@ -305,7 +305,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
}
var controller = (TreeControllerBase)controllerResult.Value;
return controller.GetNodes(id.ToInvariantString(), querystring);
return await controller.GetNodes(id.ToInvariantString(), querystring);
}
/// <summary>

View File

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Models.Trees;
@@ -40,8 +41,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IMenuItemCollectionFactory menuItemCollectionFactory,
IContentService contentService,
IContentTypeService contentTypeService,
IEntityService entityService)
: base(localizedTextService, umbracoApiControllerTypeCollection)
IEntityService entityService,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_menuItemCollectionFactory = menuItemCollectionFactory ?? throw new ArgumentNullException(nameof(menuItemCollectionFactory));
_contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));

View File

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Mail;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
@@ -56,8 +57,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IContentService contentService,
IPublicAccessService publicAccessService,
ILocalizationService localizationService,
IEventAggregator eventAggregator,
IEmailSender emailSender)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService, eventAggregator)
{
_treeSearcher = treeSearcher;
_actions = actions;

View File

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Models.Trees;
@@ -39,9 +40,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILogger<ContentTreeControllerBase> logger,
ActionCollection actionCollection,
IUserService userService,
IDataTypeService dataTypeService
IDataTypeService dataTypeService,
IEventAggregator eventAggregator
)
: base(localizedTextService, umbracoApiControllerTypeCollection)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_entityService = entityService;
_backofficeSecurityAccessor = backofficeSecurityAccessor;

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Trees;
@@ -30,7 +31,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
private readonly IContentTypeService _contentTypeService;
private readonly IEntityService _entityService;
public ContentTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IContentTypeService contentTypeService, IEntityService entityService) : base(localizedTextService, umbracoApiControllerTypeCollection)
public ContentTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IContentTypeService contentTypeService, IEntityService entityService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_treeSearcher = treeSearcher;
_menuItemCollectionFactory = menuItemCollectionFactory;

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Trees;
@@ -31,7 +32,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
private readonly IDataTypeService _dataTypeService;
public DataTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IEntityService entityService, IDataTypeService dataTypeService) : base(localizedTextService, umbracoApiControllerTypeCollection)
public DataTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IEntityService entityService, IDataTypeService dataTypeService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_treeSearcher = treeSearcher;
_menuItemCollectionFactory = menuItemCollectionFactory;

View File

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
@@ -28,7 +29,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
private readonly ILocalizationService _localizationService;
public DictionaryTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, ILocalizationService localizationService) : base(localizedTextService, umbracoApiControllerTypeCollection)
public DictionaryTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, ILocalizationService localizationService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_menuItemCollectionFactory = menuItemCollectionFactory;
_localizationService = localizationService;

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
@@ -20,9 +21,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
protected FileSystemTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory
IMenuItemCollectionFactory menuItemCollectionFactory,
IEventAggregator eventAggregator
)
: base(localizedTextService, umbracoApiControllerTypeCollection)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
MenuItemCollectionFactory = menuItemCollectionFactory;
}

View File

@@ -1,4 +1,5 @@
using Umbraco.Cms.Core;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -18,8 +19,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IPhysicalFileSystem fileSystem)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory)
IPhysicalFileSystem fileSystem,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
{
FileSystem = fileSystem;
}

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.Common.Attributes;
@@ -19,8 +20,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
public LanguageTreeController(
ILocalizedTextService textService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection)
: base(textService, umbracoApiControllerTypeCollection)
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IEventAggregator eventAggregator)
: base(textService, umbracoApiControllerTypeCollection, eventAggregator)
{
}
protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.Common.Attributes;
@@ -18,8 +19,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
{
public LogViewerTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection)
: base(localizedTextService, umbracoApiControllerTypeCollection)
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
}

View File

@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -22,7 +23,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
private readonly IMacroService _macroService;
public MacrosTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, IMacroService macroService) : base(localizedTextService, umbracoApiControllerTypeCollection)
public MacrosTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IMenuItemCollectionFactory menuItemCollectionFactory, IMacroService macroService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_menuItemCollectionFactory = menuItemCollectionFactory;
_macroService = macroService;

View File

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Entities;
@@ -45,8 +46,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IUserService userService,
IDataTypeService dataTypeService,
UmbracoTreeSearcher treeSearcher,
IMediaService mediaService)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService)
IMediaService mediaService,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService, eventAggregator)
{
_treeSearcher = treeSearcher;
_mediaService = mediaService;

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Trees;
@@ -30,7 +31,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
private readonly IMediaTypeService _mediaTypeService;
private readonly IEntityService _entityService;
public MediaTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IMediaTypeService mediaTypeService, IEntityService entityService) : base(localizedTextService, umbracoApiControllerTypeCollection)
public MediaTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IMediaTypeService mediaTypeService, IEntityService entityService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_treeSearcher = treeSearcher;
_menuItemCollectionFactory = menuItemCollectionFactory;

View File

@@ -1,9 +1,10 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.Common.Attributes;
@@ -24,8 +25,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IMemberGroupService memberGroupService)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory)
IMemberGroupService memberGroupService,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
{
_memberGroupService = memberGroupService;
}

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Trees;
@@ -41,8 +42,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IMenuItemCollectionFactory menuItemCollectionFactory,
IMemberService memberService,
IMemberTypeService memberTypeService,
IBackOfficeSecurityAccessor backofficeSecurityAccessor)
: base(localizedTextService, umbracoApiControllerTypeCollection)
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_treeSearcher = treeSearcher;
_menuItemCollectionFactory = menuItemCollectionFactory;

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -20,8 +21,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
protected MemberTypeAndGroupTreeControllerBase(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory)
: base(localizedTextService, umbracoApiControllerTypeCollection)
IMenuItemCollectionFactory menuItemCollectionFactory,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
MenuItemCollectionFactory = menuItemCollectionFactory;
}

View File

@@ -1,9 +1,10 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Services;
@@ -29,8 +30,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
UmbracoTreeSearcher treeSearcher,
IMemberTypeService memberTypeService)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory)
IMemberTypeService memberTypeService,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
{
_treeSearcher = treeSearcher;
_memberTypeService = memberTypeService;

View File

@@ -1,25 +0,0 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.Trees;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
public class MenuRenderingEventArgs : TreeRenderingEventArgs
{
/// <summary>
/// The tree node id that the menu is rendering for
/// </summary>
public string NodeId { get; private set; }
/// <summary>
/// The menu being rendered
/// </summary>
public MenuItemCollection Menu { get; private set; }
public MenuRenderingEventArgs(string nodeId, MenuItemCollection menu, FormCollection queryStrings)
: base(queryStrings)
{
NodeId = nodeId;
Menu = menu;
}
}
}

View File

@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Trees;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
/// <summary>
/// A notification that allows developers to modify the menu that is being rendered
/// </summary>
/// <remarks>
/// Developers can add/remove/replace/insert/update/etc... any of the tree items in the collection.
/// </remarks>
public class MenuRenderingNotification : INotification
{
/// <summary>
/// The tree node id that the menu is rendering for
/// </summary>
public string NodeId { get; }
/// <summary>
/// The menu being rendered
/// </summary>
public MenuItemCollection Menu { get; }
/// <summary>
/// The query string of the current request
/// </summary>
public FormCollection QueryString { get; }
public MenuRenderingNotification(string nodeId, MenuItemCollection menu, FormCollection queryString)
{
NodeId = nodeId;
Menu = menu;
QueryString = queryString;
}
}
}

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.Common.Attributes;
@@ -21,8 +22,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
public PackagesTreeController(
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory)
: base(localizedTextService, umbracoApiControllerTypeCollection)
IMenuItemCollectionFactory menuItemCollectionFactory,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_menuItemCollectionFactory = menuItemCollectionFactory;
}

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -30,8 +31,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IFileSystems fileSystems)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, fileSystems)
IFileSystems fileSystems,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, fileSystems, eventAggregator)
{
FileSystem = fileSystems.MacroPartialsFileSystem;
}

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -30,8 +31,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IFileSystems fileSystems)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory)
IFileSystems fileSystems,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
{
FileSystem = fileSystems.PartialViewsFileSystem;
}

View File

@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -27,8 +28,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IRelationService relationService)
: base(localizedTextService, umbracoApiControllerTypeCollection)
IRelationService relationService,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_menuItemCollectionFactory = menuItemCollectionFactory;
_relationService = relationService;

View File

@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Trees;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
/// <summary>
/// A notification that allows developer to modify the root tree node that is being rendered
/// </summary>
public class RootNodeRenderingNotification : INotification
{
/// <summary>
/// The root node being rendered
/// </summary>
public TreeNode Node { get; }
/// <summary>
/// The query string of the current request
/// </summary>
public FormCollection QueryString { get; }
public RootNodeRenderingNotification(TreeNode node, FormCollection queryString)
{
Node = node;
QueryString = queryString;
}
}
}

View File

@@ -1,4 +1,5 @@
using Umbraco.Cms.Core;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -22,8 +23,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IFileSystems fileSystems)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory)
IFileSystems fileSystems,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
{
FileSystem = fileSystems.ScriptsFileSystem;
}

View File

@@ -1,4 +1,5 @@
using Umbraco.Cms.Core;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
@@ -22,8 +23,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IMenuItemCollectionFactory menuItemCollectionFactory,
IFileSystems fileSystems)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory)
IFileSystems fileSystems,
IEventAggregator eventAggregator)
: base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
{
FileSystem = fileSystems.StylesheetsFileSystem;
}

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Entities;
@@ -35,8 +36,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
IMenuItemCollectionFactory menuItemCollectionFactory,
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IFileService fileService
) : base(localizedTextService, umbracoApiControllerTypeCollection)
IFileService fileService,
IEventAggregator eventAggregator
) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_treeSearcher = treeSearcher;
_menuItemCollectionFactory = menuItemCollectionFactory;

View File

@@ -1,6 +1,7 @@
using System;
using System;
using System.Collections.Concurrent;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Extensions;
@@ -18,8 +19,8 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
protected ILocalizedTextService LocalizedTextService { get; }
protected TreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection)
: base(umbracoApiControllerTypeCollection)
protected TreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IEventAggregator eventAggregator)
: base(umbracoApiControllerTypeCollection, eventAggregator)
{
LocalizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
_treeAttribute = GetTreeAttribute();

View File

@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
@@ -27,10 +28,12 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
// TODO: Need to set this, but from where?
// Presumably not injecting as this will be a base controller for package/solution developers.
private readonly UmbracoApiControllerTypeCollection _apiControllers;
private readonly IEventAggregator _eventAggregator;
protected TreeControllerBase(UmbracoApiControllerTypeCollection apiControllers)
protected TreeControllerBase(UmbracoApiControllerTypeCollection apiControllers, IEventAggregator eventAggregator)
{
_apiControllers = apiControllers;
_eventAggregator = eventAggregator;
}
/// <summary>
@@ -85,7 +88,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
/// </summary>
/// <param name="queryStrings"></param>
/// <returns></returns>
public ActionResult<TreeNode> GetRootNode([ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
public async Task<ActionResult<TreeNode>> GetRootNode([ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
{
if (queryStrings == null) queryStrings = FormCollection.Empty;
var nodeResult = CreateRootNode(queryStrings);
@@ -109,7 +112,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
if (IsDialog(queryStrings))
node.RoutePath = "#";
OnRootNodeRendering(this, new TreeNodeRenderingEventArgs(node, queryStrings));
await _eventAggregator.PublishAsync(new RootNodeRenderingNotification(node, queryStrings));
return node;
}
@@ -126,7 +129,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
/// We are allowing an arbitrary number of query strings to be passed in so that developers are able to persist custom data from the front-end
/// to the back end to be used in the query for model data.
/// </remarks>
public ActionResult<TreeNodeCollection> GetNodes(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
public async Task<ActionResult<TreeNodeCollection>> GetNodes(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
{
if (queryStrings == null) queryStrings = FormCollection.Empty;
var nodesResult = GetTreeNodes(id, queryStrings);
@@ -147,7 +150,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
node.RoutePath = "#";
//raise the event
OnTreeNodesRendering(this, new TreeNodesRenderingEventArgs(nodes, queryStrings));
await _eventAggregator.PublishAsync(new TreeNodesRenderingNotification(nodes, queryStrings));
return nodes;
}
@@ -158,7 +161,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
public ActionResult<MenuItemCollection> GetMenu(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
public async Task<ActionResult<MenuItemCollection>> GetMenu(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
{
if (queryStrings == null) queryStrings = FormCollection.Empty;
var menuResult = GetMenuForNode(id, queryStrings);
@@ -169,7 +172,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
var menu = menuResult.Value;
//raise the event
OnMenuRendering(this, new MenuRenderingEventArgs(id, menu, queryStrings));
await _eventAggregator.PublishAsync(new MenuRenderingNotification(id, menu, queryStrings));
return menu;
}
@@ -374,45 +377,5 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
queryStrings.TryGetValue(TreeQueryStringParameters.Use, out var use);
return use == "dialog";
}
/// <summary>
/// An event that allows developers to modify the tree node collection that is being rendered
/// </summary>
/// <remarks>
/// Developers can add/remove/replace/insert/update/etc... any of the tree items in the collection.
/// </remarks>
public static event TypedEventHandler<TreeControllerBase, TreeNodesRenderingEventArgs> TreeNodesRendering;
private static void OnTreeNodesRendering(TreeControllerBase instance, TreeNodesRenderingEventArgs e)
{
var handler = TreeNodesRendering;
handler?.Invoke(instance, e);
}
/// <summary>
/// An event that allows developer to modify the root tree node that is being rendered
/// </summary>
public static event TypedEventHandler<TreeControllerBase, TreeNodeRenderingEventArgs> RootNodeRendering;
// internal for temp class below - kill eventually!
internal static void OnRootNodeRendering(TreeControllerBase instance, TreeNodeRenderingEventArgs e)
{
var handler = RootNodeRendering;
handler?.Invoke(instance, e);
}
/// <summary>
/// An event that allows developers to modify the menu that is being rendered
/// </summary>
/// <remarks>
/// Developers can add/remove/replace/insert/update/etc... any of the tree items in the collection.
/// </remarks>
public static event TypedEventHandler<TreeControllerBase, MenuRenderingEventArgs> MenuRendering;
private static void OnMenuRendering(TreeControllerBase instance, MenuRenderingEventArgs e)
{
var handler = MenuRendering;
handler?.Invoke(instance, e);
}
}
}

View File

@@ -1,16 +0,0 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.Trees;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
public class TreeNodeRenderingEventArgs : TreeRenderingEventArgs
{
public TreeNode Node { get; private set; }
public TreeNodeRenderingEventArgs(TreeNode node, FormCollection queryStrings)
: base(queryStrings)
{
Node = node;
}
}
}

View File

@@ -1,16 +0,0 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.Trees;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
public class TreeNodesRenderingEventArgs : TreeRenderingEventArgs
{
public TreeNodeCollection Nodes { get; private set; }
public TreeNodesRenderingEventArgs(TreeNodeCollection nodes, FormCollection queryStrings)
: base(queryStrings)
{
Nodes = nodes;
}
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Http;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Trees;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
/// <summary>
/// A notification that allows developers to modify the tree node collection that is being rendered
/// </summary>
/// <remarks>
/// Developers can add/remove/replace/insert/update/etc... any of the tree items in the collection.
/// </remarks>
public class TreeNodesRenderingNotification : INotification
{
/// <summary>
/// The tree nodes being rendered
/// </summary>
public TreeNodeCollection Nodes { get; }
/// <summary>
/// The query string of the current request
/// </summary>
public FormCollection QueryString { get; }
public TreeNodesRenderingNotification(TreeNodeCollection nodes, FormCollection queryString)
{
Nodes = nodes;
QueryString = queryString;
}
}
}

View File

@@ -1,15 +0,0 @@
using System;
using Microsoft.AspNetCore.Http;
namespace Umbraco.Cms.Web.BackOffice.Trees
{
public class TreeRenderingEventArgs : EventArgs
{
public FormCollection QueryStrings { get; private set; }
public TreeRenderingEventArgs(FormCollection queryStrings)
{
QueryStrings = queryStrings;
}
}
}

View File

@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.Common.Attributes;
@@ -21,8 +22,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
public UserTreeController(
IMenuItemCollectionFactory menuItemCollectionFactory,
ILocalizedTextService localizedTextService,
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection
) : base(localizedTextService, umbracoApiControllerTypeCollection)
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
IEventAggregator eventAggregator
) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
{
_menuItemCollectionFactory = menuItemCollectionFactory;
}

View File

@@ -175,7 +175,7 @@
<div ng-repeat="template in ::vm.templates | orderBy:'name'">
<umb-checkbox model="template.selected"
on-change="vm.selectTemplate(template)"
text="{{template.name}}">umb-expansion-panel__content
text="{{template.name}}">
</umb-checkbox>
</div>
</umb-control-group>

View File

@@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Umbraco.Cms.Web.UI.NetCore</RootNamespace>
<LangVersion>latest</LangVersion>
<RootNamespace>Umbraco.Web.UI.NetCore</RootNamespace>
<RootNamespace>Umbraco.Cms.Web.UI.NetCore</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DocumentationFile>bin\Release\Umbraco.Web.UI.NetCore.xml</DocumentationFile>

View File

@@ -1,4 +1,5 @@
@using Umbraco.Extensions
@using Umbraco.Cms.Web.UI.NetCore
@using Umbraco.Cms.Web.Common.PublishedModels
@using Umbraco.Cms.Web.Common.Views
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@@ -124,8 +124,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IssueTemplates", "IssueTemp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Core", "Umbraco.Core\Umbraco.Core.csproj", "{29AA69D9-B597-4395-8D42-43B1263C240A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.ModelsBuilder.Embedded", "Umbraco.ModelsBuilder.Embedded\Umbraco.ModelsBuilder.Embedded.csproj", "{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastructure", "Umbraco.Infrastructure\Umbraco.Infrastructure.csproj", "{3AE7BF57-966B-45A5-910A-954D7C554441}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.PublishedCache.NuCache", "Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}"
@@ -158,10 +156,6 @@ Global
{29AA69D9-B597-4395-8D42-43B1263C240A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29AA69D9-B597-4395-8D42-43B1263C240A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29AA69D9-B597-4395-8D42-43B1263C240A}.Release|Any CPU.Build.0 = Release|Any CPU
{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}.Release|Any CPU.Build.0 = Release|Any CPU
{3AE7BF57-966B-45A5-910A-954D7C554441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AE7BF57-966B-45A5-910A-954D7C554441}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AE7BF57-966B-45A5-910A-954D7C554441}.Release|Any CPU.ActiveCfg = Release|Any CPU