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

theme.keycloak.v2.admin.resources.assets.form-state-bdbf39d3.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{au as M,c as B,r as f,q as K,g as C,j as s,B as S,L as le,dl as ce,u as k,a as j,F as p,h as b,C as T,cS as de,b as me,d as ue,cX as pe,S as H,O as he,A as D,b5 as xe,aD as fe}from"./index-831988f6.js";import{F as je}from"./FormAccess-589a8032.js";import{G as ge}from"./GroupPickerDialog-71e86661.js";import{K as y}from"./KeycloakTextInput-ead44014.js";import{u as ve}from"./useFormatDate-abfcb505.js";import{u as ye,F as be}from"./useIsFeatureEnabled-d2f044ea.js";import{S as ke}from"./ScrollForm-4efa2caf.js";import{l as Ie,f as F}from"./user-section-9e42f5e8.js";import{C as Ce}from"./Checkbox-d44d2684.js";import{R as Te}from"./Radio-94b05d7e.js";import{S as $,b as _,a as Ae,C as Se,c as Fe}from"./Select-9c61d949.js";import{K as Le}from"./KeycloakTextArea-3e2614e3.js";import{F as Oe,A as qe}from"./Form-bd3cf98e.js";import{T as we}from"./Text-2a2c2dcc.js";const Ge=({user:e})=>{const t=M(),{realm:o}=B(),[n,c]=f.useState();return K(()=>t.hasAccess("view-realm")?C.components.findOne({id:e.federationLink||e.origin}):C.userStorageProvider.name({id:e.federationLink||e.origin}),c,[]),n?s.jsx(S,{variant:"link",isDisabled:!t.hasAccess("view-realm"),component:h=>s.jsx(le,{...h,to:ce({id:n.id,providerId:n.providerId,realm:o})}),children:n.name}):null},Ne=e=>Object.keys(e.required||{}).length!==0||(e.validations?.length?.min||0)>0,L=({children:e,...t})=>{const{t:o}=k("users"),n=t.annotations?.inputHelperTextBefore,{formState:{errors:c}}=j();return s.jsx(p,{label:Ie(t,o)||"",fieldId:t.name,isRequired:Ne(t),validated:c.username?"error":"default",helperTextInvalid:o("common:required"),labelIcon:n?s.jsx(b,{helpText:n,fieldLabelId:t.name}):void 0,children:e},t.name)},E=e=>{const{control:t}=j(),n=(e.annotations?.inputType).includes("multiselect"),c=n?Ce:Te,h=(e.validations?.options).options||[];return s.jsx(L,{...e,children:s.jsx(T,{name:F(e),control:t,defaultValue:"",render:({field:a})=>s.jsx(s.Fragment,{children:h.map(r=>s.jsx(c,{id:r,"data-testid":r,label:r,value:r,isChecked:a.value.includes(r),onChange:()=>{n?a.value.includes(r)?a.onChange(a.value.filter(d=>d!==r)):a.onChange([...a.value,r]):a.onChange([r])},readOnly:e.readOnly},r))})})})},P=e=>{const{t}=k("users"),{control:o}=j(),[n,c]=f.useState(!1),h=e.annotations?.inputType==="multiselect",a=(e.validations?.options).options||[];return s.jsx(L,{...e,children:s.jsx(T,{name:F(e),defaultValue:"",control:o,render:({field:r})=>s.jsx($,{toggleId:e.name,onToggle:d=>c(d),onSelect:(d,m)=>{const i=m.toString();h?r.value.includes(i)?r.onChange(r.value.filter(u=>u!==i)):r.onChange([...r.value,i]):(r.onChange(i),c(!1))},selections:r.value?r.value:t("common:choose"),variant:h?"typeaheadmulti":"single","aria-label":t("common:selectOne"),isOpen:n,readOnly:e.readOnly,children:a.map(d=>s.jsx(_,{selected:r.value===d,value:d,children:d},d))})})})},Re=e=>{const{register:t}=j();return s.jsx(L,{...e,children:s.jsx(Le,{id:e.name,"data-testid":e.name,...t(F(e)),cols:e.annotations?.inputTypeCols,rows:e.annotations?.inputTypeRows,readOnly:e.readOnly})})},x=e=>{const{register:t}=j(),o=e.annotations?.inputType,n=o?.startsWith("html")?o.substring(4+2):"text";return s.jsx(L,{...e,children:s.jsx(de,{id:e.name,"data-testid":e.name,type:n,placeholder:e.annotations?.inputTypePlaceholder,readOnly:e.readOnly,...t(F(e))})})};function es(e){return!!e.responseData.errors}function ss(e){return e.responseData.errors?.map(t=>t.errorMessage).join(`
`)||""}const Ue={text:x,textarea:Re,select:P,"select-radiobuttons":E,multiselect:P,"multiselect-checkboxes":E,"html5-email":x,"html5-tel":x,"html5-url":x,"html5-number":x,"html5-range":x,"html5-datetime-local":x,"html5-date":x,"html5-month":x,"html5-time":x},De=({config:e,roles:t=["admin"]})=>{const{t:o}=k("realm-settings");return s.jsx(ke,{sections:[{name:""},...e.groups||[]].map(n=>({title:n.displayHeader||n.name||o("general"),panel:s.jsxs(Oe,{children:[n.displayDescription&&s.jsx(we,{className:"pf-u-pb-lg",children:n.displayDescription}),e.attributes?.map(c=>s.jsx(f.Fragment,{children:(c.group||"")===n.name&&s.jsx(Ee,{attribute:c,roles:t})},c.name))]})}))})},Ee=({attribute:e,roles:t})=>{const o=e.annotations?.inputType||"text",n=Ue[o];return s.jsx(n,{...e,roles:t})},Pe=({name:e,label:t,help:o})=>{const{t:n}=k("users"),{control:c}=j(),[h,a]=f.useState(!1),[r,d]=f.useState([]);return K(()=>C.authenticationManagement.getRequiredActions(),m=>{const i=m.filter(u=>u.enabled);d(i)},[]),s.jsx(p,{label:n(t),labelIcon:s.jsx(b,{helpText:n(o),fieldLabelId:"resetActions"}),fieldId:"actions",children:s.jsx(T,{name:e,defaultValue:[],control:c,render:({field:m})=>s.jsx($,{maxHeight:375,toggleId:`${e}-actions`,variant:Ae.typeaheadMulti,chipGroupProps:{numChips:3},placeholderText:n("requiredActionPlaceholder"),menuAppendTo:"parent",onToggle:i=>a(i),isOpen:h,selections:m.value,onSelect:(i,u)=>m.onChange(m.value.find(g=>g===u)?m.value.filter(g=>g!==u):[...m.value,u]),onClear:i=>{i.stopPropagation(),m.onChange([])},typeAheadAriaLabel:n("resetActions"),children:r.map(({alias:i,name:u})=>s.jsx(_,{value:i,"data-testid":`${i}-option`,children:u},i))})})})},V=()=>{const{t:e}=k("users"),{control:t}=j();return s.jsx(p,{label:e("emailVerified"),fieldId:"kc-email-verified",helperTextInvalid:e("common:required"),labelIcon:s.jsx(b,{helpText:e("users-help:emailVerified"),fieldLabelId:"users:emailVerified"}),children:s.jsx(T,{name:"emailVerified",defaultValue:!1,control:t,render:({field:o})=>s.jsx(H,{"data-testid":"email-verified-switch",id:"kc-user-email-verified",onChange:n=>o.onChange(n),isChecked:o.value,label:e("common:yes"),labelOff:e("common:no")})})})},as=({user:e,realm:t,bruteForce:{isBruteForceProtected:o,isLocked:n}={isBruteForceProtected:!1,isLocked:!1},save:c,onGroupsUpdate:h})=>{const{t:a}=k("users"),{realm:r}=B(),d=ve(),m=ye(),i=me(),{addAlert:u,addError:g}=ue(),{hasAccess:q}=M(),z=q("manage-users"),W=q("view-realm"),{handleSubmit:X,register:A,watch:J,control:Q,reset:Y,formState:{errors:I}}=j(),Z=J("username"),[v,w]=f.useState([]),[G,O]=f.useState(!1),[N,ee]=f.useState(n),se=async()=>{try{await C.attackDetection.del({id:e.id}),u(a("unlockSuccess"),D.success)}catch(l){g("users:unlockError",l)}},ae=l=>{w(v.filter(U=>U.name!==l)),h?.(v)},te=async l=>{w([...v,...l]),h?.([...v,...l])},ne=async l=>{l.forEach(async oe=>{try{await C.users.addToGroup({id:e.id,groupId:oe.id}),u(a("users:addedGroupMembership"),D.success)}catch(ie){g("users:addedGroupMembershipError",ie)}})},re=()=>{O(!G)},R=m(be.DeclarativeUserProfile)&&t?.attributes?.userProfileEnabled==="true";return s.jsxs(je,{isHorizontal:!0,onSubmit:X(c),role:"query-users",fineGrainedAccess:e?.access?.manage,className:"pf-u-mt-lg",children:[G&&s.jsx(ge,{type:"selectMany",text:{title:"users:selectGroups",ok:"users:join"},canBrowse:z,onConfirm:l=>{e?.id?ne(l||[]):te(l||[]),O(!1)},onClose:()=>O(!1),filterGroups:v}),R&&s.jsx(V,{}),e?.id&&s.jsxs(s.Fragment,{children:[s.jsx(p,{label:a("common:id"),fieldId:"kc-id",isRequired:!0,children:s.jsx(y,{id:e.id,"aria-label":a("userID"),value:e.id,type:"text",isReadOnly:!0})}),s.jsx(p,{label:a("createdAt"),fieldId:"kc-created-at",isRequired:!0,children:s.jsx(y,{value:d(new Date(e.createdTimestamp)),type:"text",id:"kc-created-at","aria-label":a("createdAt"),name:"createdTimestamp",isReadOnly:!0})})]}),s.jsx(Pe,{name:"requiredActions",label:"requiredUserActions",help:"users-help:requiredUserActions"}),(e?.federationLink||e?.origin)&&W&&s.jsx(p,{label:a("federationLink"),labelIcon:s.jsx(b,{helpText:a("users-help:federationLink"),fieldLabelId:"users:federationLink"}),children:s.jsx(Ge,{user:e})}),R?s.jsx(De,{config:e?.userProfileMetadata}):s.jsxs(s.Fragment,{children:[!t?.registrationEmailAsUsername&&s.jsx(p,{label:a("username"),fieldId:"kc-username",isRequired:!0,validated:I.username?"error":"default",helperTextInvalid:a("common:required"),children:s.jsx(y,{id:"kc-username",isReadOnly:!!e?.id&&!t?.editUsernameAllowed&&t?.editUsernameAllowed!==void 0,...A("username")})}),s.jsx(p,{label:a("email"),fieldId:"kc-email",validated:I.email?"error":"default",helperTextInvalid:a("users:emailInvalid"),children:s.jsx(y,{type:"email",id:"kc-email","data-testid":"email-input",...A("email",{pattern:pe})})}),s.jsx(V,{}),s.jsx(p,{label:a("firstName"),fieldId:"kc-firstName",validated:I.firstName?"error":"default",helperTextInvalid:a("common:required"),children:s.jsx(y,{"data-testid":"firstName-input",id:"kc-firstName",...A("firstName")})}),s.jsx(p,{label:a("lastName"),fieldId:"kc-lastName",validated:I.lastName?"error":"default",children:s.jsx(y,{"data-testid":"lastName-input",id:"kc-lastname","aria-label":a("lastName"),...A("lastName")})})]}),o&&s.jsx(p,{label:a("temporaryLocked"),fieldId:"temporaryLocked",labelIcon:s.jsx(b,{helpText:a("users-help:temporaryLocked"),fieldLabelId:"users:temporaryLocked"}),children:s.jsx(H,{"data-testid":"user-locked-switch",id:"temporaryLocked",onChange:l=>{se(),ee(l)},isChecked:N,isDisabled:!N,label:a("common:on"),labelOff:a("common:off")})}),!e?.id&&s.jsx(p,{label:a("common:groups"),fieldId:"kc-groups",validated:I.requiredActions?"error":"default",helperTextInvalid:a("common:required"),labelIcon:s.jsx(b,{helpText:a("users-help:groups"),fieldLabelId:"groups"}),children:s.jsx(T,{name:"groups",defaultValue:[],control:Q,render:()=>s.jsxs(he,{children:[s.jsx(Se,{categoryName:" ",children:v.map(l=>s.jsx(Fe,{onClick:()=>ae(l.name),children:l.path},l.id))}),s.jsx(S,{id:"kc-join-groups-button",onClick:re,variant:"secondary","data-testid":"join-groups-button",children:a("users:joinGroups")})]})})}),s.jsxs(qe,{children:[s.jsx(S,{"data-testid":e?.id?"save-user":"create-user",isDisabled:!e?.id&&!Z&&!t?.registrationEmailAsUsername,variant:"primary",type:"submit",children:e?.id?a("common:save"):a("common:create")}),s.jsx(S,{"data-testid":"cancel-create-user",onClick:()=>e?.id?Y(e):i(`/${r}/users`),variant:"link",children:e?.id?a("common:revert"):a("common:cancel")})]})]})};function ts(e){const t=xe(e.attributes);return{...e,attributes:t}}function ns(e){const t=e.username?.trim(),o=fe(e.attributes);return{...e,username:t,attributes:o}}export{Ge as F,Pe as R,as as U,ts as a,es as i,ns as t,ss as u};
//# sourceMappingURL=form-state-bdbf39d3.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy