Fixes: U4-2672 Fix how trees are rendered when a start node is applied, the Content/Media titles must always be visible

This commit is contained in:
Shannon
2013-10-01 16:38:10 +10:00
parent 770514919d
commit 4e56d88eb5
4 changed files with 47 additions and 36 deletions

View File

@@ -26,36 +26,13 @@ namespace Umbraco.Web.Trees
{
protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
{
TreeNode node;
//if the user's start node is not default, then return their start node as the root node.
var node = base.CreateRootNode(queryStrings);
//if the user's start node is not default, then ensure the root doesn't have a menu
if (Security.CurrentUser.StartContentId != Constants.System.Root)
{
var currApp = queryStrings.GetValue<string>(TreeQueryStringParameters.Application);
var userRoot = Services.EntityService.Get(Security.CurrentUser.StartContentId, UmbracoObjectTypes.Document);
if (userRoot == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
node = new TreeNode(
userRoot.Id.ToInvariantString(),
"", //root nodes aren't expandable, no need to lookup the child nodes url
Url.GetMenuUrl(GetType(), userRoot.Id.ToInvariantString(), queryStrings))
{
HasChildren = true,
RoutePath = currApp,
Title = userRoot.Name
};
}
else
{
node = base.CreateRootNode(queryStrings);
node.MenuUrl = "";
}
return node;
}
protected override int RecycleBinId
@@ -68,6 +45,11 @@ namespace Umbraco.Web.Trees
get { return Services.ContentService.RecycleBinSmells(); }
}
protected override int UserStartNode
{
get { return Security.CurrentUser.StartContentId; }
}
protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
{
var entities = GetChildEntities(id);
@@ -111,10 +93,17 @@ namespace Umbraco.Web.Trees
{
var menu = new MenuItemCollection();
//if the user's start node is not the root then ensure the root menu is empty/doesn't exist
if (Security.CurrentUser.StartContentId != Constants.System.Root)
{
return menu;
}
//set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias;
// we need to get the default permissions as you can't set permissions on the very root node
//TODO: Use the new services to get permissions
var nodeActions = global::umbraco.BusinessLogic.Actions.Action.FromString(
UmbracoUser.GetPermissions(Constants.System.Root.ToInvariantString()))
.Select(x => new MenuItem(x));

View File

@@ -23,6 +23,11 @@ namespace Umbraco.Web.Trees
/// </summary>
protected abstract bool RecycleBinSmells { get; }
/// <summary>
/// Returns the user's start node for this tree
/// </summary>
protected abstract int UserStartNode { get; }
protected abstract TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings);
protected abstract MenuItemCollection PerformGetMenuForNode(string id, FormDataCollection queryStrings);
@@ -39,9 +44,11 @@ namespace Umbraco.Web.Trees
//if a request is made for the root node data but the user's start node is not the default, then
// we need to return their start node data
if (iid == Constants.System.Root && UmbracoUser.StartNodeId != Constants.System.Root)
if (iid == Constants.System.Root && UserStartNode != Constants.System.Root)
{
return Services.EntityService.GetChildren(UmbracoUser.StartNodeId, UmbracoObjectType).ToArray();
//just return their single start node, it will show up under the 'Content' label
var startNode = Services.EntityService.Get(UserStartNode, UmbracoObjectType);
return new[] {startNode};
}
return Services.EntityService.GetChildren(iid, UmbracoObjectType).ToArray();
@@ -56,7 +63,7 @@ namespace Umbraco.Web.Trees
/// <returns></returns>
protected sealed override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
if (id == Constants.System.Root.ToInvariantString())
if (id == Constants.System.Root.ToInvariantString() && UserStartNode == Constants.System.Root)
{
//we need to append the recycle bin to the end (if not in dialog mode)
var nodes = PerformGetTreeNodes(id, queryStrings);

View File

@@ -20,6 +20,17 @@ namespace Umbraco.Web.Trees
[PluginController("UmbracoTrees")]
public class MediaTreeController : ContentTreeControllerBase
{
protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
{
var node = base.CreateRootNode(queryStrings);
//if the user's start node is not default, then ensure the root doesn't have a menu
if (Security.CurrentUser.StartMediaId != Constants.System.Root)
{
node.MenuUrl = "";
}
return node;
}
protected override int RecycleBinId
{
get { return Constants.System.RecycleBinContent; }
@@ -30,6 +41,11 @@ namespace Umbraco.Web.Trees
get { return Services.MediaService.RecycleBinSmells(); }
}
protected override int UserStartNode
{
get { return Security.CurrentUser.StartMediaId; }
}
protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
{
var entities = GetChildEntities(id);
@@ -53,6 +69,12 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString())
{
//if the user's start node is not the root then ensure the root menu is empty/doesn't exist
if (Security.CurrentUser.StartMediaId != Constants.System.Root)
{
return menu;
}
// root actions
menu.AddMenuItem<ActionNew>();
menu.AddMenuItem<ActionSort>(true);

View File

@@ -53,13 +53,6 @@ namespace Umbraco.Web.Trees
[DataMember(Name = "name")]
public string Title { get; set; }
//TODO: This doesn't seem to be used by anything!
/// <summary>
/// Gets or sets the node path.
/// </summary>
[DataMember(Name = "nodePath")]
public string NodePath { get; set; }
/// <summary>
/// The icon to use for the node, this can be either a path to an image or a Css class.
/// If a '/' is found in the string then it will be considered a path to an image.