fix(adminui): null Source for alias rows without a FullName (review nits)
This commit is contained in:
@@ -345,7 +345,9 @@ public interface IUnsTreeService
|
||||
Task<IReadOnlyList<(string DriverInstanceId, string Display, string DriverType)>> LoadTagDriversForEquipmentAsync(string equipmentId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Galaxy gateway driver instances (DriverType "GalaxyMxGateway") in the equipment's
|
||||
/// cluster, for the alias address picker. Tuple = (DriverInstanceId, Display, DriverConfig).</summary>
|
||||
/// cluster, for the alias address picker. Tuple = (DriverInstanceId, Display, DriverConfig).
|
||||
/// <c>Display</c> is intentionally <c>"{DriverInstanceId} — {Name}"</c> (no DriverType suffix)
|
||||
/// because every returned driver is a Galaxy gateway — do not add the type suffix.</summary>
|
||||
Task<IReadOnlyList<(string DriverInstanceId, string Display, string DriverConfig)>>
|
||||
LoadGalaxyGatewaysForEquipmentAsync(string equipmentId, CancellationToken ct = default);
|
||||
|
||||
|
||||
@@ -111,7 +111,8 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
|
||||
return rows.Select(r =>
|
||||
{
|
||||
var isAlias = r.DriverType == "GalaxyMxGateway";
|
||||
var source = isAlias ? $"galaxy:{ExtractTagConfigFullName(r.TagConfig)}" : null;
|
||||
var fullName = isAlias ? ExtractTagConfigFullName(r.TagConfig) : null;
|
||||
var source = fullName is not null ? $"galaxy:{fullName}" : null;
|
||||
return new EquipmentTagRow(r.TagId, r.Name, r.DriverInstanceId, r.DataType, r.AccessLevel, isAlias, source);
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
@@ -173,6 +173,40 @@ public sealed class UnsTreeServiceAliasTagTests
|
||||
normal.IsAlias.ShouldBeFalse();
|
||||
normal.Source.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A GalaxyMxGateway-bound tag whose TagConfig carries no <c>FullName</c> (e.g. <c>"{}"</c>) is
|
||||
/// still an alias (<c>IsAlias = true</c>) but has a <c>null</c> Source — the display should not
|
||||
/// show the literal <c>"galaxy:"</c> string.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task LoadTagsForEquipment_alias_with_no_FullName_has_null_Source()
|
||||
{
|
||||
var dbName = SeedCluster();
|
||||
|
||||
using (var db = UnsTreeTestDb.CreateNamed(dbName))
|
||||
{
|
||||
db.Tags.Add(new Tag
|
||||
{
|
||||
TagId = "TAG-ALIAS-NONAME",
|
||||
DriverInstanceId = GatewayDriverId,
|
||||
EquipmentId = EquipmentId,
|
||||
Name = "unconfigured-alias",
|
||||
DataType = "Float",
|
||||
AccessLevel = TagAccessLevel.Read,
|
||||
TagConfig = "{}",
|
||||
});
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
var service = new UnsTreeService(UnsTreeTestDb.Factory(dbName));
|
||||
|
||||
var rows = await service.LoadTagsForEquipmentAsync(EquipmentId);
|
||||
|
||||
var alias = rows.ShouldHaveSingleItem(r => r.TagId == "TAG-ALIAS-NONAME");
|
||||
alias.IsAlias.ShouldBeTrue();
|
||||
alias.Source.ShouldBeNull();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Small Shouldly-style helper for "exactly one match" assertions used by these tests.</summary>
|
||||
|
||||
Reference in New Issue
Block a user