diff --git a/apps/admin-ui/src/client-scopes/ClientScopesSection.tsx b/apps/admin-ui/src/client-scopes/ClientScopesSection.tsx index 69f9a8f982..99de1426c5 100644 --- a/apps/admin-ui/src/client-scopes/ClientScopesSection.tsx +++ b/apps/admin-ui/src/client-scopes/ClientScopesSection.tsx @@ -160,13 +160,9 @@ export default function ClientScopesSection() { const ClientScopeDetailLink = ({ id, - type, name, }: ClientScopeDefaultOptionalType) => ( - + {name} ); diff --git a/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx b/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx index e418009cde..508edffd2a 100644 --- a/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx +++ b/apps/admin-ui/src/client-scopes/details/MappingDetails.tsx @@ -38,7 +38,7 @@ export default function MappingDetails() { const { adminClient } = useAdminClient(); const { addAlert, addError } = useAlerts(); - const { id, mapperId, type } = useParams(); + const { id, mapperId } = useParams(); const form = useForm(); const { register, setValue, errors, handleSubmit } = form; const [mapping, setMapping] = useState(); @@ -56,7 +56,7 @@ export default function MappingDetails() { const isOnClientScope = !!useRouteMatch(MapperRoute.path); const toDetails = () => isOnClientScope - ? toClientScope({ realm, id, type: type!, tab: "mappers" }) + ? toClientScope({ realm, id, tab: "mappers" }) : `/${realm}/clients/${id}/mappers`; useFetch( @@ -92,7 +92,7 @@ export default function MappingDetails() { data, }; } else { - const model = type + const model = isOnClientScope ? await adminClient.clientScopes.findOne({ id }) : await adminClient.clients.findOne({ id }); if (!model) { diff --git a/apps/admin-ui/src/client-scopes/form/ClientScopeForm.tsx b/apps/admin-ui/src/client-scopes/form/ClientScopeForm.tsx index ff854d7ffe..e74c6d3659 100644 --- a/apps/admin-ui/src/client-scopes/form/ClientScopeForm.tsx +++ b/apps/admin-ui/src/client-scopes/form/ClientScopeForm.tsx @@ -18,6 +18,7 @@ import { useAlerts } from "../../components/alert/Alerts"; import { AllClientScopes, changeScope, + ClientScope, ClientScopeDefaultOptionalType, } from "../../components/client-scope/ClientScopeTypes"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; @@ -46,7 +47,7 @@ export default function ClientScopeForm() { const { realm } = useRealm(); const { adminClient } = useAdminClient(); - const { id, type } = useParams<{ id: string; type: AllClientScopes }>(); + const { id } = useParams<{ id: string }>(); const { addAlert, addError } = useAlerts(); @@ -60,9 +61,23 @@ export default function ClientScopeForm() { if (!clientScope) { throw new Error(t("common:notFound")); } + + const defaultScopes = + await adminClient.clientScopes.listDefaultClientScopes(); + const optionalScopes = + await adminClient.clientScopes.listDefaultOptionalClientScopes(); + return { ...clientScope, - type, + type: defaultScopes.find( + (defaultScope) => defaultScope.name === clientScope.name + ) + ? ClientScope.default + : optionalScopes.find( + (optionalScope) => optionalScope.name === clientScope.name + ) + ? ClientScope.optional + : AllClientScopes.none, }; } }, @@ -81,11 +96,7 @@ export default function ClientScopeForm() { if (id) { await adminClient.clientScopes.update({ id }, clientScopes); - changeScope( - adminClient, - { ...clientScopes, id, type }, - clientScopes.type - ); + changeScope(adminClient, { ...clientScopes, id }, clientScopes.type); } else { await adminClient.clientScopes.create(clientScopes); const scope = await adminClient.clientScopes.findOneByName({ @@ -104,7 +115,6 @@ export default function ClientScopeForm() { toClientScope({ realm, id: scope.id!, - type: clientScopes.type || "none", tab: "settings", }) ); @@ -173,7 +183,6 @@ export default function ClientScopeForm() { toMapper({ realm, id: clientScope!.id!, - type, mapperId: mapper.id!, }) ); @@ -215,7 +224,6 @@ export default function ClientScopeForm() { realm, id, tab, - type, }), history, }); @@ -269,7 +277,7 @@ export default function ClientScopeForm() { onAdd={addMappers} onDelete={onDelete} detailLink={(id) => - toMapper({ realm, id: clientScope.id!, type, mapperId: id! }) + toMapper({ realm, id: clientScope.id!, mapperId: id! }) } /> diff --git a/apps/admin-ui/src/client-scopes/routes/ClientScope.ts b/apps/admin-ui/src/client-scopes/routes/ClientScope.ts index 8cea6fa70d..4ea1a9d0fa 100644 --- a/apps/admin-ui/src/client-scopes/routes/ClientScope.ts +++ b/apps/admin-ui/src/client-scopes/routes/ClientScope.ts @@ -9,11 +9,10 @@ export type ClientScopeParams = { realm: string; id: string; tab: ClientScopeTab; - type?: string; }; export const ClientScopeRoute: RouteDef = { - path: "/:realm/client-scopes/:id/:tab/:type", + path: "/:realm/client-scopes/:id/:tab", component: lazy(() => import("../form/ClientScopeForm")), breadcrumb: (t) => t("client-scopes:clientScopeDetails"), access: "view-clients", diff --git a/apps/admin-ui/src/client-scopes/routes/Mapper.ts b/apps/admin-ui/src/client-scopes/routes/Mapper.ts index b2796a0885..b7b6e24884 100644 --- a/apps/admin-ui/src/client-scopes/routes/Mapper.ts +++ b/apps/admin-ui/src/client-scopes/routes/Mapper.ts @@ -6,12 +6,11 @@ import type { RouteDef } from "../../route-config"; export type MapperParams = { realm: string; id: string; - type: string; mapperId: string; }; export const MapperRoute: RouteDef = { - path: "/:realm/client-scopes/:id/mappers/:type/:mapperId", + path: "/:realm/client-scopes/:id/mappers/:mapperId", component: lazy(() => import("../details/MappingDetails")), breadcrumb: (t) => t("common:mappingDetails"), access: "view-clients",