c3277b52c9
Wave-0 reviewer findings (no Critical/High): - T0-1 M: ContextMenuItem.OnClick Action→Func<Task> (kills async-void at menu call sites Wave A/B/C need); keyboard-activated ⋯ now anchors below the button instead of viewport (0,0); focus returns to trigger on close; backdrop closes on native right-click too. - T0-3 M: guard test now discovers *DriverFactoryExtensions.Register by convention from the deployed driver assemblies instead of a hand-copied list, so a future driver lacking a constant is actually caught. - T0-2 L: corrected the round-trip 'sole non-round-trippable shape' comment (any table whose final row is a lone empty field). Claude-Session: https://claude.ai/code/session_01LVneM3eh1UtJxEisFXgmox
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared;
|
|
|
|
/// <summary>
|
|
/// One entry in a <see cref="ContextMenu"/>. An item is either an actionable
|
|
/// row (<see cref="Label"/> + <see cref="OnClick"/>) or a visual divider
|
|
/// (<see cref="IsSeparator"/> = true, in which case the other members are
|
|
/// ignored). Use the <see cref="Separator"/> factory for dividers.
|
|
/// </summary>
|
|
public sealed class ContextMenuItem
|
|
{
|
|
/// <summary>Text shown for the row.</summary>
|
|
public string Label { get; init; } = "";
|
|
|
|
/// <summary>
|
|
/// Invoked when the row is activated (click / Enter). Async so per-node menu
|
|
/// actions (delete, redeploy, rename) can await their service calls without an
|
|
/// exception-swallowing <c>async void</c>; the menu awaits this and re-renders.
|
|
/// A synchronous handler returns <see cref="Task.CompletedTask"/>.
|
|
/// </summary>
|
|
public Func<Task>? OnClick { get; init; }
|
|
|
|
/// <summary>Optional leading icon — an emoji or single glyph.</summary>
|
|
public string? Icon { get; init; }
|
|
|
|
/// <summary>Renders the row greyed-out and non-interactive.</summary>
|
|
public bool Disabled { get; init; }
|
|
|
|
/// <summary>When true this entry is a horizontal divider, not a row.</summary>
|
|
public bool IsSeparator { get; init; }
|
|
|
|
/// <summary>A horizontal divider between groups of items.</summary>
|
|
public static ContextMenuItem Separator() => new() { IsSeparator = true };
|
|
}
|