2022-02-07 11:49:47 +00:00
|
|
|
import { Tab, TabTitleText } from "@patternfly/react-core";
|
2022-08-03 12:12:07 +00:00
|
|
|
|
2022-01-03 15:00:03 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2022-01-19 09:41:52 +00:00
|
|
|
import {
|
|
|
|
RoutableTabs,
|
2023-01-06 13:30:17 +00:00
|
|
|
useRoutableTab,
|
2022-01-19 09:41:52 +00:00
|
|
|
} from "../../components/routable-tabs/RoutableTabs";
|
2022-01-03 15:00:03 +00:00
|
|
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
2023-01-06 13:30:17 +00:00
|
|
|
import {
|
|
|
|
toUserProfile,
|
|
|
|
UserProfileTab as IUserProfileTab,
|
|
|
|
} from "../routes/UserProfile";
|
2022-01-07 12:56:27 +00:00
|
|
|
import { AttributesGroupTab } from "./AttributesGroupTab";
|
2022-02-16 11:39:08 +00:00
|
|
|
import { AttributesTab } from "./AttributesTab";
|
2022-01-03 15:00:03 +00:00
|
|
|
import { JsonEditorTab } from "./JsonEditorTab";
|
2022-02-07 11:49:47 +00:00
|
|
|
import { UserProfileProvider } from "./UserProfileContext";
|
2022-01-07 12:56:27 +00:00
|
|
|
|
2022-01-03 15:00:03 +00:00
|
|
|
export const UserProfileTab = () => {
|
|
|
|
const { realm } = useRealm();
|
|
|
|
const { t } = useTranslation("realm-settings");
|
2023-01-06 13:30:17 +00:00
|
|
|
|
|
|
|
const useTab = (tab: IUserProfileTab) =>
|
|
|
|
useRoutableTab(toUserProfile({ realm, tab }));
|
|
|
|
|
|
|
|
const attributesTab = useTab("attributes");
|
|
|
|
const attributesGroupTab = useTab("attributes-group");
|
|
|
|
const jsonEditorTab = useTab("json-editor");
|
2022-01-03 15:00:03 +00:00
|
|
|
|
|
|
|
return (
|
2022-02-07 11:49:47 +00:00
|
|
|
<UserProfileProvider>
|
|
|
|
<RoutableTabs
|
|
|
|
defaultLocation={toUserProfile({ realm, tab: "attributes" })}
|
|
|
|
mountOnEnter
|
2022-01-03 15:00:03 +00:00
|
|
|
>
|
2022-02-07 11:49:47 +00:00
|
|
|
<Tab
|
|
|
|
title={<TabTitleText>{t("attributes")}</TabTitleText>}
|
2022-02-16 11:39:08 +00:00
|
|
|
data-testid="attributesTab"
|
2023-01-06 13:30:17 +00:00
|
|
|
{...attributesTab}
|
2022-02-16 11:39:08 +00:00
|
|
|
>
|
|
|
|
<AttributesTab />
|
|
|
|
</Tab>
|
2022-02-07 11:49:47 +00:00
|
|
|
<Tab
|
|
|
|
title={<TabTitleText>{t("attributesGroup")}</TabTitleText>}
|
|
|
|
data-testid="attributesGroupTab"
|
2023-01-06 13:30:17 +00:00
|
|
|
{...attributesGroupTab}
|
2022-02-07 11:49:47 +00:00
|
|
|
>
|
|
|
|
<AttributesGroupTab />
|
|
|
|
</Tab>
|
|
|
|
<Tab
|
|
|
|
title={<TabTitleText>{t("jsonEditor")}</TabTitleText>}
|
2022-02-16 11:39:08 +00:00
|
|
|
data-testid="jsonEditorTab"
|
2023-01-06 13:30:17 +00:00
|
|
|
{...jsonEditorTab}
|
2022-02-07 11:49:47 +00:00
|
|
|
>
|
|
|
|
<JsonEditorTab />
|
|
|
|
</Tab>
|
|
|
|
</RoutableTabs>
|
|
|
|
</UserProfileProvider>
|
2022-01-03 15:00:03 +00:00
|
|
|
);
|
|
|
|
};
|