Removed type from url, query it (#3974)
This commit is contained in:
parent
6f43a8d9ff
commit
c7c7df872f
5 changed files with 25 additions and 23 deletions
|
@ -160,13 +160,9 @@ export default function ClientScopesSection() {
|
|||
|
||||
const ClientScopeDetailLink = ({
|
||||
id,
|
||||
type,
|
||||
name,
|
||||
}: ClientScopeDefaultOptionalType) => (
|
||||
<Link
|
||||
key={id}
|
||||
to={toClientScope({ realm, id: id!, type, tab: "settings" })}
|
||||
>
|
||||
<Link key={id} to={toClientScope({ realm, id: id!, tab: "settings" })}>
|
||||
{name}
|
||||
</Link>
|
||||
);
|
||||
|
|
|
@ -38,7 +38,7 @@ export default function MappingDetails() {
|
|||
const { adminClient } = useAdminClient();
|
||||
const { addAlert, addError } = useAlerts();
|
||||
|
||||
const { id, mapperId, type } = useParams<MapperParams>();
|
||||
const { id, mapperId } = useParams<MapperParams>();
|
||||
const form = useForm();
|
||||
const { register, setValue, errors, handleSubmit } = form;
|
||||
const [mapping, setMapping] = useState<ProtocolMapperTypeRepresentation>();
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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! })
|
||||
}
|
||||
/>
|
||||
</Tab>
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue