Files
Umbraco-CMS/src/Umbraco.Core/Services/Navigation/INavigationManagementService.cs
Elitsa Marinovska 44ff8dc5e1 V15: Implement sorting for the in-memory navigation structures (document and media) (#17280)
* bump version to 15.1.0

* V15 Fixed the failing smoke tests in the pipeline v15 (#17158)

* Fixed the failing tests of Member Group due to UI changes

* Fixed the failing tests of Member due to UI changes

* Fixed the failing tests of User due to UI changes

* Fixed failing tests for Dictionary and Document Type

* Updated tests due to test helper changes

* Bumped version

* Updated assert steps due to the response changes

* Updated tests due to api helper changes

* Updated tests due to UI changes

* Fixed tests for delete partial view

* Fixed tests

* Added more waits

* Updated assert steps

* Fixed failing tests for Block Grid and Media

* Added more waits

* Added skip tests

* Removed waits time

* Updated assertion steps for User

* Added todo

* Updated tests due to api helper changes

* Bumped version

* Added skip tests

* Fetch sortOrder for each navigationNode

* Update NavigationNode to have sortOrder and change Parent and Children props to keys instead of NavigationNodes

* Consider sortOrder when building the navigation structures

* Renaming tests

* Adding tests for items being the last in structure when added, moved, etc.

* Updating names

* Cleanup

* Updating cache refreshers with changes due to sorting

* Refactoring due to sorting changes and resolving key to NavigationNode

* Removing sortOrder params from test as they are calculated automatically

* Adding content and media integration tests to test sorting functionality

* Adding sortOrder param for special case when adding new nodes

* Adding new UpdateSortOrder to INavigationManagementService

* Revert "V15 Fixed the failing smoke tests in the pipeline v15 (#17158)"

This reverts commit 31399c3b15.

* Revert "bump version to 15.1.0"

This reverts commit 5e4d15be

* Fix revert

* Add sort order when creating media

---------

Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com>
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2024-10-16 09:51:42 +02:00

78 lines
3.7 KiB
C#

namespace Umbraco.Cms.Core.Services.Navigation;
/// <summary>
/// Placeholder for sharing logic between the document and media navigation services
/// for managing the navigation structure.
/// </summary>
public interface INavigationManagementService
{
/// <summary>
/// Rebuilds the entire navigation structure by refreshing the navigation tree based
/// on the current state of the underlying repository.
/// </summary>
Task RebuildAsync();
/// <summary>
/// Removes a node from the main navigation structure and moves it, along with
/// its descendants, to the root of the recycle bin structure.
/// </summary>
/// <param name="key">The unique identifier of the node to remove.</param>
/// <returns>
/// <c>true</c> if the node and its descendants were successfully removed from the
/// main navigation structure and added to the recycle bin; otherwise, <c>false</c>.
/// </returns>
bool MoveToBin(Guid key);
/// <summary>
/// Adds a new node to the main navigation structure. If a parent key is provided,
/// the new node is added as a child of the specified parent. If no parent key is
/// provided, the new node is added at the root level.
/// </summary>
/// <param name="key">The unique identifier of the new node to add.</param>
/// <param name="parentKey">
/// The unique identifier of the parent node. If <c>null</c>, the new node will be added to
/// the root level.
/// </param>
/// <param name="sortOrder">
/// Optional value to define the node's position among its siblings when
/// adding node at root level.</param>
/// <returns>
/// <c>true</c> if the node was successfully added to the main navigation structure;
/// otherwise, <c>false</c>.
/// </returns>
/// <remarks>
/// The sort order is particularly important when adding nodes at the root level. For child nodes,
/// it can usually be determined by the number of existing children under the parent. However,
/// when adding nodes directly to the root (where parentKey is null), a sort order must be provided
/// to ensure the item appears in the correct position among other root-level items.
/// </remarks>
bool Add(Guid key, Guid? parentKey = null, int? sortOrder = null);
/// <summary>
/// Moves an existing node to a new parent in the main navigation structure. If a
/// target parent key is provided, the node is moved under the specified parent.
/// If no target parent key is provided, the node is moved to the root level.
/// </summary>
/// <param name="key">The unique identifier of the node to move.</param>
/// <param name="targetParentKey">
/// The unique identifier of the new parent node. If <c>null</c>, the node will be moved to
/// the root level.
/// </param>
/// <returns>
/// <c>true</c> if the node and its descendants were successfully moved to the new parent
/// in the main navigation structure; otherwise, <c>false</c>.
/// </returns>
bool Move(Guid key, Guid? targetParentKey = null);
/// <summary>
/// Updates the sort order of a node in the main navigation structure.
/// The sort order of other nodes in the same level will be adjusted accordingly.
/// </summary>
/// <param name="key">The unique identifier of the node to update.</param>
/// <param name="newSortOrder">The new sort order for the node.</param>
/// <returns>
/// <c>true</c> if the node's sort order was successfully updated; otherwise, <c>false</c>.
/// </returns>
bool UpdateSortOrder(Guid key, int newSortOrder);
}