fix: Client Protocol Mappers with non UUID ids cannot be edited (#34643)

closes #34636

Signed-off-by: Christian Janker <christian.janker@gmx.at>
This commit is contained in:
Christian Ja 2024-11-05 11:29:37 +01:00 committed by GitHub
parent b3dd26a7c3
commit 5b6ac5b14b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 7 deletions

View file

@ -185,6 +185,7 @@ export default function EditClientScope() {
realm, realm,
id: clientScope!.id!, id: clientScope!.id!,
mapperId: mapper.id!, mapperId: mapper.id!,
viewMode: "new",
}), }),
); );
} else { } else {
@ -256,7 +257,12 @@ export default function EditClientScope() {
onAdd={addMappers} onAdd={addMappers}
onDelete={onDelete} onDelete={onDelete}
detailLink={(id) => detailLink={(id) =>
toMapper({ realm, id: clientScope.id!, mapperId: id! }) toMapper({
realm,
id: clientScope.id!,
mapperId: id!,
viewMode: "edit",
})
} }
/> />
</Tab> </Tab>

View file

@ -34,7 +34,7 @@ export default function MappingDetails() {
const { t } = useTranslation(); const { t } = useTranslation();
const { addAlert, addError } = useAlerts(); const { addAlert, addError } = useAlerts();
const { id, mapperId } = useParams<MapperParams>(); const { id, mapperId, viewMode } = useParams<MapperParams>();
const form = useForm(); const form = useForm();
const { setValue, handleSubmit } = form; const { setValue, handleSubmit } = form;
const [mapping, setMapping] = useState<ProtocolMapperTypeRepresentation>(); const [mapping, setMapping] = useState<ProtocolMapperTypeRepresentation>();
@ -46,8 +46,7 @@ export default function MappingDetails() {
const navigate = useNavigate(); const navigate = useNavigate();
const { realm } = useRealm(); const { realm } = useRealm();
const serverInfo = useServerInfo(); const serverInfo = useServerInfo();
const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/; const isUpdating = viewMode === "edit";
const isUpdating = !!isGuid.exec(mapperId);
const isOnClientScope = !!useMatch(MapperRoute.path); const isOnClientScope = !!useMatch(MapperRoute.path);
const toDetails = () => const toDetails = () =>

View file

@ -7,12 +7,13 @@ export type MapperParams = {
realm: string; realm: string;
id: string; id: string;
mapperId: string; mapperId: string;
viewMode: "edit" | "new";
}; };
const MappingDetails = lazy(() => import("../details/MappingDetails")); const MappingDetails = lazy(() => import("../details/MappingDetails"));
export const MapperRoute: AppRouteObject = { export const MapperRoute: AppRouteObject = {
path: "/:realm/client-scopes/:id/mappers/:mapperId", path: "/:realm/client-scopes/:id/mappers/:mapperId/:viewMode",
element: <MappingDetails />, element: <MappingDetails />,
breadcrumb: (t) => t("mappingDetails"), breadcrumb: (t) => t("mappingDetails"),
handle: { handle: {

View file

@ -7,6 +7,7 @@ export type MapperParams = {
realm: string; realm: string;
id: string; id: string;
mapperId: string; mapperId: string;
viewMode: "edit" | "new";
}; };
const MappingDetails = lazy( const MappingDetails = lazy(
@ -14,7 +15,7 @@ const MappingDetails = lazy(
); );
export const MapperRoute: AppRouteObject = { export const MapperRoute: AppRouteObject = {
path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId", path: "/:realm/clients/:id/clientScopes/dedicated/mappers/:mapperId/:viewMode",
element: <MappingDetails />, element: <MappingDetails />,
breadcrumb: (t) => t("mappingDetails"), breadcrumb: (t) => t("mappingDetails"),
handle: { handle: {

View file

@ -60,6 +60,7 @@ export default function DedicatedScopes() {
realm, realm,
id: client.id!, id: client.id!,
mapperId: mapper.id!, mapperId: mapper.id!,
viewMode: "new",
}), }),
); );
} else { } else {
@ -122,7 +123,7 @@ export default function DedicatedScopes() {
onAdd={addMappers} onAdd={addMappers}
onDelete={onDeleteMapper} onDelete={onDeleteMapper}
detailLink={(mapperId) => detailLink={(mapperId) =>
toMapper({ realm, id: client.id!, mapperId }) toMapper({ realm, id: client.id!, mapperId, viewMode: "edit" })
} }
/> />
</Tab> </Tab>