New backoffice - trees design (#12963)

* Refactor: Add default versioned back office route attribute

* Tree controller bases and first draft implementations for document, media and doctype

* Move tree item view models to appropriate location

* Fix missing parent

* Refactor user entity access for testability

* A bit of clean-up + handle user start nodes for items endpoint

* Implement foldersOnly for folder tree

* Items endpoint for document type tree

* Strongly typed action results

* Content + media recycle bin

* Correct return type for swagger

* Member type tree

* Rename user start node handling to make a little more sense

* Revert to faked admin start nodes in document tree

* Media type tree

* Data type tree

* Relation type tree

* Remove unused dependency from member type tree

* Correct documentation for member type tree endpoint response types

* Use icon constants

* Add templates tree

* Member group tree

* Document blueprint tree

* Partial views, scripts and stylesheets trees

* Static files tree

* Clarify "folders only" state

* Comments and improved readability

* Rename TreeControllerBase and TreeItemViewModel

* Move recycle bin controller base to its own namespace

* Moved tree base controllers to their own namespace

* Common base class for tree view models

* Remove ProblemDetails response type declaration from all actions

* Add OpenApiTag

* Various review comments

* Dictionary item tree

* Renamed all tree controllers to follow action/feature naming convention

* Handle client culture state for document tree

* Support "ignore user start nodes" for content and media + refactor how tree states work to make things more explicit

* Fix or postpone a few TODOs

* Make entity service able to paginate trashed children

* Handle sorting explicitly

* Re-apply VersionedApiBackOfficeRoute to install and upgrade controllers after merge

* Use PagedViewModel instead of PagedResult for all trees

* Explain the usage of UmbracoObjectTypes.Unknown

* Introduce and apply GetMany pattern for dictionary items

* Add a note about relation type caching

* Fix broken test build + add unit tests for new localization service methods

* Use new management API controller base

* Entity repository should build document entities for document blueprints when getting paged entities (same as it does when getting specific entities)

* Use Media type for Media recycle bin

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>

* Move shared relation service to concrete implementations

* Use inclusive language

* Add 401 response type documentation to applicable trees

* Refactor entity load for folder tree controller base + ensure that folders are only included in the first result page

* Add (in-memory) pagination to dictionary tree

* Make file system controller honor paging parameters

* Support pagination in relation type tree

* Clarify method name a bit for detecting tree root path requests

* Update Open API schema to match new trees

* Move from page number and page size to skip/take (with temporary workaround for lack of property skip/take pagination in current DB implementation)

* Update OpenAPI schema to match skip/take

* Update OpenAPI schema

* Don't return paginated view models from "items" endpoints

* Update OpenApi schema

Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
This commit is contained in:
Kenn Jacobsen
2022-09-28 13:37:59 +02:00
committed by GitHub
parent 3752f51625
commit 134b193c74
103 changed files with 5976 additions and 255 deletions

View File

@@ -158,6 +158,26 @@ public class DictionaryRepositoryTest : UmbracoIntegrationTest
}
}
[Test]
public void Can_Perform_GetAll_ByKeys_On_DictionaryRepository()
{
// Arrange
var provider = ScopeProvider;
using (provider.CreateScope())
{
var repository = CreateRepository();
// Act
var dictionaryItems = repository.GetManyByKeys().ToArray();
// Assert
Assert.That(dictionaryItems, Is.Not.Null);
Assert.That(dictionaryItems.Any(), Is.True);
Assert.That(dictionaryItems.Any(x => x == null), Is.False);
Assert.That(dictionaryItems.Count(), Is.EqualTo(2));
}
}
[Test]
public void Can_Perform_GetAll_With_Params_On_DictionaryRepository()
{
@@ -178,6 +198,26 @@ public class DictionaryRepositoryTest : UmbracoIntegrationTest
}
}
[Test]
public void Can_Perform_GetAll_ByKeys_With_Params_On_DictionaryRepository()
{
// Arrange
var provider = ScopeProvider;
using (provider.CreateScope())
{
var repository = CreateRepository();
// Act
var dictionaryItems = repository.GetManyByKeys("Read More", "Article").ToArray();
// Assert
Assert.That(dictionaryItems, Is.Not.Null);
Assert.That(dictionaryItems.Any(), Is.True);
Assert.That(dictionaryItems.Any(x => x == null), Is.False);
Assert.That(dictionaryItems.Count(), Is.EqualTo(2));
}
}
[Test]
public void Can_Perform_GetByQuery_On_DictionaryRepository()
{

View File

@@ -273,6 +273,49 @@ public class EntityServiceTests : UmbracoIntegrationTest
}
}
[Test]
public void EntityService_Can_Get_Paged_Trashed_Content_Children()
{
var contentType = ContentTypeService.Get("umbTextpage");
var root = ContentBuilder.CreateSimpleContent(contentType);
ContentService.Save(root);
var toDelete = new List<IContent>();
for (var i = 0; i < 10; i++)
{
var c1 = ContentBuilder.CreateSimpleContent(contentType, Guid.NewGuid().ToString(), root);
ContentService.Save(c1);
if (i % 2 == 0)
{
toDelete.Add(c1);
}
for (var j = 0; j < 5; j++)
{
var c2 = ContentBuilder.CreateSimpleContent(contentType, Guid.NewGuid().ToString(), c1);
ContentService.Save(c2);
}
}
foreach (var content in toDelete)
{
ContentService.MoveToRecycleBin(content);
}
// get paged entities at recycle bin root
var entities = EntityService
.GetPagedTrashedChildren(Constants.System.RecycleBinContent, UmbracoObjectTypes.Document, 0, 1000, out var total)
.Select(x => x.Id)
.ToArray();
Assert.True(total > 0);
foreach (var c in toDelete)
{
Assert.IsTrue(entities.Contains(c.Id));
}
}
[Test]
public void EntityService_Can_Get_Paged_Content_Descendants_With_Search()
{
@@ -452,6 +495,50 @@ public class EntityServiceTests : UmbracoIntegrationTest
}
}
[Test]
public void EntityService_Can_Get_Paged_Trashed_Media_Children()
{
var folderType = MediaTypeService.Get(1031);
var imageMediaType = MediaTypeService.Get(1032);
var root = MediaBuilder.CreateMediaFolder(folderType, -1);
MediaService.Save(root);
var toDelete = new List<IMedia>();
for (var i = 0; i < 10; i++)
{
var c1 = MediaBuilder.CreateMediaImage(imageMediaType, root.Id);
MediaService.Save(c1);
if (i % 2 == 0)
{
toDelete.Add(c1);
}
for (var j = 0; j < 5; j++)
{
var c2 = MediaBuilder.CreateMediaImage(imageMediaType, c1.Id);
MediaService.Save(c2);
}
}
foreach (var content in toDelete)
{
MediaService.MoveToRecycleBin(content);
}
// get paged entities at recycle bin root
var entities = EntityService
.GetPagedTrashedChildren(Constants.System.RecycleBinMedia, UmbracoObjectTypes.Media, 0, 1000, out var total)
.Select(x => x.Id)
.ToArray();
Assert.True(total > 0);
foreach (var media in toDelete)
{
Assert.IsTrue(entities.Contains(media.Id));
}
}
[Test]
public void EntityService_Can_Get_Paged_Media_Descendants_With_Search()
{

View File

@@ -82,6 +82,15 @@ public class LocalizationServiceTests : UmbracoIntegrationTest
Assert.NotNull(childItem);
}
[Test]
public void Can_Get_Dictionary_Items_By_Guid_Ids()
{
var items = LocalizationService.GetDictionaryItemsByIds(_parentItemGuidId, _childItemGuidId);
Assert.AreEqual(2, items.Count());
Assert.NotNull(items.FirstOrDefault(i => i.Key == _parentItemGuidId));
Assert.NotNull(items.FirstOrDefault(i => i.Key == _childItemGuidId));
}
[Test]
public void Can_Get_Dictionary_Item_By_Key()
{
@@ -92,6 +101,15 @@ public class LocalizationServiceTests : UmbracoIntegrationTest
Assert.NotNull(childItem);
}
[Test]
public void Can_Get_Dictionary_Items_By_Keys()
{
var items = LocalizationService.GetDictionaryItemsByKeys("Parent", "Child");
Assert.AreEqual(2, items.Count());
Assert.NotNull(items.FirstOrDefault(i => i.ItemKey == "Parent"));
Assert.NotNull(items.FirstOrDefault(i => i.ItemKey == "Child"));
}
[Test]
public void Can_Get_Dictionary_Item_Children()
{