theme.keycloak.v2.admin.resources.assets.UsersSection-BgFpxLcs.js Maven / Gradle / Ivy
import{jsx as e,jsxs as o,Fragment as U}from"react/jsx-runtime";import{V as ke}from"./ViewHeader-B7eeFzFA.js";import{a as E,J as me,K as he,N as pe,D as W,f as be,g as Ue,ew as Ae,aa as z,Z as _,$ as M,ay as Ce,bb as fe,bc as Q,am as ne,i as K,e1 as Te,A as Ne,B as Z,k as q,b5 as Se,b6 as De,U as Ie,c5 as ie,b3 as ge,a2 as w,aB as Fe,co as we,ex as Ke,u as Ee,c as X,d as Pe,w as xe,a3 as Ve,a0 as Oe,a1 as Re,aC as J,L as Be,bx as Le,p as oe,bw as _e,I as qe,aP as Ge,ey as $e,ag as je,ah as He,aH as Me,aI as We,au as ze,P as Qe,dv as le}from"./main-C7ps2lmX.js";import{P as Je}from"./PermissionTab-CKEvhIGg.js";import{useState as g}from"react";import{u as ce}from"./ConfirmDialog-hx7XKLbN.js";import{L as Ze}from"./PaginatingTableToolbar-Cjsz5Jh4.js";import{a as Xe}from"./AddRoleMappingModal-DW8o4W0z.js";import{K as Ye}from"./KeycloakDataTable-DbY4la1D.js";import{F as et}from"./filter-icon-DO0QNij3.js";import{D as tt}from"./DropdownPanel-BoHoC5Zg.js";import{E as rt}from"./EmptyStateFooter-DqmBOP2I.js";import{W as at}from"./warning-triangle-icon-BPc4XyIG.js";import{a as st}from"./FlexItem-BzZfUnQ1.js";import{R as nt,u as it}from"./RoutableTabs-T8JTILEW.js";/* empty css */import{a as de,b as ue}from"./Tabs-CMdqT4Cg.js";import"react-dom";import"./Trans-DcGUccv9.js";import"./Td-D2hVFK0Z.js";import"./grip-vertical-icon-BxF7V59o.js";import"./EmptyStateActions-DWNUFByn.js";import"./_baseFlatten-eIEJR-AJ.js";import"./PageHandler-P2CRgucq.js";import"./DynamicComponents-DvaX3FJx.js";import"./ClientSelect-B9UqjyP6.js";import"./FileUpload-CumNwlWc.js";import"./CodeEditor-C-nZkUJx.js";import"./copy-icon-ACZmDH8e.js";import"./GroupPickerDialog-C09EjRTA.js";import"./DataListItemRow-BC0LurDd.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-DiPNQ1LE.js";import"./useParams-B67lSY02.js";import"./PageList-s9OtSlkz.js";const ot=({searchType:a,onSelect:s})=>{const{t:b}=E(),[u,f]=g(!1),n=i=>e(W,{onClick:()=>{s(i),f(!1)},children:b(`searchType.${i}`)},i),v=[n("default"),n("attribute")];return e(me,{className:"keycloak__users__searchtype",onOpenChange:i=>f(i),toggle:i=>e(he,{ref:i,id:"toggle-id",onClick:()=>f(!u),icon:e(et,{}),children:b(`searchType.${a}`)}),isOpen:u,children:e(pe,{children:v})})};function lt({activeFilters:a,setActiveFilters:s,profile:b,createAttributeSearchChips:u,searchUserWithAttributes:f}){const{t:n}=E(),{addAlert:v}=be(),[i,A]=g(!1),D={name:"",displayName:"",value:""},{getValues:m,register:k,reset:C,formState:{errors:h},setValue:P,setError:T,clearErrors:R}=Ue({mode:"onChange",defaultValues:D}),p=()=>a.some(t=>t.name===m().name),l=()=>{let t=!1;return m().name.length?a.some(c=>c.name===m().name)?T("name",{type:"conflict",message:n("searchUserByAttributeKeyAlreadyInUseError")}):t=!0:T("name",{type:"empty",message:n("searchUserByAttributeMissingKeyError")}),t},N=()=>{let t=!1;return m().value.length?t=!0:T("value",{type:"empty",message:n("searchUserByAttributeMissingValueError")}),t},S=()=>l()&&N(),I=()=>{S()?(s([...a,{...m()}]),C()):(h.name?.message&&v(h.name.message,q.danger),h.value?.message&&v(h.value.message,q.danger))},F=()=>{const t=[...a].filter(c=>c.name!==c.name);s(t)},x=()=>b?e(Se,{"data-testid":"search-attribute-name",variant:De.typeahead,onToggle:t=>A(t),selections:m().displayName,onSelect:t=>{P("displayName",t.toString()),p()?T("name",{type:"conflict"}):R("name")},isOpen:i,placeholderText:n("selectAttribute"),validated:h.name&&"error",maxHeight:300,...k("displayName",{required:!0,validate:l}),children:b.attributes?.map(t=>e(Ie,{value:ie(n,t.displayName,t.name),onClick:c=>{c.stopPropagation(),A(!1),P("name",t.name)},children:ie(n,t.displayName,t.name)},t.name))}):e(ne,{id:"name",placeholder:n("keyPlaceholder"),validated:h.name&&"error",onKeyDown:t=>t.key==="Enter"&&I(),...k("name",{required:!0,validate:l})});return o(Ae,{className:"user-attribute-search-form",children:[e(z,{className:"user-attribute-search-form-headline",children:e(_,{component:M.h2,children:n("selectAttributes")})}),e(Ce,{isInline:!0,className:"user-attribute-search-form-alert",variant:"info",title:n("searchUserByAttributeDescription"),component:"h3"}),o(z,{className:"user-attribute-search-form-key-value",children:[e("div",{className:"user-attribute-search-form-left",children:e(_,{component:M.h3,children:n("key")})}),e("div",{className:"user-attribute-search-form-right",children:e(_,{component:M.h3,children:n("value")})})]}),e("div",{className:"user-attribute-search-form-left",children:x()}),e("div",{className:"user-attribute-search-form-right",children:o(fe,{children:[e(Q,{children:e(ne,{id:"value",placeholder:n("valuePlaceholder"),validated:h.value&&"error",onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),I())},...k("value",{required:!0,validate:N})})}),e(Q,{children:e(K,{variant:"control",icon:e(Te,{}),onClick:I,"aria-label":n("addToFilter")})})]})}),u(),o(Ne,{className:"user-attribute-search-form-action-group",children:[e(K,{"data-testid":"search-user-attribute-btn",variant:"primary",type:"submit",isDisabled:!a.length,onClick:f,children:n("search")}),e(K,{variant:Z.link,onClick:()=>{C(),F()},children:n("reset")})]})]})}function ct({searchDropdownOpen:a,setSearchDropdownOpen:s,realm:b,hasSelectedRows:u,toggleDeleteDialog:f,toggleUnlockUsersDialog:n,goToCreate:v,searchType:i,setSearchType:A,searchUser:D,setSearchUser:m,activeFilters:k,setActiveFilters:C,refresh:h,profile:P,clearAllFilters:T,createAttributeSearchChips:R,searchUserWithAttributes:p}){const{t:l}=E(),[N,S]=g(!1),{hasAccess:I}=ge(),F=I("query-users"),x=()=>e(w,{children:o(fe,{children:[e(Q,{children:e(ot,{searchType:i,onSelect:y=>{T(),A(y)}})}),i==="default"&&t(),i==="attribute"&&c()]})}),t=()=>e(w,{children:e(we,{"data-testid":"table-search-input",placeholder:l("searchForUser"),"aria-label":l("search"),value:D,onSearch:(y,B,j)=>{m(j.haswords),h()},onKeyDown:y=>{if(y.key==="Enter"){const B=y.target;m(B.value),h()}},onClear:()=>{m(""),h()}})}),c=()=>o(U,{children:[e(tt,{buttonText:l("selectAttributes"),setSearchDropdownOpen:s,searchDropdownOpen:a,width:"15vw",children:e(lt,{activeFilters:k,setActiveFilters:C,profile:P,createAttributeSearchChips:R,searchUserWithAttributes:()=>{p(),s(!1)}})}),e(K,{icon:e(Ke,{}),variant:"control",onClick:()=>{p(),s(!1)},"aria-label":l("searchAttributes")})]}),G=b.bruteForceProtected?e(w,{children:e(me,{onOpenChange:y=>S(y),toggle:y=>e(he,{ref:y,isExpanded:N,variant:"plain",onClick:()=>S(!N),children:e(Fe,{})}),isOpen:N,shouldFocusToggleOnSelect:!0,children:o(pe,{children:[e(W,{component:"button",isDisabled:u,onClick:()=>{f(),S(!1)},children:l("deleteUser")},"deleteUser"),e(W,{component:"button",onClick:()=>{n(),S(!1)},children:l("unlockAllUsers")},"unlock")]})})}):e(w,{children:e(K,{variant:Z.link,onClick:f,"data-testid":"delete-user-btn",isDisabled:u,children:l("deleteUser")})}),$=o(U,{children:[e(w,{children:e(K,{"data-testid":"add-user",onClick:v,children:l("addUser")})}),G]});return o(U,{children:[x(),F?$:null]})}const dt=a=>{const{realm:s}=X();return o(Be,{to:Le({realm:s,id:a.id,tab:"settings"}),children:[a.username," ",e(ut,{user:a})]})},ut=({user:a})=>{const{t:s}=E();return o(U,{children:[!a.enabled&&e(oe,{color:"red",icon:e(_e,{}),children:s("disabled")}),a.bruteForceStatus?.disabled&&e(oe,{color:"orange",icon:e(at,{}),children:s("temporaryLocked")})]})},mt=a=>{const{t:s}=E();return o(U,{children:[!a.emailVerified&&e(qe,{content:s("notVerified"),children:e(Ge,{className:"keycloak__user-section__email-verified"})})," ",J()(a.email)]})};function ht(){const{adminClient:a}=Ee(),{t:s}=E(),{addAlert:b,addError:u}=be(),{realm:f,realmRepresentation:n}=X(),v=Pe(),[i,A]=g(),[D,m]=g(""),[k,C]=g([]),[h,P]=g("default"),[T,R]=g(!1),[p,l]=g([]),[N,S]=g({}),[I,F]=g(""),[x,t]=g(0),c=()=>t(x+1);xe(async()=>{const r={type:"org.keycloak.storage.UserStorageProvider"};try{return await Promise.all([a.components.find(r),a.users.getProfile()])}catch{return[[],{}]}},([r,d])=>{A(r.filter(V=>V.config?.enabled?.[0]==="true")),S(d)},[]);const G=async(r,d,V)=>{const O={first:r,max:d,q:I},L=V||D||"";if(L&&(O.search=L),!ee&&!(O.search||O.q))return[];try{return await Xe(a,{briefRepresentation:!0,...O})}catch(se){return i?.length?u("noUsersFoundErrorStorage",se):u("noUsersFoundError",se),[]}},[$,y]=ce({titleKey:"unlockAllUsers",messageKey:"unlockUsersConfirm",continueButtonLabel:"unlock",onConfirm:async()=>{try{await a.attackDetection.delAll(),c(),b(s("unlockUsersSuccess"),q.success)}catch(r){u("unlockUsersError",r)}}}),[B,j]=ce({titleKey:"deleteConfirmUsers",messageKey:s("deleteConfirmDialog",{count:k.length}),continueButtonLabel:"delete",continueButtonVariant:Z.danger,onConfirm:async()=>{try{for(const r of k)await a.users.del({id:r.id});C([]),H(),b(s("userDeletedSuccess"),q.success)}catch(r){u("userDeletedError",r)}}}),Y=()=>v($e({realm:f}));if(!i||!n)return e(Ve,{});const ee=!(i.length>0),H=()=>{const r=[...p].filter(d=>d.name!==d.name);l(r),m(""),F(""),c()},te=r=>r.map(d=>`${d.name}:${d.value}`).join(" "),ye=()=>{const r=te(p);F(r),c()},re=()=>e(st,{children:p.length>0&&e(U,{children:Object.values(p).map(r=>e(je,{className:"pf-v5-u-mt-md pf-v5-u-mr-md",categoryName:r.displayName.length?r.displayName:r.name,isClosable:!0,onClick:d=>{d.stopPropagation();const V=[...p].filter(L=>L.name!==r.name),O=te(V);l(V),F(O),c()},children:e(He,{isReadOnly:!0,children:r.value},r.name)},r.name))})}),ae=()=>e(ct,{searchDropdownOpen:T,setSearchDropdownOpen:R,realm:n,hasSelectedRows:k.length===0,toggleDeleteDialog:B,toggleUnlockUsersDialog:$,goToCreate:Y,searchType:h,setSearchType:P,searchUser:D,setSearchUser:m,activeFilters:p,setActiveFilters:l,refresh:c,profile:N,clearAllFilters:H,createAttributeSearchChips:re,searchUserWithAttributes:ye}),ve=()=>{if(p.length)return o("div",{className:"user-attribute-search-form-subtoolbar",children:[e(w,{children:re()}),e(w,{children:e(K,{variant:"link",onClick:()=>{H()},children:s("clearAllFilters")})})]})};return o(U,{children:[e(j,{}),e(y,{}),e(Ye,{isSearching:D!==""||p.length!==0,loader:G,isPaginated:!0,ariaLabelKey:"titleUsers",canSelectAll:!0,onSelect:r=>C([...r]),emptyState:ee?e(Ze,{message:s("noUsersFound"),instructions:s("emptyInstructions"),primaryActionText:s("createNewUser"),onPrimaryAction:Y}):o(U,{children:[e(Oe,{children:e(Re,{children:ae()})}),e(rt,{"data-testid":"empty-state",variant:"lg",children:e(z,{className:"kc-search-users-text",children:e(_,{children:s("searchForUserDescription")})})})]}),toolbarItem:ae(),subToolbar:ve(),actionResolver:r=>{const d=r.data;return d.access?.manage?[{title:s("delete"),onClick:()=>{C([d]),B()}}]:[]},columns:[{name:"username",displayKey:"username",cellRenderer:dt},{name:"email",displayKey:"email",cellRenderer:mt},{name:"lastName",displayKey:"lastName",cellFormatters:[J()]},{name:"firstName",displayKey:"firstName",cellFormatters:[J()]}]},x)]})}function Jt(){const{t:a}=E(),{realm:s}=X(),{hasAccess:b}=ge(),f=Me()(We.AdminFineGrainedAuthz)&&b("manage-authorization","manage-users","manage-clients"),n=A=>it(le({realm:s,tab:A})),v=n("list"),i=n("permissions");return o(U,{children:[e(ke,{titleKey:"titleUsers",subKey:"usersExplain",helpUrl:ze.usersUrl,divider:!1}),e(Qe,{"data-testid":"users-page",variant:"light",className:"pf-v5-u-p-0",children:o(nt,{"data-testid":"user-tabs",defaultLocation:le({realm:s,tab:"list"}),isBox:!0,mountOnEnter:!0,children:[e(de,{id:"list","data-testid":"listTab",title:e(ue,{children:a("userList")}),...v,children:e(ht,{})}),f&&e(de,{id:"permissions","data-testid":"permissionsTab",title:e(ue,{children:a("permissions")}),...i,children:e(Je,{type:"users"})})]})})]})}export{Jt as default};
//# sourceMappingURL=UsersSection-BgFpxLcs.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy