Use React Router v6 for the routable tabs of authentication page (#4118)
This commit is contained in:
parent
1155371439
commit
48a3fc9229
1 changed files with 11 additions and 12 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useHistory } from "react-router-dom";
|
|
||||||
import { Link } from "react-router-dom-v5-compat";
|
import { Link } from "react-router-dom-v5-compat";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import { sortBy } from "lodash-es";
|
import { sortBy } from "lodash-es";
|
||||||
|
@ -32,8 +31,8 @@ import helpUrls from "../help-urls";
|
||||||
import { BindFlowDialog } from "./BindFlowDialog";
|
import { BindFlowDialog } from "./BindFlowDialog";
|
||||||
import { UsedBy } from "./components/UsedBy";
|
import { UsedBy } from "./components/UsedBy";
|
||||||
import {
|
import {
|
||||||
routableTab,
|
|
||||||
RoutableTabs,
|
RoutableTabs,
|
||||||
|
useRoutableTab,
|
||||||
} from "../components/routable-tabs/RoutableTabs";
|
} from "../components/routable-tabs/RoutableTabs";
|
||||||
import { AuthenticationTab, toAuthentication } from "./routes/Authentication";
|
import { AuthenticationTab, toAuthentication } from "./routes/Authentication";
|
||||||
import { addTrailingSlash } from "../util";
|
import { addTrailingSlash } from "../util";
|
||||||
|
@ -61,7 +60,6 @@ export default function AuthenticationSection() {
|
||||||
const { t } = useTranslation("authentication");
|
const { t } = useTranslation("authentication");
|
||||||
const { adminClient } = useAdminClient();
|
const { adminClient } = useAdminClient();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const history = useHistory();
|
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
const refresh = () => setKey(key + 1);
|
const refresh = () => setKey(key + 1);
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
|
@ -92,6 +90,13 @@ export default function AuthenticationSection() {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const useTab = (tab: AuthenticationTab) =>
|
||||||
|
useRoutableTab(toAuthentication({ realm, tab }));
|
||||||
|
|
||||||
|
const flowsTab = useTab("flows");
|
||||||
|
const requiredActionsTab = useTab("required-actions");
|
||||||
|
const policiesTab = useTab("policies");
|
||||||
|
|
||||||
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
||||||
titleKey: "authentication:deleteConfirmFlow",
|
titleKey: "authentication:deleteConfirmFlow",
|
||||||
children: (
|
children: (
|
||||||
|
@ -141,12 +146,6 @@ export default function AuthenticationSection() {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const route = (tab: AuthenticationTab) =>
|
|
||||||
routableTab({
|
|
||||||
to: toAuthentication({ realm, tab }),
|
|
||||||
history,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DeleteConfirm />
|
<DeleteConfirm />
|
||||||
|
@ -184,7 +183,7 @@ export default function AuthenticationSection() {
|
||||||
<Tab
|
<Tab
|
||||||
data-testid="flows"
|
data-testid="flows"
|
||||||
title={<TabTitleText>{t("flows")}</TabTitleText>}
|
title={<TabTitleText>{t("flows")}</TabTitleText>}
|
||||||
{...route("flows")}
|
{...flowsTab}
|
||||||
>
|
>
|
||||||
<KeycloakDataTable
|
<KeycloakDataTable
|
||||||
key={key}
|
key={key}
|
||||||
|
@ -260,14 +259,14 @@ export default function AuthenticationSection() {
|
||||||
<Tab
|
<Tab
|
||||||
data-testid="requiredActions"
|
data-testid="requiredActions"
|
||||||
title={<TabTitleText>{t("requiredActions")}</TabTitleText>}
|
title={<TabTitleText>{t("requiredActions")}</TabTitleText>}
|
||||||
{...route("required-actions")}
|
{...requiredActionsTab}
|
||||||
>
|
>
|
||||||
<RequiredActions />
|
<RequiredActions />
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab
|
<Tab
|
||||||
data-testid="policies"
|
data-testid="policies"
|
||||||
title={<TabTitleText>{t("policies")}</TabTitleText>}
|
title={<TabTitleText>{t("policies")}</TabTitleText>}
|
||||||
{...route("policies")}
|
{...policiesTab}
|
||||||
>
|
>
|
||||||
<Policies />
|
<Policies />
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
Loading…
Reference in a new issue