2021-01-13 11:02:29 +01:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2020-11-19 19:23:41 +11:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2021-01-13 11:02:29 +01:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core;
|
2021-02-23 16:09:36 +01:00
|
|
|
using Umbraco.Cms.Core.Events;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
using Umbraco.Cms.Core.Trees;
|
|
|
|
|
using Umbraco.Cms.Web.Common.Attributes;
|
|
|
|
|
using Umbraco.Cms.Web.Common.Authorization;
|
|
|
|
|
using Constants = Umbraco.Cms.Core.Constants;
|
2018-10-02 14:14:25 +02:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Web.BackOffice.Trees
|
2018-10-02 14:14:25 +02:00
|
|
|
{
|
2020-11-19 19:23:41 +11:00
|
|
|
[Authorize(Policy = AuthorizationPolicies.TreeAccessPackages)]
|
2019-01-22 09:31:47 +01:00
|
|
|
[Tree(Constants.Applications.Packages, Constants.Trees.Packages, SortOrder = 0, IsSingleNodeTree = true)]
|
2020-09-23 08:55:25 +02:00
|
|
|
[PluginController(Constants.Web.Mvc.BackOfficeTreeArea)]
|
2018-10-02 14:14:25 +02:00
|
|
|
[CoreTree]
|
|
|
|
|
public class PackagesTreeController : TreeController
|
|
|
|
|
{
|
2020-02-17 14:58:34 +01:00
|
|
|
private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
|
|
|
|
|
|
|
|
|
|
public PackagesTreeController(
|
2020-06-09 07:49:26 +02:00
|
|
|
ILocalizedTextService localizedTextService,
|
|
|
|
|
UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
|
2021-02-23 16:09:36 +01:00
|
|
|
IMenuItemCollectionFactory menuItemCollectionFactory,
|
|
|
|
|
IEventAggregator eventAggregator)
|
|
|
|
|
: base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
|
2020-02-17 14:58:34 +01:00
|
|
|
{
|
|
|
|
|
_menuItemCollectionFactory = menuItemCollectionFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-09 07:49:26 +02:00
|
|
|
|
2018-10-02 14:14:25 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Helper method to create a root model for a tree
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2021-01-14 19:41:32 +01:00
|
|
|
protected override ActionResult<TreeNode> CreateRootNode(FormCollection queryStrings)
|
2018-10-02 14:14:25 +02:00
|
|
|
{
|
2021-01-14 19:41:32 +01:00
|
|
|
var rootResult = base.CreateRootNode(queryStrings);
|
|
|
|
|
if (!(rootResult.Result is null))
|
|
|
|
|
{
|
|
|
|
|
return rootResult;
|
|
|
|
|
}
|
|
|
|
|
var root = rootResult.Value;
|
|
|
|
|
|
2018-12-06 09:32:04 +00:00
|
|
|
|
|
|
|
|
//this will load in a custom UI instead of the dashboard for the root node
|
2019-11-05 13:45:42 +01:00
|
|
|
root.RoutePath = $"{Constants.Applications.Packages}/{Constants.Trees.Packages}/repo";
|
2018-10-02 14:14:25 +02:00
|
|
|
root.Icon = "icon-box";
|
2018-12-06 09:32:04 +00:00
|
|
|
|
|
|
|
|
root.HasChildren = false;
|
2018-10-02 14:14:25 +02:00
|
|
|
return root;
|
|
|
|
|
}
|
2018-12-06 09:32:04 +00:00
|
|
|
|
2019-01-09 20:57:02 +11:00
|
|
|
|
2021-01-14 19:41:32 +01:00
|
|
|
protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
|
2018-10-02 14:14:25 +02:00
|
|
|
{
|
2018-12-06 09:32:04 +00:00
|
|
|
//full screen app without tree nodes
|
|
|
|
|
return TreeNodeCollection.Empty;
|
2018-10-02 14:14:25 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 11:02:29 +01:00
|
|
|
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
|
2018-10-02 14:14:25 +02:00
|
|
|
{
|
2018-12-06 09:32:04 +00:00
|
|
|
//doesn't have a menu, this is a full screen app without tree nodes
|
2020-02-17 14:58:34 +01:00
|
|
|
return _menuItemCollectionFactory.Create();
|
2018-10-02 14:14:25 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|