U4-6617 - v7 Custom Tree Routing is Confusing and Doesn't Allow for Specific URL's

Created by Kevin Giszewski 12 May 2015, 15:41:03 Updated by Rasmus Eeg Møller 12 Jun 2018, 11:19:35

Relates to: U4-11433

Disclaimer Maybe I'm missing something and this is not an issue. Perhaps this is by design.

What did you do? I created a custom tree with a few nodes.

What did you expect to happen? The ability to set the routePath to anything I wished.

What actually happened? Umbraco forces use two use one of two conventions making it impossible to route to a specific view.

Given this tree controller:

using System.Net.Http.Formatting;
using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc;
using Umbraco.Web.Trees;

namespace MyNamespace.NdApplication
{
    [PluginController("NdApplication")]
    [Umbraco.Web.Trees.Tree("NdApplication", "NdApplicationAdminTree", "Admin", iconClosed: "icon-folder")]
    public class NdTreeController : TreeController
    {
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            if (id == "-1")
            {
                var node = CreateTreeNode("TrackingPixel", "", queryStrings, "Tracking Pixel", "icon-fingerprint");
                node.RoutePath = "/NdApplication/NdApplicationAdminTree/tracking-pixel-dashboard/Stats";
                node.HasChildren = true;

                nodes.Add(node);
            }

            if (id == "TrackingPixel")
            {
                var node = CreateTreeNode("TrackingPixelChildNode", "TrackingPixel", queryStrings, "Foo",
                    "icon-fingerprint");
                node.RoutePath = "/App_Plugins/foo/main";
                nodes.Add(node);
            }

            return nodes;
        }

        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            var menu = new MenuItemCollection();
           
            return menu;
        }
    }
}

Point 1 The parent (TrackingPixel) tree node routes to a plugin mapped to this in the file system: \App_Plugins\NdApplication\backoffice\NdApplicationAdminTree\tracking-pixel-dashboard.html

  1. This is not intuitive that you have to specify a different route path in the tree controller than exists in the file system.
  2. You cannot leave this parameter-less. In the code above Stats is a parameter that I had to stuff in just to make the view load. I have many cases where I just need to show a view.

Point 2 According to the docs: https://github.com/umbraco/Umbraco-CMS/blob/ded1def8e2e7ea1a4fd0f849cc7a3f1f97cd8242/src/Umbraco.Web.UI.Client/docs/src/tutorials/Creating-Editors-Trees.ngdoc#L111, we should be able to set any value for the routePath. Given the child node above with a routePath of /App_Plugins/foo/main:

  1. When the node is clicked, Umbraco looks for the view here views/foo/main.html. That means we'd have to place the view within ~/Umbraco/Views for this to work. This shouldn't be the case (IMHO). We should be able to point to anywhere, even a plug-in designed by someone else.

Comments

Shannon Deminick 26 Jun 2017, 07:11:22

Closing issue due to inactivity - see blog post for details https://umbraco.com/blog/issue-tracker-cleanup/


Rasmus Eeg Møller 12 Jun 2018, 11:19:35

They are linked, as this issue tries to do what you would think it would do. But doesn't do.


Priority: Normal

Type: Usability Problem

State: Closed

Assignee:

Difficulty: Normal

Category: Extensibility

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.2.4

Due in version:

Sprint:

Story Points:

Cycle: