diff --git a/js/apps/admin-ui/src/client-scopes/EditClientScope.tsx b/js/apps/admin-ui/src/client-scopes/EditClientScope.tsx index 7624d13933..89f4fa6442 100644 --- a/js/apps/admin-ui/src/client-scopes/EditClientScope.tsx +++ b/js/apps/admin-ui/src/client-scopes/EditClientScope.tsx @@ -185,6 +185,7 @@ export default function EditClientScope() { realm, id: clientScope!.id!, mapperId: mapper.id!, + viewMode: "new", }), ); } else { @@ -256,7 +257,12 @@ export default function EditClientScope() { onAdd={addMappers} onDelete={onDelete} detailLink={(id) => - toMapper({ realm, id: clientScope.id!, mapperId: id! }) + toMapper({ + realm, + id: clientScope.id!, + mapperId: id!, + viewMode: "edit", + }) } /> diff --git a/js/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx b/js/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx index f93aae08c5..4a99d21bc4 100644 --- a/js/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx +++ b/js/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx @@ -34,7 +34,7 @@ export default function MappingDetails() { const { t } = useTranslation(); const { addAlert, addError } = useAlerts(); - const { id, mapperId } = useParams(); + const { id, mapperId, viewMode } = useParams(); const form = useForm(); const { setValue, handleSubmit } = form; const [mapping, setMapping] = useState(); @@ -46,8 +46,7 @@ export default function MappingDetails() { const navigate = useNavigate(); const { realm } = useRealm(); const serverInfo = useServerInfo(); - const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/; - const isUpdating = !!isGuid.exec(mapperId); + const isUpdating = viewMode === "edit"; const isOnClientScope = !!useMatch(MapperRoute.path); const toDetails = () => diff --git a/js/apps/admin-ui/src/client-scopes/routes/Mapper.tsx b/js/apps/admin-ui/src/client-scopes/routes/Mapper.tsx index 53aa93719a..561abcb9bc 100644 --- a/js/apps/admin-ui/src/client-scopes/routes/Mapper.tsx +++ b/js/apps/admin-ui/src/client-scopes/routes/Mapper.tsx @@ -7,12 +7,13 @@ export type MapperParams = { realm: string; id: string; mapperId: string; + viewMode: "edit" | "new"; }; const MappingDetails = lazy(() => import("../details/MappingDetails")); export const MapperRoute: AppRouteObject = { - path: "/:realm/client-scopes/:id/mappers/:mapperId", + path: "/:realm/client-scopes/:id/mappers/:mapperId/:viewMode", element: , breadcrumb: (t) => t("mappingDetails"), handle: { diff --git a/js/apps/admin-ui/src/clients/routes/Mapper.tsx b/js/apps/admin-ui/src/clients/routes/Mapper.tsx index f101c39aad..4ec83139fc 100644 --- a/js/apps/admin-ui/src/clients/routes/Mapper.tsx +++ b/js/apps/admin-ui/src/clients/routes/Mapper.tsx @@ -7,6 +7,7 @@ export type MapperParams = { realm: string; id: string; mapperId: string; + viewMode: "edit" | "new"; }; const MappingDetails = lazy( @@ -14,7 +15,7 @@ const MappingDetails = lazy( ); export const MapperRoute: AppRouteObject = { - path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId", + path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId/:viewMode", element: , breadcrumb: (t) => t("mappingDetails"), handle: { diff --git a/js/apps/admin-ui/src/clients/scopes/DedicatedScopes.tsx b/js/apps/admin-ui/src/clients/scopes/DedicatedScopes.tsx index 275c2959a0..355fee71cd 100644 --- a/js/apps/admin-ui/src/clients/scopes/DedicatedScopes.tsx +++ b/js/apps/admin-ui/src/clients/scopes/DedicatedScopes.tsx @@ -60,6 +60,7 @@ export default function DedicatedScopes() { realm, id: client.id!, mapperId: mapper.id!, + viewMode: "new", }), ); } else { @@ -122,7 +123,7 @@ export default function DedicatedScopes() { onAdd={addMappers} onDelete={onDeleteMapper} detailLink={(mapperId) => - toMapper({ realm, id: client.id!, mapperId }) + toMapper({ realm, id: client.id!, mapperId, viewMode: "edit" }) } />