All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.SessionsTable-7Bmc2htq.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"SessionsTable-7Bmc2htq.js","sources":["../../../../../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@patternfly/react-icons/dist/esm/icons/cubes-icon.js","../../src/user/utils.ts","../../src/sessions/SessionsTable.tsx"],"sourcesContent":["import { createIcon } from '../createIcon';\n\nexport const CubesIconConfig = {\n  name: 'CubesIcon',\n  height: 512,\n  width: 512,\n  svgPath: 'M488.6 250.2L392 214V105.5c0-15-9.3-28.4-23.4-33.7l-100-37.5c-8.1-3.1-17.1-3.1-25.3 0l-100 37.5c-14.1 5.3-23.4 18.7-23.4 33.7V214l-96.6 36.2C9.3 255.5 0 268.9 0 283.9V394c0 13.6 7.7 26.1 19.9 32.2l100 50c10.1 5.1 22.1 5.1 32.2 0l103.9-52 103.9 52c10.1 5.1 22.1 5.1 32.2 0l100-50c12.2-6.1 19.9-18.6 19.9-32.2V283.9c0-15-9.3-28.4-23.4-33.7zM358 214.8l-85 31.9v-68.2l85-37v73.3zM154 104.1l102-38.2 102 38.2v.6l-102 41.4-102-41.4v-.6zm84 291.1l-85 42.5v-79.1l85-38.8v75.4zm0-112l-102 41.4-102-41.4v-.6l102-38.2 102 38.2v.6zm240 112l-85 42.5v-79.1l85-38.8v75.4zm0-112l-102 41.4-102-41.4v-.6l102-38.2 102 38.2v.6z',\n  yOffset: 0,\n  xOffset: 0,\n};\n\nexport const CubesIcon = createIcon(CubesIconConfig);\n\nexport default CubesIcon;","export const isLightweightUser = (userId?: string) =>\n  userId?.startsWith(\"lightweight-\");\n","import type UserSessionRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/userSessionRepresentation\";\nimport { useEnvironment } from \"@keycloak/keycloak-ui-shared\";\nimport {\n  Button,\n  Label,\n  List,\n  ListItem,\n  ListVariant,\n  ToolbarItem,\n  Tooltip,\n} from \"@patternfly/react-core\";\nimport { CubesIcon, InfoCircleIcon } from \"@patternfly/react-icons\";\nimport { IRowData } from \"@patternfly/react-table\";\nimport { ReactNode, useMemo, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link, useMatch, useNavigate } from \"react-router-dom\";\nimport { useAdminClient } from \"../admin-client\";\nimport { toClient } from \"../clients/routes/Client\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { useConfirmDialog } from \"../components/confirm-dialog/ConfirmDialog\";\nimport { ListEmptyState } from \"../components/list-empty-state/ListEmptyState\";\nimport {\n  Action,\n  Field,\n  KeycloakDataTable,\n  LoaderFunction,\n} from \"../components/table-toolbar/KeycloakDataTable\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport { useWhoAmI } from \"../context/whoami/WhoAmI\";\nimport { UserRoute, toUser } from \"../user/routes/User\";\nimport { toUsers } from \"../user/routes/Users\";\nimport { isLightweightUser } from \"../user/utils\";\nimport useFormatDate from \"../utils/useFormatDate\";\n\nexport type ColumnName =\n  | \"username\"\n  | \"start\"\n  | \"lastAccess\"\n  | \"clients\"\n  | \"type\";\n\nexport type SessionsTableProps = {\n  loader: LoaderFunction;\n  hiddenColumns?: ColumnName[];\n  emptyInstructions?: string;\n  logoutUser?: string;\n  filter?: ReactNode;\n  isSearching?: boolean;\n  isPaginated?: boolean;\n};\n\nconst UsernameCell = (row: UserSessionRepresentation) => {\n  const { realm } = useRealm();\n  const { t } = useTranslation();\n  return (\n    \n      {row.username}\n      {row.transientUser && (\n        <>\n          {\" \"}\n          \n            }\n              isCompact\n            >\n              {t(\"transientUser\")}\n            \n          \n        \n      )}\n    \n  );\n};\n\nconst ClientsCell = (row: UserSessionRepresentation) => {\n  const { realm } = useRealm();\n  return (\n    \n      {Object.entries(row.clients!).map(([clientId, client]) => (\n        \n          \n            {client}\n          \n        \n      ))}\n    \n  );\n};\n\nexport default function SessionsTable({\n  loader,\n  hiddenColumns = [],\n  emptyInstructions,\n  logoutUser,\n  filter,\n  isSearching,\n  isPaginated,\n}: SessionsTableProps) {\n  const { keycloak } = useEnvironment();\n  const { adminClient } = useAdminClient();\n\n  const { realm } = useRealm();\n  const { whoAmI } = useWhoAmI();\n  const navigate = useNavigate();\n  const { t } = useTranslation();\n  const { addError } = useAlerts();\n  const formatDate = useFormatDate();\n  const [key, setKey] = useState(0);\n  const refresh = () => setKey((value) => value + 1);\n  const isOnUserPage = !!useMatch(UserRoute.path);\n\n  const columns = useMemo(() => {\n    const defaultColumns: Field[] = [\n      {\n        name: \"username\",\n        displayKey: \"user\",\n        cellRenderer: UsernameCell,\n      },\n      {\n        name: \"type\",\n        displayKey: \"type\",\n      },\n      {\n        name: \"start\",\n        displayKey: \"started\",\n        cellRenderer: (row) => formatDate(new Date(row.start!)),\n      },\n      {\n        name: \"lastAccess\",\n        displayKey: \"lastAccess\",\n        cellRenderer: (row) => formatDate(new Date(row.lastAccess!)),\n      },\n      {\n        name: \"ipAddress\",\n        displayKey: \"ipAddress\",\n      },\n      {\n        name: \"clients\",\n        displayKey: \"clients\",\n        cellRenderer: ClientsCell,\n      },\n    ];\n\n    return defaultColumns.filter(\n      ({ name }) => !hiddenColumns.includes(name as ColumnName),\n    );\n  }, [realm, hiddenColumns]);\n\n  const [toggleLogoutDialog, LogoutConfirm] = useConfirmDialog({\n    titleKey: \"logoutAllSessions\",\n    messageKey: \"logoutAllDescription\",\n    continueButtonLabel: \"confirm\",\n    onConfirm: async () => {\n      try {\n        await adminClient.users.logout({ id: logoutUser! });\n        if (isOnUserPage && isLightweightUser(logoutUser)) {\n          navigate(toUsers({ realm: realm }));\n        } else {\n          refresh();\n        }\n      } catch (error) {\n        addError(\"logoutAllSessionsError\", error);\n      }\n    },\n  });\n\n  async function onClickRevoke(rowData: IRowData) {\n    const session = rowData.data as UserSessionRepresentation;\n    await adminClient.realms.deleteSession({\n      realm,\n      session: session.id!,\n      isOffline: true,\n    });\n\n    refresh();\n  }\n\n  async function onClickSignOut(rowData: IRowData) {\n    const session = rowData.data as UserSessionRepresentation;\n    await adminClient.realms.deleteSession({\n      realm,\n      session: session.id!,\n      isOffline: false,\n    });\n\n    if (session.userId === whoAmI.getUserId()) {\n      await keycloak.logout({ redirectUri: \"\" });\n    } else if (isOnUserPage && isLightweightUser(session.userId)) {\n      navigate(toUsers({ realm: realm }));\n    } else {\n      refresh();\n    }\n  }\n\n  return (\n    <>\n      \n      \n              \n            \n          )\n        }\n        columns={columns}\n        actionResolver={(rowData: IRowData) => {\n          if (\n            rowData.data.type === \"Offline\" ||\n            rowData.data.type === \"OFFLINE\"\n          ) {\n            return [\n              {\n                title: t(\"revoke\"),\n                onClick: () => onClickRevoke(rowData),\n              } as Action,\n            ];\n          }\n          return [\n            {\n              title: t(\"signOut\"),\n              onClick: () => onClickSignOut(rowData),\n            } as Action,\n          ];\n        }}\n        emptyState={\n          \n        }\n      />\n    \n  );\n}\n"],"names":["CubesIconConfig","CubesIcon","createIcon","isLightweightUser","userId","UsernameCell","row","realm","useRealm","t","useTranslation","jsxs","Link","toUser","Fragment","jsx","Tooltip","Label","InfoCircleIcon","ClientsCell","List","ListVariant","clientId","client","ListItem","toClient","SessionsTable","loader","hiddenColumns","emptyInstructions","logoutUser","filter","isSearching","isPaginated","keycloak","useEnvironment","adminClient","useAdminClient","whoAmI","useWhoAmI","navigate","useNavigate","addError","useAlerts","formatDate","useFormatDate","key","setKey","useState","refresh","value","isOnUserPage","useMatch","UserRoute","columns","useMemo","name","toggleLogoutDialog","LogoutConfirm","useConfirmDialog","toUsers","error","onClickRevoke","rowData","session","onClickSignOut","KeycloakDataTable","ToolbarItem","Button","ListEmptyState"],"mappings":"siBAEO,MAAMA,GAAkB,CAC7B,KAAM,YACN,OAAQ,IACR,MAAO,IACP,QAAS,kmBACT,QAAS,EACT,QAAS,CACX,EAEaC,GAAYC,EAAWF,EAAe,ECXtCG,EAAqBC,GAChCA,GAAQ,WAAW,cAAc,ECkD7BC,GAAgBC,GAAmC,CACjD,KA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