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",
|
"signOutAllActiveSessions": "Sign out all active sessions",
|
||||||
"signOutAllActiveSessionsQuestion": "Sign out all active sessions?",
|
"signOutAllActiveSessionsQuestion": "Sign out all active sessions?",
|
||||||
"setToNow": "Set to now",
|
"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.",
|
"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}}.",
|
"logoutAllSessionsError": "Error! Failed to log out of all sessions: {{error}}.",
|
||||||
"setToNowError": "Error! Failed to set notBefore to current date and time.",
|
"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 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 { CubesIcon } from "@patternfly/react-icons";
|
||||||
import React, { useMemo, useState } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -24,12 +30,14 @@ export type SessionsTableProps = {
|
||||||
loader: LoaderFunction<UserSessionRepresentation>;
|
loader: LoaderFunction<UserSessionRepresentation>;
|
||||||
hiddenColumns?: ColumnName[];
|
hiddenColumns?: ColumnName[];
|
||||||
emptyInstructions?: string;
|
emptyInstructions?: string;
|
||||||
|
logoutUser?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function SessionsTable({
|
export default function SessionsTable({
|
||||||
loader,
|
loader,
|
||||||
hiddenColumns = [],
|
hiddenColumns = [],
|
||||||
emptyInstructions,
|
emptyInstructions,
|
||||||
|
logoutUser,
|
||||||
}: SessionsTableProps) {
|
}: SessionsTableProps) {
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { whoAmI } = useWhoAmI();
|
const { whoAmI } = useWhoAmI();
|
||||||
|
@ -106,6 +114,20 @@ export default function SessionsTable({
|
||||||
loader={loader}
|
loader={loader}
|
||||||
ariaLabelKey="sessions:title"
|
ariaLabelKey="sessions:title"
|
||||||
searchPlaceholderKey="sessions:searchForSession"
|
searchPlaceholderKey="sessions:searchForSession"
|
||||||
|
toolbarItem={
|
||||||
|
logoutUser && (
|
||||||
|
<ToolbarItem>
|
||||||
|
<Button
|
||||||
|
onClick={async () => {
|
||||||
|
await adminClient.users.logout({ id: logoutUser });
|
||||||
|
refresh();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("logoutAllSessions")}
|
||||||
|
</Button>
|
||||||
|
</ToolbarItem>
|
||||||
|
)
|
||||||
|
}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ export const UserSessions = () => {
|
||||||
loader={loader}
|
loader={loader}
|
||||||
hiddenColumns={["username"]}
|
hiddenColumns={["username"]}
|
||||||
emptyInstructions={t("noSessionsForUser")}
|
emptyInstructions={t("noSessionsForUser")}
|
||||||
|
logoutUser={id}
|
||||||
/>
|
/>
|
||||||
</PageSection>
|
</PageSection>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue