fix(adminui): make /admin/secrets interactive - wrap the Secrets.Ui page with a render mode (#483)
The Secrets.Ui RCL's routable page was routed directly, but this host's router is deliberately static (cookie SignInAsync needs SSR) with per-page @rendermode opt-in - a directive the RCL page cannot carry, because the other three family hosts render it under a globally interactive router where a nested render mode throws. Routing straight to the RCL page therefore rendered /admin/secrets with no circuit: it displayed, but every @onclick was silently dead. Fix: a host-side wrapper page (Pages/SecretsAdmin.razor) now owns /admin/secrets, carries the standard per-page InteractiveServer render mode, re-states the RCL page's own authorization policy (the router only enforces [Authorize] on the routed component, which is now the wrapper), and renders the RCL page as an ordinary child. The RCL assembly is de-registered from both AdditionalAssemblies sites (router + endpoint) so the route is unambiguous. Guards: SecretsPageWiringTests pins the render mode (the #483 regression), route parity with the RCL page, and policy parity; the page census in PageAuthorizationGuardTests classifies the new page and admits the secrets:manage policy. AdminUI.Tests 665/665. Live-verified on the rebuilt docker-dev rig with Playwright: /_blazor circuit negotiated on /admin/secrets and Add secret opens the editor (before the fix: zero interactive markers, no circuit, dead click). Closes #483. Claude-Session: https://claude.ai/code/session_01BL2Vu1ESDQ9SCN4gVKkdts
This commit is contained in:
@@ -19,7 +19,11 @@
|
||||
<HeadOutlet/>
|
||||
</head>
|
||||
<body>
|
||||
<Routes AdditionalAssemblies="@(new[] { typeof(ZB.MOM.WW.Secrets.Ui.SecretsPage).Assembly })" />
|
||||
@* No AdditionalAssemblies: the Secrets.Ui RCL's routable page is NOT routed directly in this
|
||||
host — Pages/Secrets.razor wraps it so the route can carry this host's per-page
|
||||
@rendermode (lmxopcua#483); registering the RCL routes too would make /admin/secrets
|
||||
ambiguous. *@
|
||||
<Routes />
|
||||
<script src="_content/ZB.MOM.WW.OtOpcUa.AdminUI/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<ThemeScripts />
|
||||
<script src="_content/ZB.MOM.WW.OtOpcUa.AdminUI/js/monaco-init.js"></script>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
@page "/admin/secrets"
|
||||
@attribute [Authorize(Policy = ZB.MOM.WW.Secrets.Ui.SecretsAuthorization.ManagePolicy)]
|
||||
@rendermode RenderMode.InteractiveServer
|
||||
@using ZB.MOM.WW.Secrets.Ui
|
||||
|
||||
@* Host-side wrapper for the ZB.MOM.WW.Secrets.Ui secrets page (lmxopcua#483).
|
||||
|
||||
This host's <Routes/> is deliberately static (cookie SignInAsync needs SSR), so every
|
||||
interactive page opts in per-page with @rendermode — a directive the RCL's own routable
|
||||
SecretsPage cannot carry, because the other three family hosts render it under a globally
|
||||
interactive router where a nested render mode throws. Routing straight to the RCL page
|
||||
therefore produced a statically-rendered, dead page here: no circuit, @onclick inert.
|
||||
|
||||
So this wrapper owns the /admin/secrets route in THIS host (the RCL assembly is no longer
|
||||
passed to either AdditionalAssemblies registration — doing both would make the route
|
||||
ambiguous), carries the standard per-page render mode, re-states the RCL page's own
|
||||
authorization policy (the router only enforces [Authorize] on the routed page itself,
|
||||
which is now this one), and renders the RCL page as an ordinary child component. *@
|
||||
|
||||
<SecretsPage />
|
||||
@@ -30,13 +30,14 @@ public static class EndpointRouteBuilderExtensions
|
||||
// Razor class library static assets (_content/ZB.MOM.WW.OtOpcUa.AdminUI/**) are
|
||||
// served via the Host's app.UseStaticFiles() middleware which must run BEFORE
|
||||
// UseAuthentication() — see Program.cs.
|
||||
// The /admin/secrets management page lives in the external ZB.MOM.WW.Secrets.Ui RCL, so its
|
||||
// routable component must be discovered at the endpoint layer (AddAdditionalAssemblies) —
|
||||
// the interactive Router's AdditionalAssemblies (App.razor) alone is not enough for SSR
|
||||
// endpoint discovery. Both registrations are required or /admin/secrets 404s.
|
||||
// The Secrets.Ui RCL's routable page is deliberately NOT registered here (lmxopcua#483):
|
||||
// this host's router is static with per-page @rendermode opt-in, so routing straight to
|
||||
// the RCL page rendered it without a circuit — it displayed but every @onclick was dead.
|
||||
// Pages/Secrets.razor in THIS assembly owns /admin/secrets instead (wrapping the RCL
|
||||
// page with the render mode); registering the RCL routes too would make the route
|
||||
// ambiguous.
|
||||
app.MapRazorComponents<TApp>()
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddAdditionalAssemblies(typeof(ZB.MOM.WW.Secrets.Ui.SecretsPage).Assembly);
|
||||
.AddInteractiveServerRenderMode();
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user