Signature changes of GetMenuForNode() & PerformGetMenuForNode()

This commit is contained in:
Elitsa Marinovska
2021-01-13 11:02:29 +01:00
parent 2c81d09d0e
commit 2204a57a8d
19 changed files with 56 additions and 41 deletions

View File

@@ -1,7 +1,8 @@
using System;
using System;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
@@ -112,7 +113,7 @@ namespace Umbraco.Web.BackOffice.Trees
return nodes;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -143,7 +143,7 @@ namespace Umbraco.Web.BackOffice.Trees
return null;
}
protected override MenuItemCollection PerformGetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> PerformGetMenuForNode(string id, FormCollection queryStrings)
{
if (id == Constants.System.RootString)
{
@@ -187,12 +187,12 @@ namespace Umbraco.Web.BackOffice.Trees
int iid;
if (int.TryParse(id, out iid) == false)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
return NotFound();
}
var item = _entityService.Get(iid, UmbracoObjectTypes.Document);
if (item == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
return NotFound();
}
//if the user has no path access for this node, all they can do is refresh

View File

@@ -253,7 +253,7 @@ namespace Umbraco.Web.BackOffice.Trees
return parts.Length >= 2 && int.TryParse(parts[1], out id) ? id : 0;
}
protected abstract MenuItemCollection PerformGetMenuForNode(string id, FormCollection queryStrings);
protected abstract ActionResult<MenuItemCollection> PerformGetMenuForNode(string id, FormCollection queryStrings);
protected abstract UmbracoObjectTypes UmbracoObjectType { get; }
@@ -432,7 +432,7 @@ namespace Umbraco.Web.BackOffice.Trees
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
protected sealed override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected sealed override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
if (RecycleBinId.ToInvariantString() == id)
{

View File

@@ -1,8 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
@@ -97,7 +98,7 @@ namespace Umbraco.Web.BackOffice.Trees
return nodes;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
@@ -15,6 +15,7 @@ using Umbraco.Web.Common.Attributes;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Web.Common.Authorization;
using Umbraco.Core.Trees;
@@ -119,7 +120,7 @@ namespace Umbraco.Web.BackOffice.Trees
};
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,7 +1,8 @@
using System;
using System;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
@@ -109,7 +110,7 @@ namespace Umbraco.Web.BackOffice.Trees
/// All of the query string parameters passed from jsTree
/// </param>
/// <returns></returns>
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,8 +1,9 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Net;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
@@ -148,7 +149,7 @@ namespace Umbraco.Web.BackOffice.Trees
return menu;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
//if root node no need to visit the filesystem so lets just create the menu and return it
if (id == Constants.System.RootString)

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core.Services;
using Umbraco.Web.BackOffice.Filters;
using Umbraco.Web.Common.Attributes;
@@ -30,7 +31,7 @@ namespace Umbraco.Web.BackOffice.Trees
return new TreeNodeCollection();
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
//We don't have any menu item options (such as create/delete/reload) & only use the root node to load a custom UI
return null;

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core.Services;
using Umbraco.Web.BackOffice.Filters;
using Umbraco.Web.Common.Attributes;
@@ -30,7 +31,7 @@ namespace Umbraco.Web.BackOffice.Trees
return new TreeNodeCollection();
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
//We don't have any menu item options (such as create/delete/reload) & only use the root node to load a custom UI
return null;

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Umbraco.Core.Services;
using Umbraco.Web.Models.Trees;
@@ -9,6 +9,7 @@ using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Constants = Umbraco.Core.Constants;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Web.Common.Authorization;
namespace Umbraco.Web.BackOffice.Trees
@@ -57,7 +58,7 @@ namespace Umbraco.Web.BackOffice.Trees
return nodes;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -21,6 +21,7 @@ using Umbraco.Web.Security;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Web.Common.Authorization;
using Umbraco.Core.Trees;
@@ -97,7 +98,7 @@ namespace Umbraco.Web.BackOffice.Trees
return node;
}
protected override MenuItemCollection PerformGetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> PerformGetMenuForNode(string id, FormCollection queryStrings)
{
var menu = MenuItemCollectionFactory.Create();
@@ -122,12 +123,12 @@ namespace Umbraco.Web.BackOffice.Trees
if (int.TryParse(id, out var iid) == false)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
return NotFound();
}
var item = _entityService.Get(iid, UmbracoObjectTypes.Media);
if (item == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
return NotFound();
}
//if the user has no path access for this node, all they can do is refresh

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
@@ -14,6 +14,7 @@ using Umbraco.Web.Common.Attributes;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Web.Common.Authorization;
using Umbraco.Core.Trees;
@@ -81,7 +82,7 @@ namespace Umbraco.Web.BackOffice.Trees
return nodes;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
@@ -125,7 +125,7 @@ namespace Umbraco.Web.BackOffice.Trees
return nodes;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
@@ -32,7 +33,7 @@ namespace Umbraco.Web.BackOffice.Trees
return nodes;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = MenuItemCollectionFactory.Create();

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core.Services;
using Umbraco.Web.BackOffice.Filters;
using Umbraco.Web.Common.Attributes;
@@ -52,7 +53,7 @@ namespace Umbraco.Web.BackOffice.Trees
return TreeNodeCollection.Empty;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
//doesn't have a menu, this is a full screen app without tree nodes
return _menuItemCollectionFactory.Create();

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Umbraco.Web.Models.Trees;
using Umbraco.Core;
@@ -10,6 +10,7 @@ using Umbraco.Web.Common.Attributes;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Web.Common.Authorization;
namespace Umbraco.Web.BackOffice.Trees
@@ -34,7 +35,7 @@ namespace Umbraco.Web.BackOffice.Trees
_relationService = relationService;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -3,6 +3,7 @@ using System.Globalization;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
@@ -93,7 +94,7 @@ namespace Umbraco.Web.BackOffice.Trees
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
var menu = _menuItemCollectionFactory.Create();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -55,7 +55,7 @@ namespace Umbraco.Web.BackOffice.Trees
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
protected abstract MenuItemCollection GetMenuForNode(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings);
protected abstract ActionResult<MenuItemCollection> GetMenuForNode(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings);
/// <summary>
/// The name to display on the root node
@@ -148,12 +148,12 @@ namespace Umbraco.Web.BackOffice.Trees
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
public MenuItemCollection GetMenu(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
public ActionResult<MenuItemCollection> GetMenu(string id, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormCollection queryStrings)
{
if (queryStrings == null) queryStrings = FormCollection.Empty;
var menu = GetMenuForNode(id, queryStrings);
//raise the event
OnMenuRendering(this, new MenuRenderingEventArgs(id, menu, queryStrings));
OnMenuRendering(this, new MenuRenderingEventArgs(id, menu.Value, queryStrings));
return menu;
}

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core.Services;
using Umbraco.Web.Common.Attributes;
using Umbraco.Web.Common.Authorization;
@@ -49,7 +50,7 @@ namespace Umbraco.Web.BackOffice.Trees
return TreeNodeCollection.Empty;
}
protected override MenuItemCollection GetMenuForNode(string id, FormCollection queryStrings)
protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
{
//doesn't have a menu, this is a full screen app without tree nodes
return _menuItemCollectionFactory.Create();