2023-04-18 16:50:46 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-05-15 15:18:45 +00:00
|
|
|
import { PageSection, Tab, TabTitleText } from "@patternfly/react-core";
|
2022-09-16 11:17:37 +00:00
|
|
|
|
2023-05-15 15:18:45 +00:00
|
|
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
|
|
|
import { useRealm } from "../context/realm-context/RealmContext";
|
|
|
|
import helpUrls from "../help-urls";
|
2023-04-11 11:28:24 +00:00
|
|
|
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
|
2023-05-15 15:18:45 +00:00
|
|
|
import { UserDataTable } from "../components/users/UserDataTable";
|
|
|
|
import { toUsers, UserTab } from "./routes/Users";
|
2023-04-11 11:28:24 +00:00
|
|
|
import {
|
|
|
|
RoutableTabs,
|
|
|
|
useRoutableTab,
|
|
|
|
} from "../components/routable-tabs/RoutableTabs";
|
2023-04-18 16:50:46 +00:00
|
|
|
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
|
2021-11-18 16:45:56 +00:00
|
|
|
import "./user-section.css";
|
|
|
|
|
2021-10-29 16:11:06 +00:00
|
|
|
export default function UsersSection() {
|
2020-12-09 21:55:17 +00:00
|
|
|
const { t } = useTranslation("users");
|
2021-07-21 09:30:18 +00:00
|
|
|
const { realm: realmName } = useRealm();
|
2023-04-18 16:50:46 +00:00
|
|
|
const isFeatureEnabled = useIsFeatureEnabled();
|
2020-12-16 06:58:00 +00:00
|
|
|
|
2023-01-05 14:10:37 +00:00
|
|
|
const useTab = (tab: UserTab) =>
|
|
|
|
useRoutableTab(
|
|
|
|
toUsers({
|
|
|
|
realm: realmName,
|
|
|
|
tab,
|
2023-07-11 14:03:21 +00:00
|
|
|
}),
|
2023-01-05 14:10:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const listTab = useTab("list");
|
|
|
|
const permissionsTab = useTab("permissions");
|
|
|
|
|
2020-09-18 08:04:55 +00:00
|
|
|
return (
|
|
|
|
<>
|
2021-12-21 15:32:53 +00:00
|
|
|
<ViewHeader
|
|
|
|
titleKey="users:title"
|
|
|
|
subKey="users:usersExplain"
|
|
|
|
helpUrl={helpUrls.usersUrl}
|
2022-04-26 10:11:17 +00:00
|
|
|
divider={false}
|
2021-12-21 15:32:53 +00:00
|
|
|
/>
|
2021-03-31 13:16:58 +00:00
|
|
|
<PageSection
|
|
|
|
data-testid="users-page"
|
|
|
|
variant="light"
|
|
|
|
className="pf-u-p-0"
|
|
|
|
>
|
2022-04-26 10:11:17 +00:00
|
|
|
<RoutableTabs
|
|
|
|
data-testid="user-tabs"
|
|
|
|
defaultLocation={toUsers({
|
|
|
|
realm: realmName,
|
|
|
|
tab: "list",
|
|
|
|
})}
|
|
|
|
isBox
|
|
|
|
mountOnEnter
|
|
|
|
>
|
|
|
|
<Tab
|
|
|
|
id="list"
|
|
|
|
data-testid="listTab"
|
|
|
|
title={<TabTitleText>{t("userList")}</TabTitleText>}
|
2023-01-05 14:10:37 +00:00
|
|
|
{...listTab}
|
2022-04-26 10:11:17 +00:00
|
|
|
>
|
2023-05-15 15:18:45 +00:00
|
|
|
<UserDataTable />
|
2022-04-26 10:11:17 +00:00
|
|
|
</Tab>
|
2023-04-18 16:50:46 +00:00
|
|
|
{isFeatureEnabled(Feature.AdminFineGrainedAuthz) && (
|
2022-11-17 10:18:52 +00:00
|
|
|
<Tab
|
|
|
|
id="permissions"
|
|
|
|
data-testid="permissionsTab"
|
|
|
|
title={<TabTitleText>{t("common:permissions")}</TabTitleText>}
|
2023-01-05 14:10:37 +00:00
|
|
|
{...permissionsTab}
|
2022-11-17 10:18:52 +00:00
|
|
|
>
|
|
|
|
<PermissionsTab type="users" />
|
|
|
|
</Tab>
|
|
|
|
)}
|
2022-04-26 10:11:17 +00:00
|
|
|
</RoutableTabs>
|
2020-12-09 21:55:17 +00:00
|
|
|
</PageSection>
|
2020-09-18 08:04:55 +00:00
|
|
|
</>
|
|
|
|
);
|
2021-10-29 16:11:06 +00:00
|
|
|
}
|