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

theme.keycloak.v2.admin.resources.assets.EventsSection-C_9tNQFu.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,k as Ue,bO 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,x as v,A as ke,h as V,M as Ge,q as Me,v as He,c8 as je,au as Be,P as We,c9 as ne,ca as oe,C as $e}from"./index-C1LIsRX7.js";import{useState as m,useMemo as ze}from"react";import{D as Fe}from"./DropdownPanel-CvKbZ6hZ.js";import{L as Ee}from"./PaginatingTableToolbar-CpMLQtqt.js";import{R as Xe,u as Ze}from"./RoutableTabs-j5CUH0-6.js";import{K as Ae}from"./KeycloakDataTable-jyvvxdb8.js";import{V as qe}from"./ViewHeader-qjLr6U82.js";import{u as Ie,F as Re}from"./useFormatDate-Ypu7MAgr.js";import{p as Se}from"./pickBy-DqRcHijc.js";import{U as Je,a2 as Ye,V as Qe,W as P,X as ie,Y as et,Z as T,T as Oe,a3 as tt}from"./Td-BwjBKSkH.js";import{C as at,L as rt}from"./CodeEditor-CIeIZGz7.js";import{F as De,a as K}from"./FlexItem-DCAd8FXq.js";import{D as G}from"./DatePicker-DHSpSdsh.js";import{T as st}from"./Trans-DZTM8FLp.js";import{W as nt}from"./warning-triangle-icon-FYjAG_z9.js";import{a as le,b as ce}from"./Tabs-CNBvRApH.js";import{D as ot,a as de,b as pe,c as ue}from"./DescriptionListTerm-B63BUcYe.js";import"react-dom";import"./EmptyStateFooter-Cm2IMTi1.js";import"./EmptyStateActions-DBSnfkAA.js";import"./PageHandler-CFMh3rCu.js";import"./DynamicComponents-CIZcko9u.js";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./DataListItemRow-COCiEHyF.js";import"./KeySelect-B2uWUd6C.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-AcwuO_FT.js";import"./AddRoleMappingModal-Ds4yp8lg.js";import"./ConfirmDialog-B5qjiAuo.js";import"./filter-icon-BVyMUArZ.js";import"./useParams-n_2fXkN1.js";import"./PageList-D9zZFEpa.js";import"./_baseFlatten-BHAcGTxk.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./copy-icon-DOS8MmN7.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)},lt=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"),ct=new RegExp(/([0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})/),dt=(r,t)=>{const l=ct.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"}):""},pt=({event:r})=>{const{realm:t}=M();return e(it,{text:r.resourcePath,children:l=>lt(r)?e(se,{to:dt(t,r),children:l}):e("span",{children:l})})},ut=r=>e(pt,{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})},mt=()=>{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),o()}function E(){D(),o()}function Q(a){const s={...O()};delete s[a],D({...he,...s}),o()}function n(a,s){const i=O(),u=i[a],N=Array.isArray(u)?u.filter(Ne=>Ne!==s):u;D({...i,[a]:N}),o()}function o(){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(ie,{children:t("attribute")}),e(ie,{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(at,{isLineNumbersVisible:!0,isReadOnly:!0,code:d,language:rt.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 i=s.toString(),u=a.value.includes(i)?a.value.filter(N=>N!==i):[...a.value,i];a.onChange(u)},onClear:()=>{a.onChange([])},isOpen:z,"aria-labelledby":"resourceTypes",chipGroupComponent:e(L,{children:a.value.map(s=>e(g,{onClick:i=>{i.stopPropagation(),a.onChange(a.value.filter(u=>u!==s))},children:s},s))}),children:j?.map(s=>e(ae,{value: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 i=s.toString(),u=a.value.includes(i)?a.value.filter(N=>N!==i):[...a.value,i];a.onChange(u)},onClear:()=>{a.onChange([])},isOpen:X,"aria-labelledby":"operationTypes",chipGroupComponent:e(L,{children:a.value.map(s=>e(g,{onClick:i=>{i.stopPropagation(),a.onChange(a.value.filter(u=>u!==s))},children:s},s))}),children:B?.map(s=>e(ae,{value: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,i)=>a.onChange(i),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,i)=>a.onChange(i),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,i]=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 i=="string"?e(g,{isReadOnly:!0,children:i}):i.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:ut},{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:""},ht=r=>r.error?e(ve,{content:r.error,children:c("span",{children:[e(oe,{status:"warning",children:e(nt,{})}),r.type]})}):c("span",{children:[e(oe,{status:"success",children:e($e,{})}),r.type]}),yt=r=>c(ot,{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")]}),Tt=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 ta(){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,o){return r.realms.findEvents({...k,realm:l,first:n,max:o})}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 o={...I()};delete o[n],h({...Te,...o}),E()}function Y(n,o){const d=I(),a=d[n],s=Array.isArray(a)?a.filter(i=>i!==o):a;h({...d,[n]:s}),E()}function E(){const n=Se(I(),o=>o!==""||Array.isArray(o)&&o.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:o=>$(o),selections:n.value,onSelect:o=>{const d=o.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(o=>e(g,{onClick:d=>{d.stopPropagation(),n.onChange(n.value.filter(a=>a!==o))},children:t(`eventTypes.${o}.name`)},o))}),children:w?.enabledEventTypes?.map(o=>e(ae,{value:o,children:t(`eventTypes.${o}.name`)},o))})})}),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:(o,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:(o,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[o,d]=n;return e(L,{className:"pf-v5-u-mt-md pf-v5-u-mr-md",categoryName:Z[o],isClosable:!0,onClick:()=>J(o),children:typeof d=="string"?e(g,{isReadOnly:!0,children:d}):d.map(a=>e(g,{onClick:()=>Y(o,a),children:t(`eventTypes.${a}.name`)},a))},o)})})})]})});return c(re,{children:[e(qe,{titleKey:"titleEvents",subKey:c(st,{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:yt}],isPaginated:!0,ariaLabelKey:"titleEvents",toolbarItem:Q(),columns:[{name:"time",displayKey:"time",cellFormatters:[tt],cellRenderer:n=>p(new Date(n.time),Re)},{name:"userId",displayKey:"user",cellRenderer:Tt},{name:"type",displayKey:"eventType",cellRenderer:ht},{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(mt,{})})]})})]})}export{ta as default};
//# sourceMappingURL=EventsSection-C_9tNQFu.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy