fix(template-engine): DiffService covers native alarm sources — Deployments diff view no longer blind to native-alarm edits
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
@@ -12,8 +12,8 @@ public sealed record ConfigurationDiff
|
||||
public string? OldRevisionHash { get; init; }
|
||||
/// <summary>Revision hash of the new configuration being compared.</summary>
|
||||
public string? NewRevisionHash { get; init; }
|
||||
/// <summary>True when any attribute, alarm, script, or connection changes are present.</summary>
|
||||
public bool HasChanges => AttributeChanges.Count > 0 || AlarmChanges.Count > 0 || ScriptChanges.Count > 0 || ConnectionChanges.Count > 0;
|
||||
/// <summary>True when any attribute, alarm, script, native alarm source, or connection changes are present.</summary>
|
||||
public bool HasChanges => AttributeChanges.Count > 0 || AlarmChanges.Count > 0 || ScriptChanges.Count > 0 || NativeAlarmSourceChanges.Count > 0 || ConnectionChanges.Count > 0;
|
||||
|
||||
/// <summary>Diff entries for resolved attributes.</summary>
|
||||
public IReadOnlyList<DiffEntry<ResolvedAttribute>> AttributeChanges { get; init; } = [];
|
||||
@@ -22,6 +22,13 @@ public sealed record ConfigurationDiff
|
||||
/// <summary>Diff entries for resolved scripts.</summary>
|
||||
public IReadOnlyList<DiffEntry<ResolvedScript>> ScriptChanges { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Diff entries for resolved native alarm source bindings, keyed by canonical
|
||||
/// name. Surfaces native-alarm-source edits (connection, source reference,
|
||||
/// condition filter, lock state) in the Deployments diff view.
|
||||
/// </summary>
|
||||
public IReadOnlyList<DiffEntry<ResolvedNativeAlarmSource>> NativeAlarmSourceChanges { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Diff entries for connection configurations, keyed by connection name.
|
||||
/// Surfaces standalone endpoint/protocol/failover drift that does not show
|
||||
|
||||
@@ -4,7 +4,8 @@ namespace ZB.MOM.WW.ScadaBridge.TemplateEngine.Flattening;
|
||||
|
||||
/// <summary>
|
||||
/// Compares two FlattenedConfigurations (deployed vs current) and produces a ConfigurationDiff
|
||||
/// showing Added, Removed, and Changed entries for attributes, alarms, and scripts.
|
||||
/// showing Added, Removed, and Changed entries for attributes, alarms, scripts,
|
||||
/// and native alarm sources.
|
||||
/// </summary>
|
||||
public class DiffService
|
||||
{
|
||||
@@ -42,6 +43,12 @@ public class DiffService
|
||||
s => s.CanonicalName,
|
||||
ScriptsEqual);
|
||||
|
||||
var nativeAlarmSourceChanges = ComputeEntityDiff(
|
||||
oldConfig?.NativeAlarmSources ?? [],
|
||||
newConfig.NativeAlarmSources,
|
||||
n => n.CanonicalName,
|
||||
NativeAlarmSourcesEqual);
|
||||
|
||||
// Surface standalone connection endpoint/protocol/
|
||||
// failover drift. Per-attribute binding changes already show up under
|
||||
// AttributeChanges, but a connection's own ConfigurationJson /
|
||||
@@ -57,6 +64,7 @@ public class DiffService
|
||||
AttributeChanges = attributeChanges,
|
||||
AlarmChanges = alarmChanges,
|
||||
ScriptChanges = scriptChanges,
|
||||
NativeAlarmSourceChanges = nativeAlarmSourceChanges,
|
||||
ConnectionChanges = connectionChanges
|
||||
};
|
||||
}
|
||||
@@ -138,6 +146,13 @@ public class DiffService
|
||||
a.TriggerConfiguration == b.TriggerConfiguration &&
|
||||
a.OnTriggerScriptCanonicalName == b.OnTriggerScriptCanonicalName;
|
||||
|
||||
private static bool NativeAlarmSourcesEqual(ResolvedNativeAlarmSource a, ResolvedNativeAlarmSource b) =>
|
||||
a.CanonicalName == b.CanonicalName &&
|
||||
a.ConnectionName == b.ConnectionName &&
|
||||
a.SourceReference == b.SourceReference &&
|
||||
a.ConditionFilter == b.ConditionFilter &&
|
||||
a.IsLocked == b.IsLocked;
|
||||
|
||||
private static bool ScriptsEqual(ResolvedScript a, ResolvedScript b) =>
|
||||
a.CanonicalName == b.CanonicalName &&
|
||||
a.Code == b.Code &&
|
||||
|
||||
Reference in New Issue
Block a user