feat(adminui): UNS-tree delete for Cluster + Enterprise (refuse-if-children, no rowversion)

This commit is contained in:
Joseph Doherty
2026-06-16 16:35:07 -04:00
parent 6a8020e7e7
commit 526eebb3bb
5 changed files with 349 additions and 3 deletions
@@ -303,8 +303,19 @@
result = await Svc.DeleteEquipmentAsync(node.EntityId!, equipment.RowVersion);
break;
case UnsNodeKind.Cluster:
// Cluster carries no RowVersion (Option B); EntityId mirrors the ClusterId.
result = await Svc.DeleteClusterAsync(node.EntityId!);
break;
case UnsNodeKind.Enterprise:
// Enterprise is a tree label, not an entity — its name is the DisplayName.
// Deletes every cluster carrying that label (refuse-if-children, all-or-nothing).
result = await Svc.DeleteEnterpriseAsync(node.DisplayName);
break;
default:
// Enterprise/Cluster have no delete button, so this branch is unreachable in practice.
// Tag/VirtualTag are not deletable from the global tree.
result = new UnsMutationResult(false, "Delete for this node kind is not yet available.");
break;
}
@@ -19,7 +19,7 @@
/// <summary>Raised when the user edits a node (Area/Line).</summary>
[Parameter] public EventCallback<UnsNode> OnEdit { get; set; }
/// <summary>Raised when the user deletes a node (Area/Line/Equipment/Tag/VirtualTag).</summary>
/// <summary>Raised when the user deletes a node (Enterprise/Cluster/Area/Line/Equipment/Tag/VirtualTag).</summary>
[Parameter] public EventCallback<UnsNode> OnDelete { get; set; }
/// <summary>Raised when the user toggles a node's expansion; the host owns the resulting state + lazy load.</summary>
@@ -86,13 +86,17 @@
switch (node.Kind)
{
case UnsNodeKind.Enterprise:
// No actions on the enterprise root.
// Deletes every cluster carrying this enterprise label (refuse-if-children).
<button type="button" class="btn btn-sm btn-link p-0 ms-2 text-danger"
@onclick="@(() => OnDelete.InvokeAsync(node))">Delete</button>
break;
case UnsNodeKind.Cluster:
<button type="button" class="btn btn-sm btn-link p-0 ms-2"
@onclick="@(() => OnAddChild.InvokeAsync(node))">+ Area</button>
<a class="btn btn-sm btn-link p-0 ms-2" href="@($"/clusters/{node.ClusterId}")">⚙ settings</a>
<button type="button" class="btn btn-sm btn-link p-0 ms-2 text-danger"
@onclick="@(() => OnDelete.InvokeAsync(node))">Delete</button>
break;
case UnsNodeKind.Area: