@namespace ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared @using ZB.MOM.WW.OtOpcUa.AdminUI.ScriptAnalysis @* The script editor's Problems list. Fed by MonacoEditor.MarkersChanged; clicking a row calls OnSelect, which the host wires to MonacoEditor.RevealLineAsync so the caret jumps to the problem. Ordering and wording live in ScriptProblems (unit-tested). *@ @{ var report = Report ?? ScriptProblemReport.Empty; var ordered = ScriptProblems.Order(report.Markers); }
Problems @ScriptProblems.Summary(report with { Markers = ordered })
@if (ordered.Count > 0) { @if (report.Total > Math.Min(ordered.Count, MaxRows)) { @* The editor reports at most ScriptEditorLimits.MaxReportedMarkers problems (one circuit message); the rest are still squiggled in the editor. *@
+@(report.Total - Math.Min(ordered.Count, MaxRows)) more — fix the problems above, or scroll the editor to see them all.
} }
@code { private const int MaxRows = ScriptEditorLimits.MaxReportedMarkers; /// The report the editor last sent (null before the first diagnostics pass). [Parameter] public ScriptProblemReport? Report { get; set; } /// Raised when the author picks a problem; wire it to MonacoEditor.RevealLineAsync. [Parameter] public EventCallback OnSelect { get; set; } private Task OnKeyAsync(KeyboardEventArgs e, DiagnosticMarker m) => e.Key is "Enter" or " " ? OnSelect.InvokeAsync(m) : Task.CompletedTask; private static string BadgeClass(int severity) => severity switch { ScriptProblems.Error => "text-bg-danger", ScriptProblems.Warning => "text-bg-warning", _ => "text-bg-secondary", }; }