Added logout all sessions to user session tab (#2696)
This commit is contained in:
parent
1fa1e0dc46
commit
422c271da3
3 changed files with 25 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
|||
"signOutAllActiveSessions": "Sign out all active sessions",
|
||||
"signOutAllActiveSessionsQuestion": "Sign out all active sessions?",
|
||||
"setToNow": "Set to now",
|
||||
"logoutAllSessions": "Logout all sessions",
|
||||
"logoutAllDescription": "If you sign out all active sessions, active subjects in this realm will be signed out.",
|
||||
"logoutAllSessionsError": "Error! Failed to log out of all sessions: {{error}}.",
|
||||
"setToNowError": "Error! Failed to set notBefore to current date and time.",
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import type UserSessionRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userSessionRepresentation";
|
||||
import { List, ListItem, ListVariant } from "@patternfly/react-core";
|
||||
import {
|
||||
Button,
|
||||
List,
|
||||
ListItem,
|
||||
ListVariant,
|
||||
ToolbarItem,
|
||||
} from "@patternfly/react-core";
|
||||
import { CubesIcon } from "@patternfly/react-icons";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
@ -24,12 +30,14 @@ export type SessionsTableProps = {
|
|||
loader: LoaderFunction<UserSessionRepresentation>;
|
||||
hiddenColumns?: ColumnName[];
|
||||
emptyInstructions?: string;
|
||||
logoutUser?: string;
|
||||
};
|
||||
|
||||
export default function SessionsTable({
|
||||
loader,
|
||||
hiddenColumns = [],
|
||||
emptyInstructions,
|
||||
logoutUser,
|
||||
}: SessionsTableProps) {
|
||||
const { realm } = useRealm();
|
||||
const { whoAmI } = useWhoAmI();
|
||||
|
@ -106,6 +114,20 @@ export default function SessionsTable({
|
|||
loader={loader}
|
||||
ariaLabelKey="sessions:title"
|
||||
searchPlaceholderKey="sessions:searchForSession"
|
||||
toolbarItem={
|
||||
logoutUser && (
|
||||
<ToolbarItem>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await adminClient.users.logout({ id: logoutUser });
|
||||
refresh();
|
||||
}}
|
||||
>
|
||||
{t("logoutAllSessions")}
|
||||
</Button>
|
||||
</ToolbarItem>
|
||||
)
|
||||
}
|
||||
columns={columns}
|
||||
actions={[
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@ export const UserSessions = () => {
|
|||
loader={loader}
|
||||
hiddenColumns={["username"]}
|
||||
emptyInstructions={t("noSessionsForUser")}
|
||||
logoutUser={id}
|
||||
/>
|
||||
</PageSection>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue