1import{r as b,j as e}from"./index.js";import{V as he}from"./ViewHeader.js";import{m as re,u as be,a as $,l as _,L as xe,bg as fe,f as je,z as ge,A as ye,v as Ae,ag as X}from"./KcAdminUi.js";import{P as ve}from"./PermissionTab.js";import{o as k,ab as ae,a4 as ie,ad as ne,af as oe,aS as le,ch as Se,T as q,G as L,bC as O,a$ as ke,Z as ce,$ as B,V as Y,q as D,aH as Te,al as Ce,X as Fe,aV as G,r as J,aq as V,ac as Ne,aZ as Ue,aA as Ie,H as Ee,ao as we,ap as Ke,aY as De,ag as ue,bV as Ve,bo as Pe,aL as Re,E as Le}from"./index2.js";import{K as Oe}from"./KeycloakDataTable.js";import{S as _e,q as qe,L as Be}from"./PaginatingTableToolbar.js";import{u as Ge}from"./ConfirmDialog.js";import{b as $e}from"./AddRoleMappingModal.js";import{F as He}from"./filter-icon.js";import{D as Me}from"./DropdownPanel.js";import{u as ze,C as We}from"./index.esm.js";import{a as Qe}from"./SelectControl.js";import{K as Ze}from"./KeycloakSelect.js";import{A as Xe}from"./FormGroup.js";import{S as Ye}from"./SelectOption.js";import{E as Je}from"./EmptyStateFooter.js";import{W as me}from"./warning-triangle-icon.js";import{L as ee}from"./Label.js";import{C as et,a as tt}from"./ChipGroup.js";import{R as st,u as rt}from"./RoutableTabs.js";/* empty css */import{a as te,b as se}from"./Tabs.js";import"./HelpItem.js";import"./ScrollForm.js";import"./GridItem.js";import"./ListItem.js";import"./SplitItem.js";import"./useLocaleSort.js";import"./Trans.js";import"./i18nInstance.js";import"./_baseRest.js";import"./grip-vertical-icon.js";import"./plus-circle-icon.js";import"./TextInputGroupUtilities.js";import"./DataListItemRow.js";import"./DataListItemCells.js";import"./DataListAction.js";import"./translationFormatter.js";import"./FormLabel.js";import"./PageHandler.js";import"./DynamicComponents.js";import"./ClientSelect.js";import"./FileUpload.js";import"./TextArea.js";import"./minus-circle-icon.js";import"./ActionListItem.js";import"./MultiLineInput.js";import"./PasswordControl.js";import"./CodeEditor.js";import"./TextControl.js";import"./KeycloakTextArea.js";import"./KeySelect.js";import"./useParams.js";import"./constants.js";import"./plus-icon.js";const at=({searchType:r,onSelect:i})=>{const{t:l}=k(),[m,f]=b.useState(!1),s=c=>e.jsx(oe,{onClick:()=>{i(c),f(!1)},children:l(`searchType.${c}`)},c),p=[s("default"),s("attribute")];return e.jsx(ae,{className:"keycloak__users__searchtype",onOpenChange:c=>f(c),toggle:c=>e.jsx(ie,{"data-testid":"user-search-toggle",ref:c,id:"toggle-id",onClick:()=>f(!m),icon:e.jsx(He,{}),children:l(`searchType.${r}`)}),isOpen:m,children:e.jsx(ne,{children:p})})};function it({activeFilters:r,setActiveFilters:i,profile:l,createAttributeSearchChips:m,searchUserWithAttributes:f}){const{t:s}=k(),{addAlert:p}=le(),[c,h]=b.useState(!1),N={name:"",displayName:"",value:""},{getValues:d,register:j,reset:U,formState:{errors:x},setValue:I,setError:g,clearErrors:o,control:y}=ze({mode:"onChange",defaultValues:N}),T=()=>r.userAttribute.some(a=>a.name===d().name),C=()=>{let a=!1;return d().name.length?r.userAttribute.some(t=>t.name===d().name)?g("name",{type:"conflict",message:s("searchUserByAttributeKeyAlreadyInUseError")}):a=!0:g("name",{type:"empty",message:s("searchUserByAttributeMissingKeyError")}),a},E=()=>{let a=!1;return d().value.length?a=!0:g("value",{type:"empty",message:s("searchUserByAttributeMissingValueError")}),a},F=()=>C()&&E(),v=()=>{var a,t;F()?(i({exact:d().exact,userAttribute:[...r.userAttribute,{...d()}]}),U({exact:d().exact})):((a=x.name)!=null&&a.message&&p(x.name.message,G.danger),(t=x.value)!=null&&t.message&&p(x.value.message,G.danger))},K=()=>{const a=[...r.userAttribute].filter(t=>t.name!==t.name);i({exact:d().exact,userAttribute:a})},A=()=>{var a;return l?e.jsx(Ze,{"data-testid":"search-attribute-name-select",variant:Qe.typeahead,onToggle:t=>h(t),selections:d().displayName,onSelect:t=>{I("displayName",t.toString()),T()?g("name",{type:"conflict"}):o("name")},isOpen:c,placeholderText:s("selectAttribute"),validated:x.name&&"error",maxHeight:300,...j("displayName",{required:!0,validate:C}),children:(a=l.attributes)==null?void 0:a.map(t=>e.jsx(Ye,{value:J(s,t.displayName,t.name),onClick:w=>{w.stopPropagation(),h(!1),I("name",t.name)},children:J(s,t.displayName,t.name)},t.name))}):e.jsx(Y,{id:"name",placeholder:s("keyPlaceholder"),validated:x.name&&"error",onKeyDown:t=>t.key==="Enter"&&v(),...j("name",{required:!0,validate:C})})};return e.jsxs(Se,{className:"user-attribute-search-form","data-testid":"user-attribute-search-form",children:[e.jsx(q,{className:"user-attribute-search-form-headline",children:e.jsx(L,{component:O.h2,children:s("selectAttributes")})}),e.jsx(ke,{isInline:!0,className:"user-attribute-search-form-alert",variant:"info",title:s("searchUserByAttributeDescription"),component:"h3"}),e.jsxs(q,{className:"user-attribute-search-form-key-value",children:[e.jsx("div",{className:"user-attribute-search-form-left",children:e.jsx(L,{component:O.h3,children:s("key")})}),e.jsx("div",{className:"user-attribute-search-form-right",children:e.jsx(L,{component:O.h3,children:s("value")})})]}),e.jsx("div",{className:"user-attribute-search-form-left",children:A()}),e.jsx("div",{className:"user-attribute-search-form-right",children:e.jsxs(ce,{children:[e.jsx(B,{children:e.jsx(Y,{id:"value",placeholder:s("valuePlaceholder"),validated:x.value&&"error",onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),v())},...j("value",{required:!0,validate:E})})}),e.jsx(B,{children:e.jsx(D,{"data-testid":"user-attribute-search-add-filter-button",variant:"control",icon:e.jsx(Te,{}),onClick:v,"aria-label":s("addToFilter")})})]})}),m(),e.jsx("div",{className:"pf-v5-u-pt-lg",children:e.jsx(We,{name:"exact",defaultValue:!1,control:y,render:({field:a})=>e.jsx(Ce,{id:"exact","data-testid":"exact",label:s("exactSearch"),isChecked:a.value,onChange:a.onChange})})}),e.jsxs(Xe,{className:"user-attribute-search-form-action-group",children:[e.jsx(D,{"data-testid":"search-user-attribute-btn",variant:"primary",type:"submit",isDisabled:!r.userAttribute.length,onClick:f,children:s("search")}),e.jsx(D,{variant:Fe.link,onClick:()=>{U(),K()},children:s("reset")})]})]})}function nt({searchDropdownOpen:r,setSearchDropdownOpen:i,realm:l,hasSelectedRows:m,toggleUnlockUsersDialog:f,searchType:s,setSearchType:p,searchUser:c,setSearchUser:h,activeFilters:N,setActiveFilters:d,refresh:j,profile:U,clearAllFilters:x,createAttributeSearchChips:I,searchUserWithAttributes:g}){const{t:o}=k(),[y,T]=b.useState(!1),{hasAccess:C}=re(),E=C("query-users"),F=()=>e.jsx(V,{children:e.jsxs(ce,{children:[e.jsx(B,{children:e.jsx(at,{searchType:s,onSelect:t=>{x(),p(t)}})}),s==="default"&&v(),s==="attribute"&&K()]})}),v=()=>e.jsx(V,{children:e.jsx(_e,{"data-testid":"table-search-input",placeholder:o("searchForUser"),"aria-label":o("search"),value:c,onSearch:(t,w,P)=>{h(P.haswords),j()},onKeyDown:t=>{if(t.key==="Enter"){const w=t.target;h(w.value),j()}},onClear:()=>{h(""),j()}})}),K=()=>e.jsxs(e.Fragment,{children:[e.jsx(Me,{"data-testid":"select-attributes-dropdown",buttonText:o("selectAttributes"),setSearchDropdownOpen:i,searchDropdownOpen:r,width:"15vw",children:e.jsx(it,{activeFilters:N,setActiveFilters:d,profile:U,createAttributeSearchChips:I,searchUserWithAttributes:()=>{g(),i(!1)}})}),e.jsx(D,{icon:e.jsx(qe,{}),variant:"control",onClick:()=>{g(),i(!1)},"aria-label":o("searchAttributes")})]}),A=l.bruteForceProtected?e.jsx(V,{children:e.jsx(ae,{onOpenChange:t=>T(t),toggle:t=>e.jsx(ie,{ref:t,isExpanded:y,variant:"plain",onClick:()=>T(!y),children:e.jsx(Ne,{})}),isOpen:y,shouldFocusToggleOnSelect:!0,children:e.jsx(ne,{children:e.jsx(oe,{component:"button",onClick:()=>{f(),T(!1)},children:o("unlockAllUsers")},"unlock")})})}):null,a=e.jsx(e.Fragment,{children:A});return e.jsxs(e.Fragment,{children:[F(),E?a:null]})}const ot=r=>{var m;const{t:i}=k(),{realm:l}=$();return e.jsxs(e.Fragment,{children:[e.jsxs(De,{to:xe({realm:l,id:r.id,tab:"settings"}),children:[r.username,e.jsx(lt,{user:r})]}),((m=r.attributes)==null?void 0:m.is_temporary_admin[0])==="true"&&e.jsx(ue,{content:i("temporaryAdmin"),children:e.jsx(me,{className:"pf-v5-u-ml-sm",id:"temporary-admin-label"})})]})},lt=({user:r})=>{var l;const{t:i}=k();return e.jsxs(e.Fragment,{children:[!r.enabled&&e.jsx(ee,{color:"red",icon:e.jsx(Ve,{}),children:i("disabled")}),((l=r.bruteForceStatus)==null?void 0:l.disabled)&&e.jsx(ee,{color:"orange",icon:e.jsx(me,{}),children:i("temporaryLocked")})]})},ct=r=>{const{t:i}=k();return e.jsxs(e.Fragment,{children:[!r.emailVerified&&e.jsx(ue,{content:i("notVerified"),children:e.jsx(Pe,{className:"keycloak__user-section__email-verified"})})," ",_()(r.email)]})};function ut(){const{adminClient:r}=be(),{t:i}=k(),{addAlert:l,addError:m}=le(),{realm:f,realmRepresentation:s}=$();Ue();const[p,c]=b.useState({}),[h,N]=b.useState(""),[d,j]=b.useState([]),[U,x]=b.useState("default"),[I,g]=b.useState(!1),[o,y]=b.useState({exact:!1,userAttribute:[]}),[T,C]=b.useState({}),[E,F]=b.useState(""),[v,K]=b.useState(0),A=()=>K(v+1);Ie(async()=>{var n;try{return await Promise.all([fe(r),r.users.getProfile()])}catch(u){if(u instanceof Re&&((n=u==null?void 0:u.response)==null?void 0:n.status)===403)return[{},{}];throw u}},([n,u])=>{c(n),C(u)},[]);const a=async(n,u,Q)=>{const S={first:n,max:u,q:E},R=Q||h||"";
1if(R&&(S.search=R),o.exact&&(S.exact=!0),!P&&!(S.search||S.q))return[];try{return await $e(r,{briefRepresentation:!0,...S})}catch(Z){return p.userProfileProvidersEnabled?m("noUsersFoundErrorStorage",Z):m("noUsersFoundError",Z),[]}},[t,w]=Ge({titleKey:"unlockAllUsers",messageKey:"unlockUsersConfirm",continueButtonLabel:"unlock",onConfirm:async()=>{try{await r.attackDetection.delAll(),A(),l(i("unlockUsersSuccess"),G.success)}catch(n){m("unlockUsersError",n)}}});if(!p||!s)return e.jsx(Ee,{});const P=!p.userProfileProvidersEnabled,H=()=>{y({exact:!1,userAttribute:[]}),N(""),F(""),A()},M=n=>n.userAttribute.map(u=>`${u.name}:${u.value}`).join(" "),de=()=>{const n=M(o);F(n),A()},z=()=>e.jsx(je,{children:o.userAttribute.length>0&&e.jsx(e.Fragment,{children:Object.values(o.userAttribute).map(n=>e.jsx(et,{className:"pf-v5-u-mt-md pf-v5-u-mr-md","data-testid":"user-attribute-search-chips-group",categoryName:n.displayName.length?n.displayName:n.name,isClosable:!0,onClick:u=>{u.stopPropagation();const S={userAttribute:[...o.userAttribute].filter(R=>R.name!==n.name),exact:o.exact};y(S),F(M(S)),A()},children:e.jsx(tt,{isReadOnly:!0,children:n.value},n.name)},n.name))})}),W=()=>e.jsx(nt,{searchDropdownOpen:I,setSearchDropdownOpen:g,realm:s,hasSelectedRows:d.length===0,toggleUnlockUsersDialog:t,searchType:U,setSearchType:x,searchUser:h,setSearchUser:N,activeFilters:o,setActiveFilters:y,refresh:A,profile:T,clearAllFilters:H,createAttributeSearchChips:z,searchUserWithAttributes:de}),pe=()=>{if(o.userAttribute.length)return e.jsxs("div",{className:"user-attribute-search-form-subtoolbar",children:[e.jsx(V,{children:z()}),e.jsx(V,{children:e.jsx(D,{variant:"link",onClick:()=>{H()},children:i("clearAllFilters")})})]})};return e.jsxs(e.Fragment,{children:[e.jsx(w,{}),e.jsx(Oe,{isSearching:h!==""||o.userAttribute.length!==0,loader:a,isPaginated:!0,ariaLabelKey:"titleUsers",canSelectAll:!0,onSelect:n=>j([...n]),emptyState:P?e.jsx(Be,{message:i("noUsersFound"),instructions:i("emptyInstructions")}):e.jsxs(e.Fragment,{children:[e.jsx(we,{children:e.jsx(Ke,{children:W()})}),e.jsx(Je,{"data-testid":"empty-state",variant:"lg",children:e.jsx(q,{className:"kc-search-users-text",children:e.jsx(L,{children:i("searchForUserDescription")})})})]}),toolbarItem:W(),subToolbar:pe(),actionResolver:n=>[],columns:[{name:"username",displayKey:"username",cellRenderer:ot},{name:"email",displayKey:"email",cellRenderer:ct},{name:"lastName",displayKey:"lastName",cellFormatters:[_()]},{name:"firstName",displayKey:"firstName",cellFormatters:[_()]}]},v)]})}function ps(){const{t:r}=k(),{realm:i}=$(),{hasAccess:l}=re(),f=ge()(ye.AdminFineGrainedAuthz)&&l("manage-authorization","manage-users","manage-clients"),s=h=>rt(X({realm:i,tab:h})),p=s("list"),c=s("permissions");return e.jsxs(e.Fragment,{children:[e.jsx(he,{titleKey:"titleUsers",subKey:"usersExplain",helpUrl:Ae.usersUrl,divider:!1}),e.jsx(Le,{"data-testid":"users-page",variant:"light",className:"pf-v5-u-p-0",children:e.jsxs(st,{"data-testid":"user-tabs",defaultLocation:X({realm:i,tab:"list"}),isBox:!0,mountOnEnter:!0,children:[e.jsx(te,{id:"list","data-testid":"listTab",title:e.jsx(se,{children:r("userList")}),...p,children:e.jsx(ut,{})}),f&&e.jsx(te,{id:"permissions","data-testid":"permissionsTab",title:e.jsx(se,{children:r("permissions")}),...c,children:e.jsx(ve,{type:"users"})})]})})]})}export{ps as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.