theme.keycloak.v2.admin.resources.assets.DetailOrganization-C57a_dvC.js Maven / Gradle / Ivy
import{jsx as e,jsxs as v,Fragment as ae}from"react/jsx-runtime";import{u as z,c as W,d as ue,a as T,f as D,ab as Z,aj as Q,B as U,dE as ge,ae as ne,D as G,g as _,M as re,q as ie,h as J,i as A,F as $,r as oe,y as B,P as O,a2 as q,J as pe,K as se,N as he,L as be,bx as fe,w as X,a3 as ye,ac as ve,ad as ke,V as Ce,c0 as Ie,c1 as Pe,ag as Se,ah as we,c2 as Me,c3 as ze,W as Te,aq as De,U as ee,Q as Ee,v as Ae,aJ as N,S as Le,e as Oe,dG as Fe,a4 as xe,A as Ke,dF as Ve,bQ as Ue}from"./main-C7ps2lmX.js";import{F as Re}from"./FormAccess-DyLNkc18.js";import{A as Be}from"./AttributeForm-CdFbESi6.js";import{R as Ne,u as Ge}from"./RoutableTabs-T8JTILEW.js";import{u as le}from"./useParams-B67lSY02.js";import{V as qe}from"./ViewHeader-B7eeFzFA.js";import{u as H}from"./ConfirmDialog-hx7XKLbN.js";import{useState as M,useRef as He,useCallback as je,useEffect as We}from"react";import{L as j}from"./PaginatingTableToolbar-Cjsz5Jh4.js";import{K as ce}from"./KeycloakDataTable-DbY4la1D.js";import{M as Qe}from"./MembersModal-CiM-HKQc.js";import{u as F}from"./useToggle-K3Kx99tM.js";import{O as _e,c as Je}from"./OrganizationForm-CdHlhcGH.js";import{D as te}from"./SwitchControl-C_9Y74oV.js";import{d as $e}from"./debounce-DTNSlfWG.js";import{a as K,b as V}from"./Tabs-CMdqT4Cg.js";import"react-dom";import"./copy-icon-ACZmDH8e.js";import"./KeyValueInput-B0tpVTv9.js";import"./KeySelect-jKxsKqdI.js";import"./EmptyStateFooter-DqmBOP2I.js";import"./PageHandler-P2CRgucq.js";import"./DynamicComponents-DvaX3FJx.js";import"./ClientSelect-B9UqjyP6.js";import"./FileUpload-CumNwlWc.js";import"./CodeEditor-C-nZkUJx.js";import"./EmptyStateActions-DWNUFByn.js";import"./GroupPickerDialog-C09EjRTA.js";import"./DataListItemRow-BC0LurDd.js";import"./FlexItem-BzZfUnQ1.js";import"./MultiLineInput-DiPNQ1LE.js";import"./AddRoleMappingModal-DW8o4W0z.js";import"./filter-icon-DO0QNij3.js";import"./Td-D2hVFK0Z.js";import"./grip-vertical-icon-BxF7V59o.js";import"./PageList-s9OtSlkz.js";import"./_baseFlatten-eIEJR-AJ.js";const Xe=({save:t})=>{const{adminClient:a}=z(),{realm:l}=W(),g=ue(),{t:r}=T(),{addAlert:n,addError:c}=D(),m=Z({name:"id"}),o=Z({name:"name"}),{setValue:p}=Q(),[f,u]=H({titleKey:"disableConfirmOrganizationTitle",messageKey:"disableConfirmOrganization",continueButtonLabel:"disable",onConfirm:()=>{p("enabled",!1),t()}}),[y,i]=H({titleKey:"organizationDelete",messageKey:"organizationDeleteConfirm",continueButtonLabel:"delete",continueButtonVariant:U.danger,onConfirm:async()=>{try{await a.organizations.delById({id:m}),n(r("organizationDeletedSuccess")),g(ge({realm:l}))}catch(s){c("organizationDeleteError",s)}}});return e(ne,{name:"enabled",render:({field:{value:s,onChange:P}})=>v(ae,{children:[e(i,{}),e(u,{}),e(qe,{titleKey:o||"",divider:!1,dropdownItems:[e(G,{"data-testid":"delete-client",onClick:y,children:r("delete")},"delete")],isEnabled:s,onToggle:S=>{S?(P(S),t()):f()}})]})})},Ye=({orgId:t,onClose:a})=>{const{adminClient:l}=z(),{addAlert:g,addError:r}=D(),{t:n}=T(),c=_(),{handleSubmit:m,formState:o}=c,p=async f=>{try{const u=new FormData;for(const y in f)u.append(y,f[y]);await l.organizations.invite({orgId:t},u),g(n("inviteSent")),a()}catch(u){r("inviteSentError",u)}};return e(re,{variant:ie.small,title:n("inviteMember"),isOpen:!0,onClose:a,actions:[e(J,{formState:o,"data-testid":"save",form:"form",allowInvalid:!0,allowNonDirty:!0,children:n("send")},"confirm"),e(A,{id:"modal-cancel","data-testid":"cancel",variant:U.link,onClick:a,children:n("cancel")},"cancel")],children:e($,{...c,children:v(oe,{id:"form",onSubmit:m(p),children:[e(B,{name:"email",label:n("email"),rules:{required:n("required")},autoFocus:!0}),e(B,{name:"firstName",label:n("firstName")}),e(B,{name:"lastName",label:n("lastName")})]})})})},Ze=t=>{const{realm:a}=W();return e(be,{to:fe({realm:a,id:t.id,tab:"settings"}),children:t.username})},et=()=>{const{t}=T(),{adminClient:a}=z(),{id:l}=le(),{addAlert:g,addError:r}=D(),[n,c]=M(0),m=()=>c(n+1),[o,p]=F(),[f,u]=F(),[y,i]=F(),[s,P]=M([]),S=(b,k,R)=>a.organizations.listMembers({orgId:l,first:b,max:k,search:R}),h=async b=>{try{await Promise.all(b.map(k=>a.organizations.delMember({orgId:l,userId:k.id}))),g(t("organizationUsersLeft",{count:b.length}))}catch(k){r("organizationUsersLeftError",k)}m()};return v(O,{variant:"light",children:[f&&e(Qe,{membersQuery:async()=>await a.organizations.listMembers({orgId:l}),onAdd:async b=>{try{await Promise.all(b.map(k=>a.organizations.addMember({orgId:l,userId:k.id}))),g(t("organizationUsersAdded",{count:b.length}))}catch(k){r("organizationUsersAddedError",k)}},onClose:()=>{u(),m()}}),y&&e(Ye,{orgId:l,onClose:i}),e(ce,{loader:S,isPaginated:!0,ariaLabelKey:"membersList",searchPlaceholderKey:"searchMember",onSelect:b=>P([...b]),canSelectAll:!0,toolbarItem:v(ae,{children:[e(q,{children:e(pe,{onOpenChange:p,toggle:b=>e(se,{ref:b,onClick:p,isExpanded:o,variant:"primary",children:t("addMember")}),isOpen:o,children:v(he,{children:[e(G,{onClick:()=>{u(),p()},children:t("addRealmUser")}),e(G,{onClick:()=>{i(),p()},children:t("inviteMember")})]})})}),e(q,{children:e(A,{variant:"plain",isDisabled:s.length===0,onClick:()=>h(s),children:t("removeMember")})})]}),actions:[{title:t("remove"),onRowClick:async b=>{await h([b])}}],columns:[{name:"username",cellRenderer:Ze},{name:"email"},{name:"firstName"},{name:"lastName"}],emptyState:e(j,{message:t("emptyMembers"),instructions:t("emptyMembersInstructions"),secondaryActions:[{text:t("addRealmUser"),onClick:u},{text:t("inviteMember"),onClick:i}]})},n)]})},tt=({name:t,label:a,helpText:l,defaultValue:g,isRequired:r,variant:n="typeahead",isDisabled:c})=>{const{adminClient:m}=z(),{t:o}=T(),{control:p,getValues:f,formState:{errors:u}}=Q(),y=f(t),[i,s,P]=F(),[S,h]=M(""),b=He(),[k,R]=M([]),[x,Y]=M(""),de=je($e(Y,1e3),[]);X(async()=>{const d={max:20};return x&&(d.search=x),(await m.identityProviders.find(d)).filter(C=>!C.config?.["kc.org"])},R,[x]);const me=d=>{const w=d.map(C=>e(ee,{value:C.alias,selected:y?.includes(C.alias),children:C.alias},C.alias));return w.length===0?e(ee,{value:"",children:o("noResultsFound")}):w};return k?v(ve,{label:o(a),isRequired:r,labelIcon:l?e(ke,{helpText:l,fieldLabelId:a}):void 0,fieldId:t,children:[e(ne,{name:t,defaultValue:g,control:p,rules:{validate:d=>r&&d.filter(w=>w!==void 0).length===0?o("required"):void 0},render:({field:d})=>e(Ce,{id:t,onOpenChange:s,toggle:w=>e(se,{"data-testid":t,ref:w,variant:"typeahead",onClick:s,isExpanded:i,isFullWidth:!0,isDisabled:c,status:u[t]?"danger":void 0,children:v(Ie,{isPlain:!0,children:[e(Pe,{value:S||d.value,onClick:s,onChange:(C,I)=>{P(!0),h(I),de(I)},autoComplete:"off",innerRef:b,placeholderText:o("selectAUser"),...d.value&&{"aria-activedescendant":d.value},role:"combobox",isExpanded:i,"aria-controls":"select-create-typeahead-listbox",children:n==="typeaheadMulti"&&Array.isArray(d.value)&&e(Se,{"aria-label":"Current selections",children:d.value.map((C,I)=>e(we,{onClick:E=>{E.stopPropagation(),d.onChange(d.value.filter(L=>L!==C))},children:C},I))})}),e(Me,{children:!!x&&e(A,{variant:"plain",onClick:()=>{h(""),Y(""),d.onChange([]),b?.current?.focus()},"aria-label":o("clear"),children:e(ze,{"aria-hidden":!0})})})]})}),isOpen:i,selected:d.value,onSelect:(w,C)=>{const I=C?.toString();if(n!=="typeaheadMulti"){const E=d.value.includes(I);E?d.onChange([]):d.onChange([I]),h(E?"":I||""),P(!1)}else{const E=d.value.find(L=>L===I)?d.value.filter(L=>L!==I):[...d.value,I];d.onChange(E)}},"aria-label":o(t),children:e(Te,{children:me(k)})})}),u[t]&&e(De,{message:o("required")})]}):e(ye,{})},at=({orgId:t,identityProvider:a,onClose:l})=>{const{adminClient:g}=z(),{t:r}=T(),{addAlert:n,addError:c}=D(),m=_({mode:"onChange"}),{handleSubmit:o,formState:p,setValue:f}=m,{getValues:u}=Q();We(()=>Ee({...a,alias:[a?.alias]},f),[]);const y=async i=>{try{const s=await g.identityProviders.findOne({alias:i.alias[0]});if(!s)throw new Error(r("notFound"));const{config:P}=Le(i);s.config={...s.config,...P},await g.identityProviders.update({alias:i.alias[0]},s),a||await g.organizations.linkIdp({orgId:t,alias:i.alias[0]}),n(r(a?"linkUpdatedSuccessful":"linkSuccessful")),l()}catch(s){c(a?"linkUpdatedError":"linkError",s)}};return e(re,{variant:ie.small,title:r("linkIdentityProvider"),isOpen:!0,onClose:l,actions:[e(J,{formState:p,"data-testid":"confirm",form:"form",allowInvalid:!0,allowNonDirty:!0,children:r("save")},"confirm"),e(A,{id:"modal-cancel","data-testid":"cancel",variant:U.link,onClick:l,children:r("cancel")},"cancel")],children:e($,{...m,children:v(oe,{id:"form",onSubmit:o(y),children:[e(tt,{name:"alias",label:r("identityProvider"),defaultValue:[],isRequired:!0,isDisabled:!!a}),e(Ae,{name:N("config.kc.org.domain"),label:r("domain"),controller:{defaultValue:""},options:[{key:"",value:r("none")},...u("domains").map(i=>({key:i,value:i}))],menuAppendTo:"parent"}),e(te,{name:N("config.kc.org.broker.public"),label:r("shownOnLoginPage"),labelIcon:r("shownOnLoginPageHelp"),stringify:!0}),e(te,{name:N("config.kc.org.broker.redirect.mode.email-matches"),label:r("redirectWhenEmailMatches"),labelIcon:r("redirectWhenEmailMatchesHelp"),stringify:!0})]})})})},nt=({row:t,refresh:a})=>{const{adminClient:l}=z(),{addAlert:g,addError:r}=D(),{t:n}=T(),c=async m=>{try{await l.identityProviders.update({alias:t.alias},{...t,config:{...t.config,"kc.org.broker.public":`${m}`}}),g(n("linkUpdatedSuccessful")),a()}catch(o){r("linkUpdatedError",o)}};return e(xe,{label:n("on"),labelOff:n("off"),isChecked:t.config?.["kc.org.broker.public"]==="true",onChange:(m,o)=>c(o)})},rt=()=>{const{adminClient:t}=z(),{t:a}=T(),{id:l}=Oe(),{addAlert:g,addError:r}=D(),[n,c]=M(0),m=()=>c(n+1),[o,p]=M(!1),[f,u]=M(),[y,i]=F();X(async()=>t.identityProviders.find({max:1}),h=>{p(h.length===1)},[]);const s=()=>t.organizations.listIdentityProviders({orgId:l}),[P,S]=H({titleKey:"identityProviderUnlink",messageKey:"identityProviderUnlinkConfirm",continueButtonLabel:"unLinkIdentityProvider",continueButtonVariant:U.danger,onConfirm:async()=>{try{await t.organizations.unLinkIdp({orgId:l,alias:f.alias}),u(void 0),g(a("unLinkSuccessful")),m()}catch(h){r("unLinkError",h)}}});return v(O,{variant:"light",children:[e(S,{}),y&&e(at,{orgId:l,identityProvider:f,onClose:()=>{i(),m()}}),o?e(ce,{loader:s,ariaLabelKey:"identityProviders",searchPlaceholderKey:"searchProvider",toolbarItem:e(q,{children:e(A,{onClick:()=>{u(void 0),i()},children:a("linkIdentityProvider")})}),actions:[{title:a("edit"),onRowClick:h=>{u(h),i()}},{title:a("unLinkIdentityProvider"),onRowClick:h=>{u(h),P()}}],columns:[{name:"alias"},{name:"config['kc.org.domain']",displayKey:"domain"},{name:"providerId",displayKey:"providerDetails"},{name:"config['kc.org.broker.public']",displayKey:"shownOnLoginPage",cellRenderer:h=>e(nt,{row:h,refresh:m})}],emptyState:e(j,{message:a("emptyIdentityProviderLink"),instructions:a("emptyIdentityProviderLinkInstructions"),primaryActionText:a("linkIdentityProvider"),onPrimaryAction:i})},n):e(j,{icon:Fe,message:a("noIdentityProvider"),instructions:a("noIdentityProviderInstructions")})]})};function qt(){const{adminClient:t}=z(),{addAlert:a,addError:l}=D(),{realm:g}=W(),{id:r}=le(),{t:n}=T(),c=_(),m=async i=>{try{const s=Je(i);await t.organizations.updateById({id:r},s),a(n("organizationSaveSuccess"))}catch(s){l("organizationSaveError",s)}};X(()=>t.organizations.findOne({id:r}),i=>{if(!i)throw new Error(n("notFound"));c.reset({...i,domains:i.domains?.map(s=>s.name),attributes:Ue(i.attributes)})},[r]);const o=i=>Ge(Ve({realm:g,id:r,tab:i})),p=o("settings"),f=o("attributes"),u=o("members"),y=o("identityProviders");return e(O,{variant:"light",className:"pf-v5-u-p-0",children:v($,{...c,children:[e(Xe,{save:()=>m(c.getValues())}),v(Ne,{"data-testid":"organization-tabs","aria-label":n("organization"),isBox:!0,mountOnEnter:!0,children:[e(K,{id:"settings","data-testid":"settingsTab",title:e(V,{children:n("settings")}),...p,children:e(O,{children:v(Re,{role:"anyone",onSubmit:c.handleSubmit(m),isHorizontal:!0,children:[e(_e,{}),v(Ke,{children:[e(J,{formState:c.formState,"data-testid":"save",children:n("save")}),e(A,{onClick:()=>c.reset(),"data-testid":"reset",variant:"link",children:n("reset")})]})]})})}),e(K,{id:"attributes","data-testid":"attributeTab",title:e(V,{children:n("attributes")}),...f,children:e(O,{variant:"light",children:e(Be,{form:c,save:m,reset:()=>c.reset({...c.getValues()}),name:"attributes"})})}),e(K,{id:"members","data-testid":"membersTab",title:e(V,{children:n("members")}),...u,children:e(et,{})}),e(K,{id:"identityProviders","data-testid":"identityProvidersTab",title:e(V,{children:n("identityProviders")}),...y,children:e(rt,{})})]})]})})}export{qt as default};
//# sourceMappingURL=DetailOrganization-C57a_dvC.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy