theme.keycloak.v2.admin.resources.assets.SessionsSection--6clq0zS.js.map Maven / Gradle / Ivy
{"version":3,"file":"SessionsSection--6clq0zS.js","sources":["../../src/sessions/RevocationModal.tsx","../../src/sessions/SessionsSection.tsx"],"sourcesContent":["import type GlobalRequestResult from \"@keycloak/keycloak-admin-client/lib/defs/globalRequestResult\";\nimport {\n AlertVariant,\n Button,\n ButtonVariant,\n Form,\n FormGroup,\n Modal,\n ModalVariant,\n TextContent,\n TextInput,\n} from \"@patternfly/react-core\";\nimport { useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useAdminClient } from \"../admin-client\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\n\ntype RevocationModalProps = {\n handleModalToggle: () => void;\n save: () => void;\n};\n\nexport const RevocationModal = ({\n handleModalToggle,\n save,\n}: RevocationModalProps) => {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const { addAlert } = useAlerts();\n\n const { realm: realmName, realmRepresentation: realm, refresh } = useRealm();\n const { register, handleSubmit } = useForm();\n\n const parseResult = (result: GlobalRequestResult, prefixKey: string) => {\n const successCount = result.successRequests?.length || 0;\n const failedCount = result.failedRequests?.length || 0;\n\n if (successCount === 0 && failedCount === 0) {\n addAlert(t(\"noAdminUrlSet\"), AlertVariant.warning);\n } else if (failedCount > 0) {\n addAlert(\n t(\"\" + prefixKey + \"Success\", {\n successNodes: result.successRequests,\n }),\n AlertVariant.success,\n );\n addAlert(\n t(\"\" + prefixKey + \"Fail\", {\n failedNodes: result.failedRequests,\n }),\n AlertVariant.danger,\n );\n } else {\n addAlert(\n t(\"\" + prefixKey + \"Success\", {\n successNodes: result.successRequests,\n }),\n AlertVariant.success,\n );\n }\n };\n\n const setToNow = async () => {\n try {\n await adminClient.realms.update(\n { realm: realmName },\n {\n realm: realmName,\n notBefore: Date.now() / 1000,\n },\n );\n\n addAlert(t(\"notBeforeSuccess\"), AlertVariant.success);\n } catch (error) {\n addAlert(t(\"setToNowError\", { error }), AlertVariant.danger);\n }\n };\n\n const clearNotBefore = async () => {\n try {\n await adminClient.realms.update(\n { realm: realmName },\n {\n realm: realmName,\n notBefore: 0,\n },\n );\n addAlert(t(\"notBeforeClearedSuccess\"), AlertVariant.success);\n refresh();\n } catch (error) {\n addAlert(t(\"notBeforeError\", { error }), AlertVariant.danger);\n }\n };\n\n const push = async () => {\n const result = await adminClient.realms.pushRevocation({\n realm: realmName,\n });\n parseResult(result, \"notBeforePush\");\n\n refresh();\n };\n\n return (\n {\n setToNow();\n handleModalToggle();\n }}\n form=\"revocation-modal-form\"\n >\n {t(\"setToNow\")}\n ,\n ,\n ,\n ,\n ]}\n >\n \n {t(\"revocationDescription\")}\n \n \n \n );\n};\n","import UserSessionRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/userSessionRepresentation\";\nimport { KeycloakSelect } from \"@keycloak/keycloak-ui-shared\";\nimport {\n DropdownItem,\n PageSection,\n SelectOption,\n} from \"@patternfly/react-core\";\nimport { FilterIcon } from \"@patternfly/react-icons\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { useAdminClient } from \"../admin-client\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { useConfirmDialog } from \"../components/confirm-dialog/ConfirmDialog\";\nimport { ViewHeader } from \"../components/view-header/ViewHeader\";\nimport { fetchAdminUI } from \"../context/auth/admin-ui-endpoint\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport helpUrls from \"../help-urls\";\nimport useToggle from \"../utils/useToggle\";\nimport { RevocationModal } from \"./RevocationModal\";\nimport SessionsTable from \"./SessionsTable\";\n\nimport \"./SessionsSection.css\";\n\ntype FilterType = \"ALL\" | \"REGULAR\" | \"OFFLINE\";\n\ntype SessionFilterProps = {\n filterType: FilterType;\n onChange: (filterType: FilterType) => void;\n};\n\nconst SessionFilter = ({ filterType, onChange }: SessionFilterProps) => {\n const { t } = useTranslation();\n\n const [open, toggle] = useToggle();\n\n return (\n }\n onSelect={(value) => {\n const filter = value as FilterType;\n onChange(filter);\n toggle();\n }}\n selections={filterType}\n >\n \n {t(\"sessionsType.allSessions\")}\n \n \n {t(\"sessionsType.regularSSO\")}\n \n \n {t(\"sessionsType.offline\")}\n \n \n );\n};\n\nexport default function SessionsSection() {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n\n const [key, setKey] = useState(0);\n const refresh = () => setKey(key + 1);\n const { addError } = useAlerts();\n const { realm } = useRealm();\n\n const [revocationModalOpen, setRevocationModalOpen] = useState(false);\n const [filterType, setFilterType] = useState(\"ALL\");\n const [noSessions, setNoSessions] = useState(false);\n\n const handleRevocationModalToggle = () => {\n setRevocationModalOpen(!revocationModalOpen);\n };\n\n const loader = async (first?: number, max?: number, search?: string) => {\n const data = await fetchAdminUI(\n adminClient,\n \"ui-ext/sessions\",\n {\n first: `${first}`,\n max: `${max}`,\n type: filterType,\n search: search || \"\",\n },\n );\n setNoSessions(data.length === 0);\n return data;\n };\n\n const [toggleLogoutDialog, LogoutConfirm] = useConfirmDialog({\n titleKey: \"logoutAllSessions\",\n messageKey: \"logoutAllDescription\",\n continueButtonLabel: \"confirm\",\n onConfirm: async () => {\n try {\n await adminClient.realms.logoutAll({ realm });\n refresh();\n } catch (error) {\n addError(\"logoutAllSessionsError\", error);\n }\n },\n });\n\n return (\n <>\n \n handleRevocationModalToggle()}\n >\n {t(\"revocation\")}\n ,\n \n {t(\"signOutAllActiveSessions\")}\n ,\n ]}\n titleKey=\"titleSessions\"\n subKey=\"sessionExplain\"\n helpUrl={helpUrls.sessionsUrl}\n />\n \n {revocationModalOpen && (\n {\n handleRevocationModalToggle();\n }}\n />\n )}\n {\n setFilterType(type);\n refresh();\n }}\n />\n }\n />\n \n >\n );\n}\n"],"names":["RevocationModal","handleModalToggle","save","adminClient","useAdminClient","t","useTranslation","addAlert","useAlerts","realmName","realm","refresh","useRealm","register","handleSubmit","useForm","parseResult","result","prefixKey","successCount","failedCount","AlertVariant","setToNow","error","clearNotBefore","push","jsxs","Modal","ModalVariant","jsx","Button","ButtonVariant","TextContent","Form","FormGroup","TextInput","SessionFilter","filterType","onChange","open","toggle","useToggle","KeycloakSelect","FilterIcon","value","SelectOption","SessionsSection","key","setKey","useState","addError","revocationModalOpen","setRevocationModalOpen","setFilterType","noSessions","setNoSessions","handleRevocationModalToggle","loader","first","max","search","data","fetchAdminUI","toggleLogoutDialog","LogoutConfirm","useConfirmDialog","Fragment","ViewHeader","DropdownItem","helpUrls","PageSection","SessionsTable","type"],"mappings":"w1BAuBO,MAAMA,EAAkB,CAAC,CAC9B,kBAAAC,EACA,KAAAC,CACF,IAA4B,CACpB,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACR,CAAE,SAAAC,GAAaC,IAEf,CAAE,MAAOC,EAAW,oBAAqBC,EAAO,QAAAC,CAAA,EAAYC,IAC5D,CAAE,SAAAC,EAAU,aAAAC,CAAa,EAAIC,EAAQ,EAErCC,EAAc,CAACC,EAA6BC,IAAsB,CAChE,MAAAC,EAAeF,EAAO,iBAAiB,QAAU,EACjDG,EAAcH,EAAO,gBAAgB,QAAU,EAEjDE,IAAiB,GAAKC,IAAgB,EACxCb,EAASF,EAAE,eAAe,EAAGgB,EAAa,OAAO,EACxCD,EAAc,GACvBb,EACEF,EAAE,GAAKa,EAAY,UAAW,CAC5B,aAAcD,EAAO,eAAA,CACtB,EACDI,EAAa,OAAA,EAEfd,EACEF,EAAE,GAAKa,EAAY,OAAQ,CACzB,YAAaD,EAAO,cAAA,CACrB,EACDI,EAAa,MAAA,GAGfd,EACEF,EAAE,GAAKa,EAAY,UAAW,CAC5B,aAAcD,EAAO,eAAA,CACtB,EACDI,EAAa,OAAA,CAEjB,EAGIC,EAAW,SAAY,CACvB,GAAA,CACF,MAAMnB,EAAY,OAAO,OACvB,CAAE,MAAOM,CAAU,EACnB,CACE,MAAOA,EACP,UAAW,KAAK,IAAA,EAAQ,GAC1B,CAAA,EA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