theme.keycloak.v2.admin.resources.assets.DetailOrganization-TK3s4MwI.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 _,B as U,dD as ge,ae as ne,D as q,g as $,M as re,q as ie,p as J,h as A,F as Q,r as oe,x as B,P as O,a2 as G,J as pe,K as se,N as he,L as be,bx as fe,v as X,a3 as ye,ac as ve,ad as ke,V as Ce,b$ as Ie,c0 as Pe,ag as Se,ah as we,c1 as Me,c2 as ze,W as Te,aq as De,U as ee,Q as Ee,y as Ae,aJ as N,S as Le,e as Oe,dF as Fe,a4 as xe,A as Ke,dE as Ve,bP as Ue}from"./index-C1LIsRX7.js";import{F as Re}from"./FormAccess-BcY70QlP.js";import{A as Be}from"./AttributeForm-DDUkni1v.js";import{R as Ne,u as qe}from"./RoutableTabs-j5CUH0-6.js";import{u as le}from"./useParams-n_2fXkN1.js";import{V as Ge}from"./ViewHeader-qjLr6U82.js";import{u as H}from"./ConfirmDialog-B5qjiAuo.js";import{useState as M,useRef as He,useCallback as je,useEffect as We}from"react";import{L as j}from"./PaginatingTableToolbar-CpMLQtqt.js";import{K as ce}from"./KeycloakDataTable-jyvvxdb8.js";import{M as _e}from"./MembersModal-BMzek0-s.js";import{u as F}from"./useToggle-K3Kx99tM.js";import{O as $e,c as Je}from"./OrganizationForm-BjCA0cNQ.js";import{D as te}from"./SwitchControl-C3zDl-9W.js";import{d as Qe}from"./debounce-Bipqqxoj.js";import{a as K,b as V}from"./Tabs-CNBvRApH.js";import"react-dom";import"./copy-icon-DOS8MmN7.js";import"./KeyValueInput-CoupoYmE.js";import"./KeySelect-B2uWUd6C.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./PageHandler-CFMh3rCu.js";import"./DynamicComponents-CIZcko9u.js";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./CodeEditor-CIeIZGz7.js";import"./EmptyStateActions-DBSnfkAA.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./DataListItemRow-COCiEHyF.js";import"./FlexItem-DCAd8FXq.js";import"./MultiLineInput-AcwuO_FT.js";import"./AddRoleMappingModal-Ds4yp8lg.js";import"./filter-icon-BVyMUArZ.js";import"./Td-BwjBKSkH.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./PageList-D9zZFEpa.js";import"./_baseFlatten-BHAcGTxk.js";const Xe=({save:t})=>{const{adminClient:a}=z(),{realm:s}=W(),g=ue(),{t:r}=T(),{addAlert:n,addError:l}=D(),m=Z({name:"id"}),o=Z({name:"name"}),{setValue:b}=_(),[f,u]=H({titleKey:"disableConfirmOrganizationTitle",messageKey:"disableConfirmOrganization",continueButtonLabel:"disable",onConfirm:()=>{b("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:s}))}catch(c){l("organizationDeleteError",c)}}});return e(ne,{name:"enabled",render:({field:{value:c,onChange:P}})=>v(ae,{children:[e(i,{}),e(u,{}),e(Ge,{titleKey:o||"",divider:!1,dropdownItems:[e(q,{"data-testid":"delete-client",onClick:y,children:r("delete")},"delete")],isEnabled:c,onToggle:S=>{S?(P(S),t()):f()}})]})})},Ye=({orgId:t,onClose:a})=>{const{adminClient:s}=z(),{addAlert:g,addError:r}=D(),{t:n}=T(),l=$(),{handleSubmit:m,formState:o}=l,b=async f=>{try{const u=new FormData;for(const y in f)u.append(y,f[y]);await s.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(Q,{...l,children:v(oe,{id:"form",onSubmit:m(b),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:s}=le(),{addAlert:g,addError:r}=D(),[n,l]=M(0),m=()=>l(n+1),[o,b]=F(),[f,u]=F(),[y,i]=F(),[c,P]=M([]),S=(h,k,R)=>a.organizations.listMembers({orgId:s,first:h,max:k,search:R}),p=async h=>{try{await Promise.all(h.map(k=>a.organizations.delMember({orgId:s,userId:k.id}))),g(t("organizationUsersLeft",{count:h.length}))}catch(k){r("organizationUsersLeftError",k)}m()};return v(O,{variant:"light",children:[f&&e(_e,{membersQuery:async()=>await a.organizations.listMembers({orgId:s}),onAdd:async h=>{try{await Promise.all(h.map(k=>a.organizations.addMember({orgId:s,userId:k.id}))),g(t("organizationUsersAdded",{count:h.length}))}catch(k){r("organizationUsersAddedError",k)}},onClose:()=>{u(),m()}}),y&&e(Ye,{orgId:s,onClose:i}),e(ce,{loader:S,isPaginated:!0,ariaLabelKey:"membersList",searchPlaceholderKey:"searchMember",onSelect:h=>P([...h]),canSelectAll:!0,toolbarItem:v(ae,{children:[e(G,{children:e(pe,{toggle:h=>e(se,{ref:h,onClick:b,isExpanded:o,variant:"primary",children:t("addMember")}),isOpen:o,children:v(he,{children:[e(q,{onClick:()=>{u(),b()},children:t("addRealmUser")}),e(q,{onClick:()=>{i(),b()},children:t("inviteMember")})]})})}),e(G,{children:e(A,{variant:"plain",isDisabled:c.length===0,onClick:()=>p(c),children:t("removeMember")})})]}),actions:[{title:t("remove"),onRowClick:async h=>{await p([h])}}],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:s,defaultValue:g,isRequired:r,variant:n="typeahead",isDisabled:l})=>{const{adminClient:m}=z(),{t:o}=T(),{control:b,getValues:f,formState:{errors:u}}=_(),y=f(t),[i,c,P]=F(),[S,p]=M(""),h=He(),[k,R]=M([]),[x,Y]=M(""),de=je(Qe(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:s?e(ke,{helpText:s,fieldLabelId:a}):void 0,fieldId:t,children:[e(ne,{name:t,defaultValue:g,control:b,rules:{validate:d=>r&&d.filter(w=>w!==void 0).length===0?o("required"):void 0},render:({field:d})=>e(Ce,{id:t,toggle:w=>e(se,{"data-testid":t,ref:w,variant:"typeahead",onClick:c,isExpanded:i,isFullWidth:!0,isDisabled:l,status:u[t]?"danger":void 0,children:v(Ie,{isPlain:!0,children:[e(Pe,{value:S||d.value,onClick:c,onChange:(C,I)=>{P(!0),p(I),de(I)},autoComplete:"off",innerRef:h,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:()=>{p(""),Y(""),d.onChange([]),h?.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]),p(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:s})=>{const{adminClient:g}=z(),{t:r}=T(),{addAlert:n,addError:l}=D(),m=$({mode:"onChange"}),{handleSubmit:o,formState:b,setValue:f}=m,{getValues:u}=_();We(()=>Ee({...a,alias:[a?.alias]},f),[]);const y=async i=>{try{const c=await g.identityProviders.findOne({alias:i.alias[0]});if(!c)throw new Error(r("notFound"));const{config:P}=Le(i);c.config={...c.config,...P},await g.identityProviders.update({alias:i.alias[0]},c),a||await g.organizations.linkIdp({orgId:t,alias:i.alias[0]}),n(r(a?"linkUpdatedSuccessful":"linkSuccessful")),s()}catch(c){l(a?"linkUpdatedError":"linkError",c)}};return e(re,{variant:ie.small,title:r("linkIdentityProvider"),isOpen:!0,onClose:s,actions:[e(J,{formState:b,"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:s,children:r("cancel")},"cancel")],children:e(Q,{...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:s}=z(),{addAlert:g,addError:r}=D(),{t:n}=T(),l=async m=>{try{await s.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)=>l(o)})},rt=()=>{const{adminClient:t}=z(),{t:a}=T(),{id:s}=Oe(),{addAlert:g,addError:r}=D(),[n,l]=M(0),m=()=>l(n+1),[o,b]=M(!1),[f,u]=M(),[y,i]=F();X(async()=>t.identityProviders.find({max:1}),p=>{b(p.length===1)},[]);const c=()=>t.organizations.listIdentityProviders({orgId:s}),[P,S]=H({titleKey:"identityProviderUnlink",messageKey:"identityProviderUnlinkConfirm",continueButtonLabel:"unLinkIdentityProvider",continueButtonVariant:U.danger,onConfirm:async()=>{try{await t.organizations.unLinkIdp({orgId:s,alias:f.alias}),u(void 0),g(a("unLinkSuccessful")),m()}catch(p){r("unLinkError",p)}}});return v(O,{variant:"light",children:[e(S,{}),y&&e(at,{orgId:s,identityProvider:f,onClose:()=>{i(),m()}}),o?e(ce,{loader:c,ariaLabelKey:"identityProviders",searchPlaceholderKey:"searchProvider",toolbarItem:e(G,{children:e(A,{onClick:()=>{u(void 0),i()},children:a("linkIdentityProvider")})}),actions:[{title:a("edit"),onRowClick:p=>{u(p),i()}},{title:a("unLinkIdentityProvider"),onRowClick:p=>{u(p),P()}}],columns:[{name:"alias"},{name:"config['kc.org.domain']",displayKey:"domain"},{name:"providerId",displayKey:"providerDetails"},{name:"config['kc.org.broker.public']",displayKey:"shownOnLoginPage",cellRenderer:p=>e(nt,{row:p,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 Gt(){const{adminClient:t}=z(),{addAlert:a,addError:s}=D(),{realm:g}=W(),{id:r}=le(),{t:n}=T(),l=$(),m=async i=>{try{const c=Je(i);await t.organizations.updateById({id:r},c),a(n("organizationSaveSuccess"))}catch(c){s("organizationSaveError",c)}};X(()=>t.organizations.findOne({id:r}),i=>{if(!i)throw new Error(n("notFound"));l.reset({...i,domains:i.domains?.map(c=>c.name),attributes:Ue(i.attributes)})},[r]);const o=i=>qe(Ve({realm:g,id:r,tab:i})),b=o("settings"),f=o("attributes"),u=o("members"),y=o("identityProviders");return e(O,{variant:"light",className:"pf-v5-u-p-0",children:v(Q,{...l,children:[e(Xe,{save:()=>m(l.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")}),...b,children:e(O,{children:v(Re,{role:"anyone",onSubmit:l.handleSubmit(m),isHorizontal:!0,children:[e($e,{}),v(Ke,{children:[e(J,{formState:l.formState,"data-testid":"save",children:n("save")}),e(A,{onClick:()=>l.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:l,save:m,reset:()=>l.reset({...l.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{Gt as default};
//# sourceMappingURL=DetailOrganization-TK3s4MwI.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy