Use React Router v6 for the routable tabs of the realm settings keys page (#4129)
This commit is contained in:
parent
d2163efe3f
commit
0b7ab7d008
1 changed files with 9 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useHistory } from "react-router-dom";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Tab, TabTitleText } from "@patternfly/react-core";
|
import { Tab, TabTitleText } from "@patternfly/react-core";
|
||||||
|
|
||||||
|
@ -8,8 +7,8 @@ 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 {
|
import {
|
||||||
routableTab,
|
|
||||||
RoutableTabs,
|
RoutableTabs,
|
||||||
|
useRoutableTab,
|
||||||
} from "../../components/routable-tabs/RoutableTabs";
|
} from "../../components/routable-tabs/RoutableTabs";
|
||||||
import { KeySubTab, toKeysTab } from "../routes/KeysTab";
|
import { KeySubTab, toKeysTab } from "../routes/KeysTab";
|
||||||
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
|
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
|
||||||
|
@ -31,7 +30,6 @@ const sortByPriority = (components: ComponentRepresentation[]) => {
|
||||||
|
|
||||||
export const KeysTab = () => {
|
export const KeysTab = () => {
|
||||||
const { t } = useTranslation("realm-settings");
|
const { t } = useTranslation("realm-settings");
|
||||||
const history = useHistory();
|
|
||||||
|
|
||||||
const { adminClient } = useAdminClient();
|
const { adminClient } = useAdminClient();
|
||||||
const { realm: realmName } = useRealm();
|
const { realm: realmName } = useRealm();
|
||||||
|
@ -53,16 +51,16 @@ export const KeysTab = () => {
|
||||||
[key]
|
[key]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const useTab = (tab: KeySubTab) =>
|
||||||
|
useRoutableTab(toKeysTab({ realm: realmName, tab }));
|
||||||
|
|
||||||
|
const listTab = useTab("list");
|
||||||
|
const providersTab = useTab("providers");
|
||||||
|
|
||||||
if (!realmComponents) {
|
if (!realmComponents) {
|
||||||
return <KeycloakSpinner />;
|
return <KeycloakSpinner />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const keysRoute = (tab: KeySubTab) =>
|
|
||||||
routableTab({
|
|
||||||
to: toKeysTab({ realm: realmName, tab }),
|
|
||||||
history,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RoutableTabs
|
<RoutableTabs
|
||||||
mountOnEnter
|
mountOnEnter
|
||||||
|
@ -74,7 +72,7 @@ export const KeysTab = () => {
|
||||||
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")}
|
{...listTab}
|
||||||
>
|
>
|
||||||
<KeysListTab realmComponents={realmComponents} />
|
<KeysListTab realmComponents={realmComponents} />
|
||||||
</Tab>
|
</Tab>
|
||||||
|
@ -83,7 +81,7 @@ export const KeysTab = () => {
|
||||||
data-testid="rs-providers-tab"
|
data-testid="rs-providers-tab"
|
||||||
aria-label="rs-providers-tab"
|
aria-label="rs-providers-tab"
|
||||||
title={<TabTitleText>{t("providers")}</TabTitleText>}
|
title={<TabTitleText>{t("providers")}</TabTitleText>}
|
||||||
{...keysRoute("providers")}
|
{...providersTab}
|
||||||
>
|
>
|
||||||
<KeysProvidersTab realmComponents={realmComponents} refresh={refresh} />
|
<KeysProvidersTab realmComponents={realmComponents} refresh={refresh} />
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
Loading…
Reference in a new issue