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

theme.keycloak.v2.admin.resources.assets.EventsSection-BTS2MqRb.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as e,jsxs as c,Fragment as re}from"react/jsx-runtime";import{c as M,L as se,I as ve,aR as Pe,c7 as Le,az as we,bx as be,l as Ue,bP as xe,u as _e,a as H,b as Ve,g as fe,a_ as Ke,F as ge,r as Ce,ac as _,ae as f,b5 as ee,b6 as te,ag as L,ah as g,U as ae,y as v,A as ke,i as V,M as Ge,q as Me,w as He,c8 as je,au as Be,P as We,c9 as ne,ca as ie,C as $e}from"./main-C7ps2lmX.js";import{useState as m,useMemo as ze}from"react";import{D as Fe}from"./DropdownPanel-BoHoC5Zg.js";import{L as Ee}from"./PaginatingTableToolbar-Cjsz5Jh4.js";import{R as Xe,u as Ze}from"./RoutableTabs-T8JTILEW.js";import{K as Ae}from"./KeycloakDataTable-DbY4la1D.js";import{V as qe}from"./ViewHeader-B7eeFzFA.js";import{u as Ie,F as Re}from"./useFormatDate-X7HJ5iYO.js";import{p as Se}from"./pickBy-CtMuUSbs.js";import{U as Je,a1 as Ye,V as Qe,W as P,X as oe,Y as et,Z as T,T as Oe}from"./Td-D2hVFK0Z.js";import{C as tt,L as at}from"./CodeEditor-C-nZkUJx.js";import{F as De,a as K}from"./FlexItem-BzZfUnQ1.js";import{D as G}from"./DatePicker-DTJHSI7E.js";import{T as rt}from"./Trans-DcGUccv9.js";import{W as st}from"./warning-triangle-icon-BPc4XyIG.js";import{a as le,b as ce}from"./Tabs-CMdqT4Cg.js";import{D as nt,a as de,b as pe,c as ue}from"./DescriptionListTerm-Bdo198Bq.js";import"react-dom";import"./EmptyStateFooter-DqmBOP2I.js";import"./EmptyStateActions-DWNUFByn.js";import"./PageHandler-P2CRgucq.js";import"./DynamicComponents-DvaX3FJx.js";import"./ClientSelect-B9UqjyP6.js";import"./FileUpload-CumNwlWc.js";import"./GroupPickerDialog-C09EjRTA.js";import"./DataListItemRow-BC0LurDd.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-DiPNQ1LE.js";import"./AddRoleMappingModal-DW8o4W0z.js";import"./ConfirmDialog-hx7XKLbN.js";import"./filter-icon-DO0QNij3.js";import"./useParams-B67lSY02.js";import"./PageList-s9OtSlkz.js";import"./_baseFlatten-eIEJR-AJ.js";import"./grip-vertical-icon-BxF7V59o.js";import"./copy-icon-ACZmDH8e.js";const me=38,it=({text:r,children:t})=>{const l=r||"",p=l.length>me,C=l.substring(0,me);return p?e(ve,{content:r,children:t(C+"…")}):t(l)},ot=r=>r.operationType==="DELETE"?!1:r.resourceType==="USER"||r.resourceType==="GROUP_MEMBERSHIP"||r.resourceType==="GROUP"||r.resourceType==="CLIENT"||r.resourceType?.startsWith("AUTHORIZATION_RESOURCE")||r.resourceType==="CLIENT_SCOPE"||r.resourceType==="AUTH_FLOW"||r.resourcePath?.startsWith("roles-by-id"),lt=new RegExp(/([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})/),ct=(r,t)=>{const l=lt.exec(t.resourcePath);if(!l)return console.warn("event didn't contain a valid link",t),"";const p=l[1];return t.resourceType==="CLIENT"||t.resourceType?.startsWith("AUTHORIZATION_RESOURCE")?Pe({realm:r,clientId:p,tab:t.resourceType==="CLIENT"?"settings":"authorization"}):t.resourceType==="GROUP"?Le({realm:r,id:p}):t.resourceType==="CLIENT_SCOPE"?we({realm:r,id:p,tab:"settings"}):t.resourceType==="USER"||t.resourceType==="GROUP_MEMBERSHIP"?be({realm:r,id:p,tab:"settings"}):t.resourceType==="AUTH_FLOW"?Ue({realm:r,id:p,usedBy:"-"}):t.resourcePath?.startsWith("roles-by-id")?xe({realm:r,id:p,tab:"details"}):""},dt=({event:r})=>{const{realm:t}=M();return e(it,{text:r.resourcePath,children:l=>ot(r)?e(se,{to:ct(t,r),children:l}):e("span",{children:l})})},pt=r=>e(dt,{event:r}),he={resourceTypes:[],operationTypes:[],resourcePath:"",dateFrom:"",dateTo:"",authClient:"",authUser:"",authRealm:"",authIpAddress:""},ye=({titleKey:r,onClose:t,children:l})=>{const{t:p}=H();return e(Ge,{variant:Me.medium,title:p(r),isOpen:!0,onClose:t,children:l})},ut=()=>{const{adminClient:r}=_e(),{t}=H(),{realm:l}=M(),p=Ve(),C=Ie(),j=p.enums?.resourceType,B=p.enums?.operationType,[A,W]=m(0),[$,w]=m(!1),[z,k]=m(!1),[X,Z]=m(!1),[b,I]=m({}),[h,R]=m(),[y,U]=m(),q={resourceTypes:t("resourceTypes"),operationTypes:t("operationTypes"),resourcePath:t("resourcePath"),dateFrom:t("dateFrom"),dateTo:t("dateTo"),authClient:t("client"),authUser:t("userId"),authRealm:t("realm"),authIpAddress:t("ipAddress")},S=fe({mode:"onChange",defaultValues:he}),{getValues:O,reset:D,formState:{isDirty:x},control:F}=S;function J(a,s){return r.realms.findAdminEvents({...b,realm:l,first:a,max:s})}function Y(){w(!1),i()}function E(){D(),i()}function Q(a){const s={...O()};delete s[a],D({...he,...s}),i()}function n(a,s){const o=O(),u=o[a],N=Array.isArray(u)?u.filter(Ne=>Ne!==s):u;D({...o,[a]:N}),i()}function i(){const a=Se(O(),s=>s!==""||Array.isArray(s)&&s.length>0);I(a),W(A+1)}const d=ze(()=>y?.representation?Ke(JSON.parse(y.representation)):"",[y?.representation]);return c(re,{children:[h&&e(ye,{titleKey:"auth",onClose:()=>R(void 0),children:c(Je,{"aria-label":"authData","data-testid":"auth-dialog",variant:Ye.compact,children:[e(Qe,{children:c(P,{children:[e(oe,{children:t("attribute")}),e(oe,{children:t("value")})]})}),c(et,{children:[c(P,{children:[e(T,{children:t("realm")}),e(T,{children:h.authDetails?.realmId})]}),c(P,{children:[e(T,{children:t("client")}),e(T,{children:h.authDetails?.clientId})]}),c(P,{children:[e(T,{children:t("user")}),e(T,{children:h.authDetails?.userId})]}),c(P,{children:[e(T,{children:t("ipAddress")}),e(T,{children:h.authDetails?.ipAddress})]})]})]})}),y&&e(ye,{titleKey:"representation","data-testid":"representation-dialog",onClose:()=>U(void 0),children:e(tt,{isLineNumbersVisible:!0,isReadOnly:!0,code:d,language:at.json,height:"8rem"})}),e(Ae,{loader:J,isPaginated:!0,ariaLabelKey:"adminEvents",toolbarItem:e(ge,{...S,children:c(De,{direction:{default:"column"},spaceItems:{default:"spaceItemsNone"},children:[e(K,{children:e(Fe,{buttonText:t("searchForAdminEvent"),setSearchDropdownOpen:w,searchDropdownOpen:$,marginRight:"2.5rem",width:"15vw",children:c(Ce,{isHorizontal:!0,className:"keycloak__events_search__form","data-testid":"searchForm",children:[e(_,{label:t("resourceTypes"),fieldId:"kc-resourceTypes",className:"keycloak__events_search__form_label",children:e(f,{name:"resourceTypes",control:F,render:({field:a})=>e(ee,{className:"keycloak__events_search__type_select","data-testid":"resource-types-searchField",chipGroupProps:{numChips:1,expandedText:t("hide"),collapsedText:t("showRemaining")},variant:te.typeaheadMulti,typeAheadAriaLabel:"Select",onToggle:s=>k(s),selections:a.value,onSelect:s=>{const o=s.toString(),u=a.value.includes(o)?a.value.filter(N=>N!==o):[...a.value,o];a.onChange(u)},onClear:()=>{a.onChange([])},isOpen:z,"aria-labelledby":"resourceTypes",chipGroupComponent:e(L,{children:a.value.map(s=>e(g,{onClick:o=>{o.stopPropagation(),a.onChange(a.value.filter(u=>u!==s))},children:s},s))}),children:j?.map(s=>e(ae,{value:s,children:s},s))})})}),e(_,{label:t("operationTypes"),fieldId:"kc-operationTypes",className:"keycloak__events_search__form_label",children:e(f,{name:"operationTypes",control:F,render:({field:a})=>e(ee,{className:"keycloak__events_search__type_select","data-testid":"operation-types-searchField",chipGroupProps:{numChips:1,expandedText:t("hide"),collapsedText:t("showRemaining")},variant:te.typeaheadMulti,typeAheadAriaLabel:"Select",onToggle:s=>Z(s),selections:a.value,onSelect:s=>{const o=s.toString(),u=a.value.includes(o)?a.value.filter(N=>N!==o):[...a.value,o];a.onChange(u)},onClear:()=>{a.onChange([])},isOpen:X,"aria-labelledby":"operationTypes",chipGroupComponent:e(L,{children:a.value.map(s=>e(g,{onClick:o=>{o.stopPropagation(),a.onChange(a.value.filter(u=>u!==s))},children:s},s))}),children:B?.map(s=>e(ae,{value:s,children:s},s.toString()))})})}),e(v,{name:"resourcePath",label:t("resourcePath")}),e(v,{name:"authRealm",label:t("realm")}),e(v,{name:"authClient",label:t("client")}),e(v,{name:"authUser",label:t("user")}),e(v,{name:"authIpAddress",label:t("ipAddress")}),e(_,{label:t("dateFrom"),fieldId:"kc-dateFrom",className:"keycloak__events_search__form_label",children:e(f,{name:"dateFrom",control:F,render:({field:a})=>e(G,{className:"pf-v5-u-w-100",value:a.value,onChange:(s,o)=>a.onChange(o),inputProps:{id:"kc-dateFrom"}})})}),e(_,{label:t("dateTo"),fieldId:"kc-dateTo",className:"keycloak__events_search__form_label",children:e(f,{name:"dateTo",control:F,render:({field:a})=>e(G,{className:"pf-v5-u-w-100",value:a.value,onChange:(s,o)=>a.onChange(o),inputProps:{id:"kc-dateTo"}})})}),c(ke,{children:[e(V,{variant:"primary",onClick:Y,"data-testid":"search-events-btn",isDisabled:!x,children:t("searchAdminEventsBtn")}),e(V,{variant:"secondary",onClick:E,isDisabled:!x,children:t("resetBtn")})]})]})})}),e(K,{children:Object.entries(b).length>0&&e("div",{className:"keycloak__searchChips pf-v5-u-ml-md",children:Object.entries(b).map(a=>{const[s,o]=a;return e(L,{className:"pf-v5-u-mt-md pf-v5-u-mr-md",categoryName:q[s],isClosable:!0,onClick:()=>Q(s),children:typeof o=="string"?e(g,{isReadOnly:!0,children:o}):o.map(u=>e(g,{onClick:()=>n(s,u),children:u},u))},s)})})})]})}),actions:[{title:t("auth"),onRowClick:a=>R(a)},{title:t("representation"),onRowClick:a=>U(a)}],columns:[{name:"time",displayKey:"time",cellRenderer:a=>C(new Date(a.time),Re)},{name:"resourcePath",displayKey:"resourcePath",cellRenderer:pt},{name:"resourceType",displayKey:"resourceType"},{name:"operationType",displayKey:"operationType",transforms:[Oe(10)]},{name:"",displayKey:"user",cellRenderer:a=>a.authDetails?.userId||""}],emptyState:e(Ee,{message:t("emptyAdminEvents"),instructions:t("emptyAdminEventsInstructions")}),isSearching:Object.keys(b).length>0},A)]})},Te={client:"",dateFrom:"",dateTo:"",user:"",type:[],ipAddress:""},mt=r=>r.error?e(ve,{content:r.error,children:c("span",{children:[e(ie,{status:"warning",children:e(st,{})}),r.type]})}):c("span",{children:[e(ie,{status:"success",children:e($e,{})}),r.type]}),ht=r=>c(nt,{isHorizontal:!0,className:"keycloak_eventsection_details",children:[r.details&&Object.entries(r.details).map(([t,l])=>c(de,{children:[e(pe,{children:t}),e(ue,{children:l})]},t)),r.error&&c(de,{children:[e(pe,{children:"error"}),e(ue,{children:r.error})]},"error")]}),yt=r=>{const{t}=H(),{realm:l}=M();return c(re,{children:[r.userId&&e(se,{to:be({realm:l,id:r.userId,tab:"settings"}),children:r.userId},`link-${r.time}-${r.type}`),!r.userId&&t("noUserDetails")]})};function ea(){const{adminClient:r}=_e(),{t}=H(),{realm:l}=M(),p=Ie(),[C,j]=m(0),[B,A]=m(!1),[W,$]=m(!1),[w,z]=m(),[k,X]=m({}),Z={client:t("client"),dateFrom:t("dateFrom"),dateTo:t("dateTo"),user:t("userId"),type:t("eventType"),ipAddress:t("ipAddress")},b=fe({mode:"onChange",defaultValues:Te}),{getValues:I,reset:h,formState:{isDirty:R},control:y,handleSubmit:U}=b;He(()=>r.realms.getConfigEvents({realm:l}),n=>z(n),[]);function q(n,i){return r.realms.findEvents({...k,realm:l,first:n,max:i})}const S=n=>Ze(ne({realm:l,tab:n})),O=S("user-events"),D=S("admin-events");function x(){A(!1),E()}function F(){h(),E()}function J(n){const i={...I()};delete i[n],h({...Te,...i}),E()}function Y(n,i){const d=I(),a=d[n],s=Array.isArray(a)?a.filter(o=>o!==i):a;h({...d,[n]:s}),E()}function E(){const n=Se(I(),i=>i!==""||Array.isArray(i)&&i.length>0);X(n),j(C+1)}const Q=()=>e(ge,{...b,children:c(De,{direction:{default:"column"},spaceItems:{default:"spaceItemsNone"},children:[e(K,{children:e(Fe,{buttonText:t("searchForUserEvent"),setSearchDropdownOpen:A,searchDropdownOpen:B,marginRight:"2.5rem",width:"15vw",children:c(Ce,{"data-testid":"searchForm",className:"keycloak__events_search__form",onSubmit:U(x),isHorizontal:!0,children:[e(v,{name:"user",label:t("userId"),"data-testid":"userId-searchField"}),e(_,{label:t("eventType"),fieldId:"kc-eventType",className:"keycloak__events_search__form_label",children:e(f,{name:"type",control:y,render:({field:n})=>e(ee,{className:"keycloak__events_search__type_select","data-testid":"event-type-searchField",chipGroupProps:{numChips:1,expandedText:t("hide"),collapsedText:t("showRemaining")},variant:te.typeaheadMulti,typeAheadAriaLabel:"Select",onToggle:i=>$(i),selections:n.value,onSelect:i=>{const d=i.toString(),a=n.value.includes(d)?n.value.filter(s=>s!==d):[...n.value,d];n.onChange(a)},onClear:()=>{n.onChange([])},isOpen:W,"aria-labelledby":"eventType",chipGroupComponent:e(L,{children:n.value.map(i=>e(g,{onClick:d=>{d.stopPropagation(),n.onChange(n.value.filter(a=>a!==i))},children:t(`eventTypes.${i}.name`)},i))}),children:w?.enabledEventTypes?.map(i=>e(ae,{value:i,children:t(`eventTypes.${i}.name`)},i))})})}),e(v,{name:"client",label:t("client"),"data-testid":"client-searchField"}),e(_,{label:t("dateFrom"),fieldId:"kc-dateFrom",className:"keycloak__events_search__form_label",children:e(f,{name:"dateFrom",control:y,render:({field:n})=>e(G,{className:"pf-v5-u-w-100",value:n.value,onChange:(i,d)=>n.onChange(d),inputProps:{id:"kc-dateFrom"}})})}),e(_,{label:t("dateTo"),fieldId:"kc-dateTo",className:"keycloak__events_search__form_label",children:e(f,{name:"dateTo",control:y,render:({field:n})=>e(G,{className:"pf-v5-u-w-100",value:n.value,onChange:(i,d)=>n.onChange(d),inputProps:{id:"kc-dateTo"}})})}),e(v,{name:"ipAddress",label:t("ipAddress"),"data-testid":"ipAddress-searchField"}),c(ke,{children:[e(V,{"data-testid":"search-events-btn",variant:"primary",type:"submit",isDisabled:!R,children:t("searchUserEventsBtn")}),e(V,{variant:"secondary",onClick:F,isDisabled:!R,children:t("resetBtn")})]})]})})}),e(K,{children:Object.entries(k).length>0&&e("div",{className:"keycloak__searchChips pf-v5-u-ml-md",children:Object.entries(k).map(n=>{const[i,d]=n;return e(L,{className:"pf-v5-u-mt-md pf-v5-u-mr-md",categoryName:Z[i],isClosable:!0,onClick:()=>J(i),children:typeof d=="string"?e(g,{isReadOnly:!0,children:d}):d.map(a=>e(g,{onClick:()=>Y(i,a),children:t(`eventTypes.${a}.name`)},a))},i)})})})]})});return c(re,{children:[e(qe,{titleKey:"titleEvents",subKey:c(rt,{i18nKey:"eventExplain",children:["If you want to configure user events, Admin events or Event listeners, please enter",e(se,{to:je({realm:l,tab:"events"}),children:t("eventConfig")}),"page realm settings to configure."]}),helpUrl:Be.eventsUrl,divider:!1}),e(We,{variant:"light",className:"pf-v5-u-p-0",children:c(Xe,{isBox:!0,defaultLocation:ne({realm:l,tab:"user-events"}),children:[e(le,{title:e(ce,{children:t("userEvents")}),...O,children:e("div",{className:"keycloak__events_table",children:e(Ae,{loader:q,detailColumns:[{name:"details",enabled:n=>n.details!==void 0,cellRenderer:ht}],isPaginated:!0,ariaLabelKey:"titleEvents",toolbarItem:Q(),columns:[{name:"time",displayKey:"time",cellRenderer:n=>p(new Date(n.time),Re)},{name:"userId",displayKey:"user",cellRenderer:yt},{name:"type",displayKey:"eventType",cellRenderer:mt},{name:"ipAddress",displayKey:"ipAddress",transforms:[Oe(10)]},{name:"clientId",displayKey:"client"}],emptyState:e(Ee,{message:t("emptyUserEvents"),instructions:t("emptyUserEventsInstructions")}),isSearching:Object.keys(k).length>0},C)})}),e(le,{title:e(ce,{children:t("adminEvents")}),"data-testid":"admin-events-tab",...D,children:e(ut,{})})]})})]})}export{ea as default};
//# sourceMappingURL=EventsSection-BTS2MqRb.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy