make all sub tabs routeable tabs (#1954)

* make all sub tabs routeable tabs

closes: #1507, closes: #1204

* fixed tabless route
This commit is contained in:
Erik Jan de Wit 2022-01-31 08:19:44 +01:00 committed by GitHub
parent db63cdd61c
commit b9e79b6d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 113 additions and 259 deletions

View file

@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from "react"; import React, { Fragment, useEffect, useMemo, useState } from "react";
import { import {
ActionGroup, ActionGroup,
AlertVariant, AlertVariant,
@ -370,7 +370,7 @@ export default function ClientProfileForm() {
(type) => type.id === executor.executor (type) => type.id === executor.executor
) )
.map((type) => ( .map((type) => (
<> <Fragment key={type.id}>
<HelpItem <HelpItem
key={type.id} key={type.id}
helpText={type.helpText} helpText={type.helpText}
@ -394,7 +394,7 @@ export default function ClientProfileForm() {
}); });
}} }}
></Button> ></Button>
</> </Fragment>
))} ))}
</DataListCell>, </DataListCell>,
]} ]}

View file

@ -31,7 +31,6 @@ import { useAlerts } from "../components/alert/Alerts";
import { useAdminClient, useFetch } from "../context/auth/AdminClient"; import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { HelpItem } from "../components/help-enabler/HelpItem"; import { HelpItem } from "../components/help-enabler/HelpItem";
import { PlusCircleIcon, TrashIcon } from "@patternfly/react-icons"; import { PlusCircleIcon, TrashIcon } from "@patternfly/react-icons";
import "./RealmSettingsSection.css";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog"; import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import type ClientPolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientPolicyRepresentation"; import type ClientPolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientPolicyRepresentation";
import { toNewClientPolicyCondition } from "./routes/AddCondition"; import { toNewClientPolicyCondition } from "./routes/AddCondition";
@ -40,7 +39,9 @@ import { toEditClientPolicyCondition } from "./routes/EditCondition";
import type { EditClientPolicyParams } from "./routes/EditClientPolicy"; import type { EditClientPolicyParams } from "./routes/EditClientPolicy";
import { AddClientProfileModal } from "./AddClientProfileModal"; import { AddClientProfileModal } from "./AddClientProfileModal";
import type ClientProfileRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientProfileRepresentation"; import type ClientProfileRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientProfileRepresentation";
import { toRealmSettings } from "./routes/RealmSettings"; import { toClientPolicies } from "./routes/ClientPolicies";
import "./RealmSettingsSection.css";
type NewClientPolicyForm = Required<ClientPolicyRepresentation>; type NewClientPolicyForm = Required<ClientPolicyRepresentation>;
@ -275,10 +276,9 @@ export default function NewClientPolicyForm() {
}); });
addAlert(t("deleteClientPolicySuccess"), AlertVariant.success); addAlert(t("deleteClientPolicySuccess"), AlertVariant.success);
history.push( history.push(
toRealmSettings({ toClientPolicies({
realm, realm,
tab: "clientPolicies", tab: "policies",
subTab: "policies",
}) })
); );
} catch (error) { } catch (error) {
@ -321,10 +321,9 @@ export default function NewClientPolicyForm() {
}); });
addAlert(t("deleteClientSuccess"), AlertVariant.success); addAlert(t("deleteClientSuccess"), AlertVariant.success);
history.push( history.push(
toRealmSettings({ toClientPolicies({
realm, realm,
tab: "clientPolicies", tab: "policies",
subTab: "policies",
}) })
); );
} catch (error) { } catch (error) {
@ -367,10 +366,9 @@ export default function NewClientPolicyForm() {
}); });
addAlert(t("deleteClientSuccess"), AlertVariant.success); addAlert(t("deleteClientSuccess"), AlertVariant.success);
history.push( history.push(
toRealmSettings({ toClientPolicies({
realm, realm,
tab: "clientPolicies", tab: "policies",
subTab: "policies",
}) })
); );
} catch (error) { } catch (error) {
@ -507,10 +505,9 @@ export default function NewClientPolicyForm() {
showAddConditionsAndProfilesForm || policyName showAddConditionsAndProfilesForm || policyName
? reset() ? reset()
: history.push( : history.push(
toRealmSettings({ toClientPolicies({
realm, realm,
tab: "clientPolicies", tab: "policies",
subTab: "policies",
}) })
) )
} }

View file

@ -1,7 +1,4 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Breadcrumb, BreadcrumbItem } from "@patternfly/react-core";
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation"; import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation";
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
@ -9,115 +6,7 @@ import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner"
import { useAdminClient, useFetch } from "../context/auth/AdminClient"; import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext"; import { useRealm } from "../context/realm-context/RealmContext";
import { KEY_PROVIDER_TYPE } from "../util"; import { KEY_PROVIDER_TYPE } from "../util";
import { toRealmSettings } from "./routes/RealmSettings";
import { RealmSettingsTabs } from "./RealmSettingsTabs"; import { RealmSettingsTabs } from "./RealmSettingsTabs";
import { toClientPolicies } from "./routes/ClientPolicies";
export const EditProviderCrumb = () => {
const { t } = useTranslation("realm-settings");
const { realm } = useRealm();
return (
<Breadcrumb>
<BreadcrumbItem
render={(props) => (
<Link {...props} to={toRealmSettings({ realm, tab: "keys" })}>
{t("keys")}
</Link>
)}
/>
<BreadcrumbItem>{t("providers")}</BreadcrumbItem>
<BreadcrumbItem isActive>{t("editProvider")}</BreadcrumbItem>
</Breadcrumb>
);
};
export const ToClientPolicies = () => {
const { t } = useTranslation("realm-settings");
const { realm } = useRealm();
return (
<BreadcrumbItem
render={(props) => (
<Link
{...props}
to={toRealmSettings({
realm,
tab: "clientPolicies",
subTab: "policies",
})}
>
{t("clientPolicies")}
</Link>
)}
/>
);
};
export const EditPolicyCrumb = () => {
const { t } = useTranslation("realm-settings");
return (
<Breadcrumb>
<ToClientPolicies />
<BreadcrumbItem isActive>{t("policyDetails")}</BreadcrumbItem>
</Breadcrumb>
);
};
export const EditProfileCrumb = () => {
const { t } = useTranslation("realm-settings");
const { realm } = useRealm();
return (
<Breadcrumb>
<BreadcrumbItem
render={(props) => (
<Link {...props} to={toClientPolicies({ realm, tab: "profiles" })}>
{t("clientPolicies")}
</Link>
)}
/>
<BreadcrumbItem isActive>{t("clientProfile")}</BreadcrumbItem>
</Breadcrumb>
);
};
export const EditExecutorCrumb = () => {
const { t } = useTranslation("realm-settings");
const { realm } = useRealm();
return (
<Breadcrumb>
<BreadcrumbItem
render={(props) => (
<Link {...props} to={toClientPolicies({ realm, tab: "profiles" })}>
{t("clientPolicies")}
</Link>
)}
/>
<BreadcrumbItem isActive>{t("executorDetails")}</BreadcrumbItem>
</Breadcrumb>
);
};
export const NewPolicyCrumb = () => {
const { t } = useTranslation("realm-settings");
const { realm } = useRealm();
return (
<Breadcrumb>
<BreadcrumbItem
render={(props) => (
<Link {...props} to={toClientPolicies({ realm, tab: "policy" })}>
{t("clientPolicies")}
</Link>
)}
/>
<BreadcrumbItem isActive>{t("createPolicy")}</BreadcrumbItem>
</Breadcrumb>
);
};
const sortByPriority = (components: ComponentRepresentation[]) => { const sortByPriority = (components: ComponentRepresentation[]) => {
const sortedComponents = [...components].sort((a, b) => { const sortedComponents = [...components].sort((a, b) => {

View file

@ -9,7 +9,6 @@ import {
DropdownSeparator, DropdownSeparator,
PageSection, PageSection,
Tab, Tab,
Tabs,
TabTitleText, TabTitleText,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
@ -48,7 +47,7 @@ import ProfilesTab from "./ProfilesTab";
import { PoliciesTab } from "./PoliciesTab"; import { PoliciesTab } from "./PoliciesTab";
import { PartialImportDialog } from "./PartialImport"; import { PartialImportDialog } from "./PartialImport";
import { PartialExportDialog } from "./PartialExport"; import { PartialExportDialog } from "./PartialExport";
import { toRealmSettings } from "./routes/RealmSettings"; import { RealmSettingsTab, toRealmSettings } from "./routes/RealmSettings";
import { LocalizationTab } from "./LocalizationTab"; import { LocalizationTab } from "./LocalizationTab";
import { HelpItem } from "../components/help-enabler/HelpItem"; import { HelpItem } from "../components/help-enabler/HelpItem";
import { UserRegistration } from "./UserRegistration"; import { UserRegistration } from "./UserRegistration";
@ -57,7 +56,8 @@ import environment from "../environment";
import helpUrls from "../help-urls"; import helpUrls from "../help-urls";
import { UserProfileTab } from "./user-profile/UserProfileTab"; import { UserProfileTab } from "./user-profile/UserProfileTab";
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled"; import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
import { toClientPolicies } from "./routes/ClientPolicies"; import { ClientPoliciesTab, toClientPolicies } from "./routes/ClientPolicies";
import { KeySubTab, toKeysTab } from "./routes/KeysTab";
type RealmSettingsHeaderProps = { type RealmSettingsHeaderProps = {
onChange: (value: boolean) => void; onChange: (value: boolean) => void;
@ -188,7 +188,6 @@ export const RealmSettingsTabs = ({
const form = useForm({ mode: "onChange", shouldUnregister: false }); const form = useForm({ mode: "onChange", shouldUnregister: false });
const { control, getValues, setValue, reset: resetForm } = form; const { control, getValues, setValue, reset: resetForm } = form;
const [activeTab, setActiveTab] = useState(0);
const [key, setKey] = useState(0); const [key, setKey] = useState(0);
const refreshHeader = () => { const refreshHeader = () => {
@ -219,7 +218,7 @@ export const RealmSettingsTabs = ({
const isRealmRenamed = realmName !== realm.realm; const isRealmRenamed = realmName !== realm.realm;
if (isRealmRenamed) { if (isRealmRenamed) {
await refreshRealms(); await refreshRealms();
history.push(toRealmSettings({ realm: realm.realm! })); history.push(toRealmSettings({ realm: realm.realm!, tab: "general" }));
} }
addAlert(t("saveSuccess"), AlertVariant.success); addAlert(t("saveSuccess"), AlertVariant.success);
} catch (error) { } catch (error) {
@ -233,6 +232,26 @@ export const RealmSettingsTabs = ({
defaultValue: "false", defaultValue: "false",
}); });
const route = (tab: RealmSettingsTab | undefined = "general") =>
routableTab({
to: toRealmSettings({ realm: realmName, tab }),
history,
});
const policiesRoute = (tab: ClientPoliciesTab) =>
routableTab({
to: toClientPolicies({
realm: realmName,
tab,
}),
history,
});
const keysRoute = (tab: KeySubTab) =>
routableTab({
to: toKeysTab({ realm: realmName, tab }),
history,
});
return ( return (
<> <>
<Controller <Controller
@ -251,14 +270,18 @@ export const RealmSettingsTabs = ({
/> />
<PageSection variant="light" className="pf-u-p-0"> <PageSection variant="light" className="pf-u-p-0">
<FormProvider {...form}> <FormProvider {...form}>
<RoutableTabs isBox mountOnEnter> <RoutableTabs
isBox
mountOnEnter
defaultLocation={toRealmSettings({
realm: realmName,
tab: "general",
})}
>
<Tab <Tab
title={<TabTitleText>{t("general")}</TabTitleText>} title={<TabTitleText>{t("general")}</TabTitleText>}
data-testid="rs-general-tab" data-testid="rs-general-tab"
{...routableTab({ {...route()}
to: toRealmSettings({ realm: realmName }),
history,
})}
> >
<RealmSettingsGeneralTab <RealmSettingsGeneralTab
save={save} save={save}
@ -268,10 +291,7 @@ export const RealmSettingsTabs = ({
<Tab <Tab
title={<TabTitleText>{t("login")}</TabTitleText>} title={<TabTitleText>{t("login")}</TabTitleText>}
data-testid="rs-login-tab" data-testid="rs-login-tab"
{...routableTab({ {...route("login")}
to: toRealmSettings({ realm: realmName, tab: "login" }),
history,
})}
> >
<RealmSettingsLoginTab <RealmSettingsLoginTab
refresh={refresh} refresh={refresh}
@ -282,20 +302,14 @@ export const RealmSettingsTabs = ({
<Tab <Tab
title={<TabTitleText>{t("email")}</TabTitleText>} title={<TabTitleText>{t("email")}</TabTitleText>}
data-testid="rs-email-tab" data-testid="rs-email-tab"
{...routableTab({ {...route("email")}
to: toRealmSettings({ realm: realmName, tab: "email" }),
history,
})}
> >
<RealmSettingsEmailTab realm={realm} /> <RealmSettingsEmailTab realm={realm} />
</Tab> </Tab>
<Tab <Tab
title={<TabTitleText>{t("themes")}</TabTitleText>} title={<TabTitleText>{t("themes")}</TabTitleText>}
data-testid="rs-themes-tab" data-testid="rs-themes-tab"
{...routableTab({ {...route("themes")}
to: toRealmSettings({ realm: realmName, tab: "themes" }),
history,
})}
> >
<RealmSettingsThemesTab <RealmSettingsThemesTab
save={save} save={save}
@ -305,21 +319,17 @@ export const RealmSettingsTabs = ({
<Tab <Tab
title={<TabTitleText>{t("realm-settings:keys")}</TabTitleText>} title={<TabTitleText>{t("realm-settings:keys")}</TabTitleText>}
data-testid="rs-keys-tab" data-testid="rs-keys-tab"
{...routableTab({ {...route("keys")}
to: toRealmSettings({ realm: realmName, tab: "keys" }),
history,
})}
> >
<Tabs <RoutableTabs
activeKey={activeTab} defaultLocation={toKeysTab({ realm: realmName, tab: "list" })}
onSelect={(_, key) => setActiveTab(Number(key))}
> >
<Tab <Tab
id="keysList" id="keysList"
eventKey={0}
data-testid="rs-keys-list-tab" data-testid="rs-keys-list-tab"
aria-label="keys-list-subtab" aria-label="keys-list-subtab"
title={<TabTitleText>{t("keysList")}</TabTitleText>} title={<TabTitleText>{t("keysList")}</TabTitleText>}
{...keysRoute("list")}
> >
<KeysListTab realmComponents={realmComponents} /> <KeysListTab realmComponents={realmComponents} />
</Tab> </Tab>
@ -327,8 +337,8 @@ export const RealmSettingsTabs = ({
id="providers" id="providers"
data-testid="rs-providers-tab" data-testid="rs-providers-tab"
aria-label="rs-providers-tab" aria-label="rs-providers-tab"
eventKey={1}
title={<TabTitleText>{t("providers")}</TabTitleText>} title={<TabTitleText>{t("providers")}</TabTitleText>}
{...keysRoute("providers")}
> >
<KeysProvidersTab <KeysProvidersTab
realmComponents={realmComponents} realmComponents={realmComponents}
@ -336,25 +346,19 @@ export const RealmSettingsTabs = ({
refresh={refresh} refresh={refresh}
/> />
</Tab> </Tab>
</Tabs> </RoutableTabs>
</Tab> </Tab>
<Tab <Tab
title={<TabTitleText>{t("events")}</TabTitleText>} title={<TabTitleText>{t("events")}</TabTitleText>}
data-testid="rs-realm-events-tab" data-testid="rs-realm-events-tab"
{...routableTab({ {...route("events")}
to: toRealmSettings({ realm: realmName, tab: "events" }),
history,
})}
> >
<EventsTab /> <EventsTab />
</Tab> </Tab>
<Tab <Tab
title={<TabTitleText>{t("localization")}</TabTitleText>} title={<TabTitleText>{t("localization")}</TabTitleText>}
data-testid="rs-localization-tab" data-testid="rs-localization-tab"
{...routableTab({ {...route("localization")}
to: toRealmSettings({ realm: realmName, tab: "localization" }),
history,
})}
> >
<LocalizationTab <LocalizationTab
key={key} key={key}
@ -367,13 +371,7 @@ export const RealmSettingsTabs = ({
<Tab <Tab
title={<TabTitleText>{t("securityDefences")}</TabTitleText>} title={<TabTitleText>{t("securityDefences")}</TabTitleText>}
data-testid="rs-security-defenses-tab" data-testid="rs-security-defenses-tab"
{...routableTab({ {...route("securityDefences")}
to: toRealmSettings({
realm: realmName,
tab: "securityDefences",
}),
history,
})}
> >
<SecurityDefences save={save} reset={() => resetForm(realm)} /> <SecurityDefences save={save} reset={() => resetForm(realm)} />
</Tab> </Tab>
@ -382,26 +380,14 @@ export const RealmSettingsTabs = ({
<TabTitleText>{t("realm-settings:sessions")}</TabTitleText> <TabTitleText>{t("realm-settings:sessions")}</TabTitleText>
} }
data-testid="rs-sessions-tab" data-testid="rs-sessions-tab"
{...routableTab({ {...route("sessions")}
to: toRealmSettings({
realm: realmName,
tab: "sessions",
}),
history,
})}
> >
<RealmSettingsSessionsTab key={key} realm={realm} save={save} /> <RealmSettingsSessionsTab key={key} realm={realm} save={save} />
</Tab> </Tab>
<Tab <Tab
title={<TabTitleText>{t("realm-settings:tokens")}</TabTitleText>} title={<TabTitleText>{t("realm-settings:tokens")}</TabTitleText>}
data-testid="rs-tokens-tab" data-testid="rs-tokens-tab"
{...routableTab({ {...route("tokens")}
to: toRealmSettings({
realm: realmName,
tab: "tokens",
}),
history,
})}
> >
<RealmSettingsTokensTab <RealmSettingsTokensTab
save={save} save={save}
@ -416,13 +402,7 @@ export const RealmSettingsTabs = ({
</TabTitleText> </TabTitleText>
} }
data-testid="rs-clientPolicies-tab" data-testid="rs-clientPolicies-tab"
{...routableTab({ {...route("clientPolicies")}
to: toRealmSettings({
realm: realmName,
tab: "clientPolicies",
}),
history,
})}
> >
<RoutableTabs <RoutableTabs
mountOnEnter mountOnEnter
@ -445,13 +425,7 @@ export const RealmSettingsTabs = ({
</span> </span>
</TabTitleText> </TabTitleText>
} }
{...routableTab({ {...policiesRoute("profiles")}
to: toClientPolicies({
realm: realmName,
tab: "profiles",
}),
history,
})}
> >
<ProfilesTab /> <ProfilesTab />
</Tab> </Tab>
@ -459,13 +433,7 @@ export const RealmSettingsTabs = ({
id="policies" id="policies"
data-testid="rs-policies-clientPolicies-tab" data-testid="rs-policies-clientPolicies-tab"
aria-label={t("clientPoliciesSubTab")} aria-label={t("clientPoliciesSubTab")}
{...routableTab({ {...policiesRoute("policies")}
to: toClientPolicies({
realm: realmName,
tab: "policies",
}),
history,
})}
title={ title={
<TabTitleText> <TabTitleText>
{t("policies")} {t("policies")}
@ -491,13 +459,7 @@ export const RealmSettingsTabs = ({
</TabTitleText> </TabTitleText>
} }
data-testid="rs-user-profile-tab" data-testid="rs-user-profile-tab"
{...routableTab({ {...route("userProfile")}
to: toRealmSettings({
realm: realmName,
tab: "userProfile",
}),
history,
})}
> >
<UserProfileTab /> <UserProfileTab />
</Tab> </Tab>
@ -505,13 +467,7 @@ export const RealmSettingsTabs = ({
<Tab <Tab
title={<TabTitleText>{t("userRegistration")}</TabTitleText>} title={<TabTitleText>{t("userRegistration")}</TabTitleText>}
data-testid="rs-userRegistration-tab" data-testid="rs-userRegistration-tab"
{...routableTab({ {...route("userRegistration")}
to: toRealmSettings({
realm: realmName,
tab: "userRegistration",
}),
history,
})}
> >
<UserRegistration /> <UserRegistration />
</Tab> </Tab>

View file

@ -273,7 +273,6 @@ export default {
addClientProfileError: "Could not create client profile: '{{error}}'", addClientProfileError: "Could not create client profile: '{{error}}'",
createClientProfileNameHelperText: createClientProfileNameHelperText:
"The name must be unique within the realm", "The name must be unique within the realm",
allClientPolicies: "Client policies",
newClientProfile: "Create client profile", newClientProfile: "Create client profile",
newClientProfileName: "Client profile name", newClientProfileName: "Client profile name",
clientProfile: "Client profile details", clientProfile: "Client profile details",

View file

@ -16,9 +16,11 @@ import { EditClientPolicyRoute } from "./routes/EditClientPolicy";
import { NewClientPolicyConditionRoute } from "./routes/AddCondition"; import { NewClientPolicyConditionRoute } from "./routes/AddCondition";
import { EditClientPolicyConditionRoute } from "./routes/EditCondition"; import { EditClientPolicyConditionRoute } from "./routes/EditCondition";
import { UserProfileRoute } from "./routes/UserProfile"; import { UserProfileRoute } from "./routes/UserProfile";
import { KeysRoute } from "./routes/KeysTab";
const routes: RouteDef[] = [ const routes: RouteDef[] = [
RealmSettingsRoute, RealmSettingsRoute,
KeysRoute,
AesGeneratedSettingsRoute, AesGeneratedSettingsRoute,
EcdsaGeneratedSettingsRoute, EcdsaGeneratedSettingsRoute,
HmacGeneratedSettingsRoute, HmacGeneratedSettingsRoute,

View file

@ -2,14 +2,13 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { NewPolicyCrumb } from "../RealmSettingsSection";
export type AddClientPolicyParams = { realm: string }; export type AddClientPolicyParams = { realm: string };
export const AddClientPolicyRoute: RouteDef = { export const AddClientPolicyRoute: RouteDef = {
path: "/:realm/realm-settings/clientPolicies/policies/add-client-policy", path: "/:realm/realm-settings/clientPolicies/policies/add-client-policy",
component: lazy(() => import("../NewClientPolicyForm")), component: lazy(() => import("../NewClientPolicyForm")),
breadcrumb: () => NewPolicyCrumb, breadcrumb: (t) => t("realm-settings:createPolicy"),
access: "manage-clients", access: "manage-clients",
}; };

View file

@ -2,24 +2,23 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProviderCrumb } from "../RealmSettingsSection";
export type AesGeneratedSettingsParams = { export type KeyProviderParams = {
realm: string; realm: string;
id: string; id: string;
}; };
export const AesGeneratedSettingsRoute: RouteDef = { export const AesGeneratedSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:id/aes-generated/settings", path: "/:realm/realm-settings/keys/providers/:id/aes-generated/settings",
component: lazy( component: lazy(
() => import("../key-providers/aes-generated/AESGeneratedForm") () => import("../key-providers/aes-generated/AESGeneratedForm")
), ),
breadcrumb: () => EditProviderCrumb, breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", access: "view-realm",
}; };
export const toAesGeneratedSettings = ( export const toAesGeneratedSettings = (
params: AesGeneratedSettingsParams params: KeyProviderParams
): LocationDescriptorObject => ({ ): LocationDescriptorObject => ({
pathname: generatePath(AesGeneratedSettingsRoute.path, params), pathname: generatePath(AesGeneratedSettingsRoute.path, params),
}); });

View file

@ -3,17 +3,17 @@ import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
export type UserProfileTab = "profiles" | "policies"; export type ClientPoliciesTab = "profiles" | "policies";
export type ClientPoliciesParams = { export type ClientPoliciesParams = {
realm: string; realm: string;
tab: string; tab: ClientPoliciesTab;
}; };
export const ClientPoliciesRoute: RouteDef = { export const ClientPoliciesRoute: RouteDef = {
path: "/:realm/realm-settings/clientPolicies/:tab", path: "/:realm/realm-settings/clientPolicies/:tab",
component: lazy(() => import("../ProfilesTab")), component: lazy(() => import("../RealmSettingsSection")),
breadcrumb: (t) => t("realm-settings:allClientPolicies"), breadcrumb: (t) => t("realm-settings:clientPolicies"),
access: "view-realm", access: "view-realm",
}; };

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProfileCrumb } from "../RealmSettingsSection";
export type ClientProfileParams = { export type ClientProfileParams = {
realm: string; realm: string;
@ -12,7 +11,7 @@ export type ClientProfileParams = {
export const ClientProfileRoute: RouteDef = { export const ClientProfileRoute: RouteDef = {
path: "/:realm/realm-settings/clientPolicies/:profileName/edit-profile", path: "/:realm/realm-settings/clientPolicies/:profileName/edit-profile",
component: lazy(() => import("../ClientProfileForm")), component: lazy(() => import("../ClientProfileForm")),
breadcrumb: () => EditProfileCrumb, breadcrumb: (t) => t("realm-settings:clientProfile"),
access: ["view-realm", "view-users"], access: ["view-realm", "view-users"],
}; };

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProviderCrumb } from "../RealmSettingsSection";
export type EcdsaGeneratedSettingsParams = { export type EcdsaGeneratedSettingsParams = {
realm: string; realm: string;
@ -10,11 +9,11 @@ export type EcdsaGeneratedSettingsParams = {
}; };
export const EcdsaGeneratedSettingsRoute: RouteDef = { export const EcdsaGeneratedSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:id/ecdsa-generated/settings", path: "/:realm/realm-settings/keys/providers/:id/ecdsa-generated/settings",
component: lazy( component: lazy(
() => import("../key-providers/ecdsa-generated/ECDSAGeneratedForm") () => import("../key-providers/ecdsa-generated/ECDSAGeneratedForm")
), ),
breadcrumb: () => EditProviderCrumb, breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", access: "view-realm",
}; };

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditPolicyCrumb } from "../RealmSettingsSection";
export type EditClientPolicyParams = { export type EditClientPolicyParams = {
realm: string; realm: string;
@ -13,7 +12,7 @@ export const EditClientPolicyRoute: RouteDef = {
path: "/:realm/realm-settings/clientPolicies/:policyName/edit-policy", path: "/:realm/realm-settings/clientPolicies/:policyName/edit-policy",
component: lazy(() => import("../NewClientPolicyForm")), component: lazy(() => import("../NewClientPolicyForm")),
access: "manage-realm", access: "manage-realm",
breadcrumb: () => EditPolicyCrumb, breadcrumb: (t) => t("realm-settings:policyDetails"),
}; };
export const toEditClientPolicy = ( export const toEditClientPolicy = (

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditExecutorCrumb } from "../RealmSettingsSection";
export type ExecutorParams = { export type ExecutorParams = {
realm: string; realm: string;
@ -13,7 +12,7 @@ export type ExecutorParams = {
export const ExecutorRoute: RouteDef = { export const ExecutorRoute: RouteDef = {
path: "/:realm/realm-settings/clientPolicies/:profileName/edit-profile/:executorName", path: "/:realm/realm-settings/clientPolicies/:profileName/edit-profile/:executorName",
component: lazy(() => import("../ExecutorForm")), component: lazy(() => import("../ExecutorForm")),
breadcrumb: () => EditExecutorCrumb, breadcrumb: (t) => t("realm-settings:executorDetails"),
access: ["manage-realm"], access: ["manage-realm"],
}; };

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProviderCrumb } from "../RealmSettingsSection";
export type HmacGeneratedSettingsParams = { export type HmacGeneratedSettingsParams = {
realm: string; realm: string;
@ -10,11 +9,11 @@ export type HmacGeneratedSettingsParams = {
}; };
export const HmacGeneratedSettingsRoute: RouteDef = { export const HmacGeneratedSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:id/hmac-generated/settings", path: "/:realm/realm-settings/keys/providers/:id/hmac-generated/settings",
component: lazy( component: lazy(
() => import("../key-providers/hmac-generated/HMACGeneratedForm") () => import("../key-providers/hmac-generated/HMACGeneratedForm")
), ),
breadcrumb: () => EditProviderCrumb, breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", access: "view-realm",
}; };

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProviderCrumb } from "../RealmSettingsSection";
export type JavaKeystoreSettingsParams = { export type JavaKeystoreSettingsParams = {
realm: string; realm: string;
@ -10,11 +9,11 @@ export type JavaKeystoreSettingsParams = {
}; };
export const JavaKeystoreSettingsRoute: RouteDef = { export const JavaKeystoreSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:id/java-keystore/settings", path: "/:realm/realm-settings/keys/providers/:id/java-keystore/settings",
component: lazy( component: lazy(
() => import("../key-providers/java-keystore/JavaKeystoreForm") () => import("../key-providers/java-keystore/JavaKeystoreForm")
), ),
breadcrumb: () => EditProviderCrumb, breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", access: "view-realm",
}; };

View file

@ -0,0 +1,22 @@
import type { LocationDescriptorObject } from "history";
import { lazy } from "react";
import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config";
export type KeySubTab = "list" | "providers";
export type KeysParams = {
realm: string;
tab: KeySubTab;
};
export const KeysRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:tab",
component: lazy(() => import("../RealmSettingsSection")),
breadcrumb: (t) => t("realm-settings:keys"),
access: "view-realm",
};
export const toKeysTab = (params: KeysParams): LocationDescriptorObject => ({
pathname: generatePath(KeysRoute.path, params),
});

View file

@ -21,11 +21,10 @@ export type RealmSettingsTab =
export type RealmSettingsParams = { export type RealmSettingsParams = {
realm: string; realm: string;
tab?: RealmSettingsTab; tab?: RealmSettingsTab;
subTab?: string;
}; };
export const RealmSettingsRoute: RouteDef = { export const RealmSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/:tab?/:subTab?", path: "/:realm/realm-settings/:tab?",
component: lazy(() => import("../RealmSettingsSection")), component: lazy(() => import("../RealmSettingsSection")),
breadcrumb: (t) => t("realmSettings"), breadcrumb: (t) => t("realmSettings"),
access: "view-realm", access: "view-realm",

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProviderCrumb } from "../RealmSettingsSection";
export type RsaGeneratedSettingsParams = { export type RsaGeneratedSettingsParams = {
realm: string; realm: string;
@ -10,11 +9,11 @@ export type RsaGeneratedSettingsParams = {
}; };
export const RsaGeneratedSettingsRoute: RouteDef = { export const RsaGeneratedSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:id/rsa-generated/settings", path: "/:realm/realm-settings/keys/providers/:id/rsa-generated/settings",
component: lazy( component: lazy(
() => import("../key-providers/rsa-generated/RSAGeneratedForm") () => import("../key-providers/rsa-generated/RSAGeneratedForm")
), ),
breadcrumb: () => EditProviderCrumb, breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", access: "view-realm",
}; };

View file

@ -2,7 +2,6 @@ import type { LocationDescriptorObject } from "history";
import { lazy } from "react"; import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
import { EditProviderCrumb } from "../RealmSettingsSection";
export type RsaSettingsParams = { export type RsaSettingsParams = {
realm: string; realm: string;
@ -10,9 +9,9 @@ export type RsaSettingsParams = {
}; };
export const RsaSettingsRoute: RouteDef = { export const RsaSettingsRoute: RouteDef = {
path: "/:realm/realm-settings/keys/:id/rsa/settings", path: "/:realm/realm-settings/keys/providers/:id/rsa/settings",
component: lazy(() => import("../key-providers/rsa/RSAForm")), component: lazy(() => import("../key-providers/rsa/RSAForm")),
breadcrumb: () => EditProviderCrumb, breadcrumb: (t) => t("realm-settings:editProvider"),
access: "view-realm", access: "view-realm",
}; };