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

theme.keycloak.v2.admin.resources.assets.UserForm-PSfSn7pK.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as t,jsxs as u,Fragment as k}from"react/jsx-runtime";import{u as I,b3 as E,c as ie,w as S,i as v,L as T,ei as ne,dX as se,bQ as oe,bh as j,eo as le,a as R,v as ce,b6 as de,f as ue,dt as me,F as pe,ac as f,am as V,ad as y,ep as be,y as A,dQ as fe,ai as he,a4 as Ae,ae as ge,bb as ke,bc as x,ag as ye,ah as ve,aq as Ie,A as Le,h as we,dv as Ge,k as D}from"./main-C7ps2lmX.js";import{useState as h,useEffect as qe}from"react";import{D as Ce}from"./SwitchControl-C_9Y74oV.js";import{F as Oe}from"./FormAccess-DyLNkc18.js";import{G as Fe}from"./GroupPickerDialog-C09EjRTA.js";import{u as Ue}from"./useFormatDate-X7HJ5iYO.js";const je=({user:r})=>{const{adminClient:n}=I(),e=E(),{realm:o}=ie(),[s,l]=h();return S(()=>e.hasAccess("view-realm")?n.components.findOne({id:r.federationLink||r.origin}):n.userStorageProvider.name({id:r.federationLink||r.origin}),l,[]),s?e.hasAccess("view-realm")?t(v,{variant:"link",component:m=>t(T,{...m,to:ne({id:s.id,providerId:s.providerId,realm:o})}),children:s.name}):t("span",{children:s.name}):null};function Ve(r){const n={};Object.entries(r.attributes||{}).forEach(([o,s])=>n[se(o)]=s);const e=oe(r.unmanagedAttributes);return{...r,attributes:n,unmanagedAttributes:e}}function Ne(r){const n=r.username?.trim(),e=Array.isArray(r.attributes)?j(r.attributes):Object.fromEntries(Object.entries(r.attributes||{}).map(([s,l])=>[le(s),l])),o=Array.isArray(r.unmanagedAttributes)?j(r.unmanagedAttributes):r.unmanagedAttributes;for(const s in o)if(e&&Object.hasOwn(e,s))throw Error(`Attribute ${s} is a managed attribute and is already available from the user details.`);return{...r,username:n,attributes:{...o,...e},unmanagedAttributes:void 0}}function Pe(r={},n={}){return Object.fromEntries(Object.entries(r).filter(([e])=>!Object.hasOwn(n,e)))}const xe=({name:r,label:n,help:e})=>{const{adminClient:o}=I(),{t:s}=R(),[l,m]=h([]);return S(()=>o.authenticationManagement.getRequiredActions(),c=>{const p=c.filter(a=>a.enabled);m(p)},[]),t(ce,{name:r,label:s(n),labelIcon:s(e),controller:{defaultValue:[]},isScrollable:!0,maxMenuHeight:"375px",variant:de.typeaheadMulti,chipGroupProps:{numChips:3},placeholderText:s("requiredActionPlaceholder"),menuAppendTo:"parent",options:l.map(({alias:c,name:p})=>({key:c,value:p||c}))})},Be=({form:r,realm:n,user:e,bruteForce:{isBruteForceProtected:o,isLocked:s}={isBruteForceProtected:!1,isLocked:!1},userProfileMetadata:l,save:m,onGroupsUpdate:c})=>{const{adminClient:p}=I(),{t:a}=R(),H=Ue(),{addAlert:L,addError:w}=ue(),{hasAccess:G}=E(),M=G("manage-users"),N=G("view-realm"),{whoAmI:P}=me(),B=P.getLocale(),{handleSubmit:z,setValue:q,watch:Q,control:K,reset:W,formState:C}=r,{errors:X}=C,_=Q("username"),[b,O]=h([]),[F,g]=h(!1),[U,$]=h(s);qe(()=>{q("requiredActions",e?.requiredActions||[])},[e,q]);const J=async()=>{try{await p.attackDetection.del({id:e.id}),L(a("unlockSuccess"),D.success)}catch(i){w("unlockError",i)}},Y=i=>{O(b.filter(d=>d.name!==i)),c?.(b)},Z=async i=>{O([...b,...i]),c?.([...b,...i])},ee=async i=>{i.forEach(async ae=>{try{await p.users.addToGroup({id:e.id,groupId:ae.id}),L(a("addedGroupMembership"),D.success)}catch(re){w("addedGroupMembershipError",re)}})},te=()=>{g(!F)};return t(Oe,{isHorizontal:!0,onSubmit:z(m),role:"query-users",fineGrainedAccess:e?.access?.manage,className:"pf-v5-u-mt-lg",children:u(pe,{...r,children:[F&&t(Fe,{type:"selectMany",text:{title:"selectGroups",ok:"join"},canBrowse:M,onConfirm:i=>{e?.id?ee(i||[]):Z(i||[]),g(!1)},onClose:()=>g(!1),filterGroups:b}),e?.id&&u(k,{children:[t(f,{label:a("id"),fieldId:"kc-id",isRequired:!0,children:t(V,{id:e.id,"aria-label":a("userID"),value:e.id,readOnly:!0})}),t(f,{label:a("createdAt"),fieldId:"kc-created-at",isRequired:!0,children:t(V,{value:H(new Date(e.createdTimestamp)),id:"kc-created-at",readOnly:!0})})]}),t(xe,{name:"requiredActions",label:"requiredUserActions",help:"requiredUserActionsHelp"}),(e?.federationLink||e?.origin)&&N&&t(f,{label:a("federationLink"),labelIcon:t(y,{helpText:a("federationLinkHelp"),fieldLabelId:"federationLink"}),children:t(je,{user:e})}),l?u(k,{children:[t(Ce,{name:"emailVerified",label:a("emailVerified"),labelIcon:a("emailVerifiedHelp")}),t(be,{form:r,userProfileMetadata:l,hideReadOnly:!e,supportedLocales:n.supportedLocales||[],currentLocale:B,t:(i,d)=>a(i,d)})]}):u(k,{children:[!n.registrationEmailAsUsername&&t(A,{name:"username",label:a("username"),readOnly:!!e?.id&&!n.editUsernameAllowed&&n.editUsernameAllowed!==void 0,rules:{required:a("required")}}),t(A,{name:"email",label:a("email"),type:"email",rules:{pattern:{value:fe,message:a("emailInvalid")}}}),t(he,{name:"emailVerified",label:a("emailVerified"),labelIcon:a("emailVerifiedHelp"),labelOn:a("yes"),labelOff:a("no")}),t(A,{name:"firstName",label:a("firstName")}),t(A,{name:"lastName",label:a("lastName")})]}),o&&t(f,{label:a("temporaryLocked"),fieldId:"temporaryLocked",labelIcon:t(y,{helpText:a("temporaryLockedHelp"),fieldLabelId:"temporaryLocked"}),children:t(Ae,{"data-testid":"user-locked-switch",id:"temporaryLocked",onChange:(i,d)=>{J(),$(d),m({enabled:!d})},isChecked:U,isDisabled:!U,label:a("on"),labelOff:a("off")})}),!e?.id&&u(f,{label:a("groups"),fieldId:"kc-groups",labelIcon:t(y,{helpText:a("groupsHelp"),fieldLabelId:"groups"}),children:[t(ge,{name:"groups",defaultValue:[],control:K,render:()=>u(ke,{children:[t(x,{children:t(ye,{categoryName:" ",children:b.map(i=>t(ve,{onClick:()=>Y(i.name),children:i.path},i.id))})}),t(x,{children:t(v,{id:"kc-join-groups-button",onClick:te,variant:"secondary","data-testid":"join-groups-button",children:a("joinGroups")})})]})}),X.requiredActions&&t(Ie,{message:a("required")})]}),u(Le,{children:[t(we,{formState:C,"data-testid":e?.id?"save-user":"create-user",isDisabled:!e?.id&&!_&&n.registrationEmailAsUsername===!1,allowNonDirty:!0,allowInvalid:!0,children:e?.id?a("save"):a("create")}),t(v,{"data-testid":"cancel-create-user",variant:"link",onClick:e?.id?()=>W(Ve(e)):void 0,component:e?.id?void 0:i=>t(T,{...i,to:Ge({realm:n.realm})}),children:e?.id?a("revert"):a("cancel")})]})]})})};export{je as F,xe as R,Be as U,Ve as a,Pe as f,Ne as t};
//# sourceMappingURL=UserForm-PSfSn7pK.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy