fix: refresh Access Settings policy from /access response
Reopening the Access Settings dialog after a save could leave the
radio on the wrong policy: the form initialized `access_policy`
from the route list's snapshot, but the list isn't refreshed when
the dialog closes, so the snapshot's value silently shadowed the
just-saved policy.
Backend now returns the route's authoritative `access_policy` on
`GET /v2/model-routes/{id}/access`. Use that value when the GET
resolves, falling back to the parent snapshot only as the initial
seed so the radio isn't briefly unselected.
While we're here, widen the `access_policy` type from a closed
union to `string` — plugins can contribute additional policy
values via the `accessControl.allowedUsersOverride` slot, so the
wire type shouldn't restrict to the OSS-side enum.
This commit is contained in:
@@ -221,6 +221,10 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
const userMap = new Map(allusers.map((u) => [u.key, u]));
|
||||
|
||||
if (currentData?.id) {
|
||||
// Seed the radio from the parent's snapshot so the form isn't
|
||||
// momentarily unselected; the GET below replaces it with the
|
||||
// server's authoritative value, which is what survives a save
|
||||
// when the parent list hasn't been refreshed.
|
||||
form.setFieldsValue({
|
||||
access_policy: currentData?.access_policy
|
||||
});
|
||||
@@ -246,7 +250,7 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
setFilterInUsers(filterSet);
|
||||
|
||||
form.setFieldsValue({
|
||||
access_policy: currentData.access_policy,
|
||||
access_policy: res.access_policy ?? currentData.access_policy,
|
||||
users: res.items.map((item) => ({ id: item.id }))
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ const AccessControlModal: React.FC<
|
||||
|
||||
const handleOnFinish = async (values: AccessControlFormData) => {
|
||||
try {
|
||||
const data: any = {
|
||||
const data: AccessControlFormData = {
|
||||
access_policy: values.access_policy,
|
||||
// `users` is only meaningful for the legacy `allowed_users`
|
||||
// policy; for the plugin override (typically the principal-
|
||||
|
||||
Reference in New Issue
Block a user