From d2dbf7b0d7267f9f32531d25bf05cdb735d1e40f Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 8 Jun 2026 06:49:28 -0400 Subject: [PATCH] feat(config): make Equipment.DriverInstanceId nullable + driver-less AdminUI support + migration --- ...8-driverless-equipment-namespace-design.md | 9 + ...26-06-08-driverless-equipment-namespace.md | 6 + .../Entities/Equipment.cs | 7 +- ...lableEquipmentDriverInstanceId.Designer.cs | 1758 +++++++++++++++++ ...04706_NullableEquipmentDriverInstanceId.cs | 40 + .../OtOpcUaConfigDbContextModelSnapshot.cs | 1 - .../Pages/Clusters/EquipmentEdit.razor | 9 +- .../Components/Pages/Clusters/TagEdit.razor | 2 +- 8 files changed, 1823 insertions(+), 9 deletions(-) create mode 100644 src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Migrations/20260608104706_NullableEquipmentDriverInstanceId.Designer.cs create mode 100644 src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Migrations/20260608104706_NullableEquipmentDriverInstanceId.cs diff --git a/docs/plans/2026-06-08-driverless-equipment-namespace-design.md b/docs/plans/2026-06-08-driverless-equipment-namespace-design.md index 7ff9df54..3a30fb00 100644 --- a/docs/plans/2026-06-08-driverless-equipment-namespace-design.md +++ b/docs/plans/2026-06-08-driverless-equipment-namespace-design.md @@ -106,6 +106,15 @@ In `cmd_populate_equipment`: become no-ops; remove for clarity. Keep the `Namespace` INSERT/teardown. - Fix the stale `# … "an Equipment namespace has a driver" expectations` comment. +### AdminUI — two production derefs (found at build time, not by the grep sweep) +Making the column nullable surfaced two `.razor` sites the impact grep missed (caught by `TreatWarningsAsErrors`): +- `Components/Pages/Clusters/TagEdit.razor:191` — `db.Equipment.Where(e => driverIds.Contains(e.DriverInstanceId))` (CS8604). + Behavior-preserving fix: guard `e.DriverInstanceId != null && …` (SQL already excludes NULL from an `IN` set, so this only satisfies the compiler). +- `Components/Pages/Clusters/EquipmentEdit.razor` — the equipment editor loads `DriverInstanceId` into a non-null + `FormModel` (line 183, CS8601) and **mandates** a driver on save (`"Pick a driver instance."`). Decision: give it + **full driver-less support** — `FormModel.DriverInstanceId` → `string?`, add a "(none / driver-less)" option to the + driver dropdown, relax the mandatory-driver validation, and persist NULL when none is selected (normalize empty → null). + ### Noted, not changing (YAGNI) - `sp_ComputeGenerationDiff` includes `DriverInstanceId` in a `CHECKSUM(...)`. It is NULL-tolerant for this one-time transition and sits on the **dormant** generation-diff path (the active deploy gate is diff --git a/docs/plans/2026-06-08-driverless-equipment-namespace.md b/docs/plans/2026-06-08-driverless-equipment-namespace.md index e07df668..78f219c0 100644 --- a/docs/plans/2026-06-08-driverless-equipment-namespace.md +++ b/docs/plans/2026-06-08-driverless-equipment-namespace.md @@ -20,9 +20,15 @@ **Files:** - Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Entities/Equipment.cs` (line ~23) +- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/Clusters/TagEdit.razor` (~line 191 — null-guard the EF predicate) +- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Components/Pages/Clusters/EquipmentEdit.razor` (FormModel + dropdown + save — full driver-less support) - Create: `src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Migrations/_NullableEquipmentDriverInstanceId.cs` (generated by `dotnet ef`) - Auto-modify: `src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Migrations/OtOpcUaConfigDbContextModelSnapshot.cs` (regenerated by `dotnet ef`) +**AdminUI surface (found at build time — the nullable change breaks two `.razor` sites under `TreatWarningsAsErrors`):** +- `TagEdit.razor:191`: `db.Equipment.Where(e => driverIds.Contains(e.DriverInstanceId))` → guard `e.DriverInstanceId != null && driverIds.Contains(e.DriverInstanceId)` (behavior-preserving; SQL already excludes NULL). +- `EquipmentEdit.razor`: full driver-less support — `FormModel.DriverInstanceId` → `string?`; add a "(none / driver-less)" option to the driver `