Complete common picker and tree field accessibility

This commit is contained in:
Joseph Doherty
2026-11-13 21:52:00 -05:00
parent 25e78ebe92
commit b990ebe3ea
43 changed files with 2581 additions and 74 deletions
@@ -0,0 +1,14 @@
using System.Reflection;
using System.Security.Claims;
using Microsoft.AspNetCore.Components.Authorization;
/// <summary>Authenticated read-only fixture identity; no real authorization store.</summary>
public sealed class CommonFixturePrincipal : AuthenticationStateProvider
{
public override Task<AuthenticationState> GetAuthenticationStateAsync() => Task.FromResult(new AuthenticationState(
new ClaimsPrincipal(new ClaimsIdentity([new(ClaimTypes.Name,"fixture-reader"),new(ClaimTypes.Role,"Reader")],"fixture"))));
}
/// <summary>Every external browse/connection operation is refused.</summary>
public class CommonRefusingBrowser : DispatchProxy
{
protected override object? Invoke(MethodInfo? method,object?[]? args) => throw new NotSupportedException("Common field fixture refuses "+method?.Name);
}
@@ -0,0 +1,24 @@
@page "/common"
@rendermode InteractiveServer
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers
<main class="container-fluid p-3"><h1>Common field fixture</h1><p>Synthetic read-only fixture; no connection operations.</p><output id="interactive">@_ready</output>
<EditForm EditContext="_context" OnSubmit="IgnoreSubmit">
@foreach(var type in Types)
{
@for(int copy=0;copy<2;copy++)
{
var key=type.Name+copy;
<section data-common="@type.Name" data-copy="@copy" @key="key"><h2>@type.Name · instance @copy</h2><DynamicComponent Type="type" Parameters="Values(type)" /></section>
}
}
</EditForm></main>
@code {
private readonly EditContext _context=new(new object());
private bool _ready;
protected override void OnAfterRender(bool firstRender){if(firstRender){_ready=true;StateHasChanged();}}
private static readonly Type[] Types=[typeof(DriverIdentitySection),typeof(DriverResilienceSection),typeof(AbCipAddressPickerBody),typeof(AbLegacyAddressPickerBody),typeof(FOCASAddressPickerBody),typeof(GalaxyAddressPickerBody),typeof(ModbusAddressPickerBody),typeof(OpcUaClientAddressPickerBody),typeof(S7AddressPickerBody),typeof(SqlAddressPickerBody),typeof(TwinCATAddressPickerBody)];
private static Dictionary<string,object> Values(Type type)=>type==typeof(DriverIdentitySection)
?new(){["Model"]=new DriverIdentitySection.DriverIdentityModel(),["IsNew"]=true,["ShowDriverType"]=true}:new();
private void IgnoreSubmit(EditContext context){}
}
@@ -2,6 +2,9 @@ using DeviceFormCanary.Components;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();
builder.Services.AddSingleton(System.Reflection.DispatchProxy.Create<ZB.MOM.WW.OtOpcUa.AdminUI.Uns.IUnsTreeService, ProtocolReadOnlyProxy>());
builder.Services.AddAuthorizationCore(options => options.AddPolicy(ZB.MOM.WW.OtOpcUa.Security.Auth.AdminUiPolicies.DriverOperator, policy => policy.RequireRole("Operator", "Administrator")));
builder.Services.AddSingleton<Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider, CommonFixturePrincipal>();
builder.Services.AddSingleton(System.Reflection.DispatchProxy.Create<ZB.MOM.WW.OtOpcUa.AdminUI.Browsing.IBrowserSessionService, CommonRefusingBrowser>());
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
var app = builder.Build();
app.UseAntiforgery();