theme.keycloak.v2.admin.resources.assets.NewClientForm-EtPhcHlS.js Maven / Gradle / Ivy
import{jsxs as G,jsx as T,Fragment as le}from"react/jsx-runtime";import{_ as H,i as K,B as $,m as N,aK as de,aL as ce,aM as ue,n as ee,aN as me,aO as ve,aP as fe,a as Q,aG as pe,v as ge,u as be,c as ze,d as we,f as xe,g as Se,P as ye,F as Ee,aQ as Ne,S as Ie,k as he,aR as _e}from"./main-C7ps2lmX.js";import{F as te}from"./FormAccess-DyLNkc18.js";import{V as Ce}from"./ViewHeader-B7eeFzFA.js";import{C as ke,a as Te}from"./ClientDescription-p94dy3yH.js";import{g as We}from"./utils-DeGqqWSp.js";import{L as Oe}from"./LoginSettings-BIZRUkgM.js";import*as h from"react";import t from"react";import"react-dom";import"./copy-icon-ACZmDH8e.js";import"./SwitchControl-C_9Y74oV.js";import"./MultiLineInput-DiPNQ1LE.js";const b={button:"pf-v5-c-button",dirRtl:"pf-v5-m-dir-rtl",drawer:"pf-v5-c-drawer",modalBox:"pf-v5-c-modal-box",modifiers:{finished:"pf-m-finished",expanded:"pf-m-expanded",current:"pf-m-current",expandable:"pf-m-expandable",disabled:"pf-m-disabled",noPadding:"pf-m-no-padding"},pageMainWizard:"pf-v5-c-page__main-wizard",themeDark:"pf-v5-theme-dark",wizard:"pf-v5-c-wizard",wizardClose:"pf-v5-c-wizard__close",wizardDescription:"pf-v5-c-wizard__description",wizardFooter:"pf-v5-c-wizard__footer",wizardFooterCancel:"pf-v5-c-wizard__footer-cancel",wizardHeader:"pf-v5-c-wizard__header",wizardInnerWrap:"pf-v5-c-wizard__inner-wrap",wizardMain:"pf-v5-c-wizard__main",wizardMainBody:"pf-v5-c-wizard__main-body",wizardNav:"pf-v5-c-wizard__nav",wizardNavItem:"pf-v5-c-wizard__nav-item",wizardNavLink:"pf-v5-c-wizard__nav-link",wizardNavLinkText:"pf-v5-c-wizard__nav-link-text",wizardNavLinkToggle:"pf-v5-c-wizard__nav-link-toggle",wizardNavLinkToggleIcon:"pf-v5-c-wizard__nav-link-toggle-icon",wizardNavList:"pf-v5-c-wizard__nav-list",wizardOuterWrap:"pf-v5-c-wizard__outer-wrap",wizardTitle:"pf-v5-c-wizard__title",wizardTitleText:"pf-v5-c-wizard__title-text",wizardToggle:"pf-v5-c-wizard__toggle",wizardToggleIcon:"pf-v5-c-wizard__toggle-icon",wizardToggleList:"pf-v5-c-wizard__toggle-list",wizardToggleListItem:"pf-v5-c-wizard__toggle-list-item",wizardToggleNum:"pf-v5-c-wizard__toggle-num",wizardToggleSeparator:"pf-v5-c-wizard__toggle-separator"};var V;(function(e){e.Default="default",e.Error="error"})(V||(V={}));var P;(function(e){e.Next="next",e.Back="back",e.Nav="nav"})(P||(P={}));function je(e){return typeof e=="function"||t.isValidElement(e)}function X(e){return typeof e=="function"||t.isValidElement(e)}function ae(e){return typeof e=="function"||t.isValidElement(e)}function Fe(e){return e?.subStepIds===void 0&&!D(e)}function D(e){return e?.parentId!==void 0}function R(e){return e?.subStepIds!==void 0}const ie=({children:e})=>t.createElement("footer",{className:N(b.wizardFooter)},e),U=e=>{var{activeStep:i}=e,o=H(e,["activeStep"]);const s=!ae(i?.footer)&&i?.footer;return t.createElement(Le,Object.assign({},o,s))},Le=({onNext:e,onBack:i,onClose:o,isNextDisabled:s,isBackDisabled:r,isBackHidden:n,isCancelHidden:l,nextButtonText:c="Next",backButtonText:u="Back",cancelButtonText:a="Cancel",nextButtonProps:z,backButtonProps:f,cancelButtonProps:g})=>t.createElement(ie,null,!n&&t.createElement(K,Object.assign({variant:$.secondary,onClick:i,isDisabled:r},f),u),t.createElement(K,Object.assign({variant:$.primary,type:"submit",onClick:e,isDisabled:s},z),c),!l&&t.createElement("div",{className:b.wizardFooterCancel},t.createElement(K,Object.assign({variant:$.link,onClick:o},g),a)));ie.displayName="WizardFooterWrapper";U.displayName="WizardFooter";const J=t.createContext({}),ne=({steps:e,footer:i,activeStepIndex:o,children:s,onNext:r,onBack:n,onClose:l,goToStepById:c,goToStepByName:u,goToStepByIndex:a})=>{const[z,f]=t.useState(e),[g,d]=t.useState(),m=t.useMemo(()=>z.map((y,W)=>Object.assign(Object.assign({},y),e[W])),[e,z]),v=t.useMemo(()=>m.find(y=>y.index===o),[o,m]),w=t.useCallback(()=>l?.(null),[l]),S=t.useCallback(()=>r(null,m),[r,m]),E=t.useCallback(()=>n(null,m),[n,m]),k=t.useMemo(()=>{const y=v?.footer||g||i;if(ae(y)){const W=y;return typeof W=="function"?W(v,S,E,w):W}return t.createElement(U,Object.assign({activeStep:v,onNext:S,onBack:E,onClose:w,isBackDisabled:v?.index===1||D(v)&&v?.index===2},y))},[g,i,v,S,E,w]),F=t.useCallback(y=>m.find(W=>W.id===y),[m]),x=t.useCallback(y=>f(W=>W.map(O=>O.id===y.id?Object.assign(Object.assign({},O),y):O)),[]);return t.createElement(J.Provider,{value:{steps:m,activeStep:v,footer:k,close:w,getStep:F,setStep:x,goToNextStep:S,goToPrevStep:E,setFooter:d,goToStepById:t.useCallback(y=>c(m,y),[c,m]),goToStepByName:t.useCallback(y=>u(m,y),[u,m]),goToStepByIndex:t.useCallback(y=>a(null,m,y),[a,m])}},s)};ne.displayName="WizardContextProvider";const M=()=>t.useContext(J),j=e=>{var{children:i,steps:o}=e,s=H(e,["children","steps"]);const{activeStep:r,setStep:n}=M(),{id:l,name:c,body:u,isDisabled:a,isHidden:z,navItem:f,footer:g,status:d}=s,m=R(r);return t.useEffect(()=>{n(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({id:l,name:c},u&&{body:u}),a&&{isDisabled:a}),z&&{isHidden:z}),f&&{navItem:f}),g&&{footer:g}),d&&{status:d}),!m&&l===r?.id&&!r?.isVisited&&{isVisited:!0}))},[u,g,l,a,z,c,f,d,m,n,r?.id,r?.isVisited]),t.createElement(t.Fragment,null,i)};j.displayName="WizardStep";const Be=e=>t.Children.toArray(e).reduce((i,o,s)=>{if(Ve(o)){const{props:r}=o,{steps:n,id:l}=r,c=i.length+1,u=[];i.push(Object.assign(Object.assign(Object.assign({index:c,component:o},s===0&&!n?.length&&{isVisited:!0}),n&&{subStepIds:n?.map((a,z)=>(u.push(Object.assign(Object.assign({index:c+z+1,component:a,parentId:l},s===0&&z===0&&{isVisited:!0}),Y(a.props))),a.props.id))}),Y(r)),...u)}else throw new Error("Wizard only accepts children of type WizardStep.");return i},[]);function Ve(e){return t.isValidElement(e)&&e.type===j}const Y=e=>{var i=H(e,["children","steps"]);return i},Z=(e,i)=>{if(!R(i)&&!i.isHidden&&!i.isDisabled)if(D(i)){const o=e.find(s=>s.id===i.parentId);if(!o.isHidden&&!o.isDisabled)return!0}else return!0;return!1},re=({children:e,hasNoPadding:i=!1,"aria-label":o,"aria-labelledby":s,component:r="div"})=>{const[n,l]=t.useState(!1),[c,u]=t.useState(void 0),a=t.useRef(null),z=r,{activeStep:f}=t.useContext(J),g=o||`${f?.name} content`;return t.useEffect(()=>{const m=ce(()=>{if(a?.current){const{offsetWidth:w,offsetHeight:S,scrollHeight:E}=a.current;c!==w&&(u(w),l(S{};if(a?.current){v=de(a.current,m);const{offsetHeight:w,scrollHeight:S}=a.current;l(w{v()}},[c]),t.createElement(z,Object.assign({ref:a},r==="div"&&n&&{role:"region"},n&&{"aria-label":g,"aria-labelledby":s,tabIndex:0},{className:N(b.wizardMain)}),t.createElement("div",{className:N(b.wizardMainBody,i&&b.modifiers.noPadding)},e))};re.displayName="WizardBody";const oe=({steps:e,activeStep:i,footer:o,nav:s,isNavExpanded:r,toggleNavExpanded:n,"aria-label":l="Wizard toggle"})=>{const c=D(i),u=c&&e.find(d=>d.id===i.parentId),z=e.filter(d=>!D(d)).indexOf(u||i)+1,f=t.useCallback(d=>{r&&d.key===ue.Escape&&n?.(d)},[r,n]);t.useEffect(()=>{const d=typeof document<"u"?document.body:null;return d?.addEventListener("keydown",f,!1),()=>{d?.removeEventListener("keydown",f,!1)}},[f]);const g=e.map(d=>{var m;const v=((m=d.component)===null||m===void 0?void 0:m.props)||{},{children:w,body:S}=v,E=H(v,["children","body"]);return t.createElement(t.Fragment,{key:d.id},i?.id===d.id&&(S||S===void 0?t.createElement(re,Object.assign({},S),w):w),t.createElement("div",{key:d.id,style:{display:"none"}},t.createElement(j,Object.assign({},E))))});return t.createElement(t.Fragment,null,t.createElement("button",{onClick:n,className:N(b.wizardToggle,r&&"pf-m-expanded"),"aria-label":l,"aria-expanded":r},t.createElement("span",{className:N(b.wizardToggleList)},t.createElement("span",{className:N(b.wizardToggleListItem)},t.createElement("span",{className:N(b.wizardToggleNum)},z)," ",u?.name||i?.name,c&&t.createElement(ee,{className:N(b.wizardToggleSeparator),"aria-hidden":"true"})),c&&t.createElement("span",{className:N(b.wizardToggleListItem)},i?.name)),t.createElement("span",{className:N(b.wizardToggleIcon)},t.createElement(me,{"aria-hidden":"true"}))),t.createElement("div",{className:N(b.wizardOuterWrap)},t.createElement("div",{className:N(b.wizardInnerWrap)},s,g),o))};oe.displayName="WizardToggle";const q=({children:e,"aria-label":i,"aria-labelledby":o,isExpanded:s=!1,isInnerList:r=!1})=>r?h.createElement("ol",{className:N(b.wizardNavList),role:"list"},e):h.createElement("nav",{className:N(b.wizardNav,s&&b.modifiers.expanded),"aria-label":i,"aria-labelledby":o},h.createElement("ol",{className:N(b.wizardNavList),role:"list"},e));q.displayName="WizardNav";const Pe={name:"--pf-v5-global--spacer--sm",value:"0.5rem",var:"var(--pf-v5-global--spacer--sm)"},Ae={name:"--pf-v5-global--danger-color--100",value:"#c9190b",var:"var(--pf-v5-global--danger-color--100)"},A=({children:e=null,content:i="",isCurrent:o=!1,isDisabled:s=!1,isVisited:r=!1,stepIndex:n,onClick:l,component:c="button",href:u,isExpandable:a=!1,id:z,status:f="default",target:g,ouiaId:d,ouiaSafe:m=!0})=>{const[v,w]=h.useState(!1),S=ve(A.displayName,d,m);h.useEffect(()=>{w(o)},[o]);const E=h.useMemo(()=>{if(f===V.Error||r&&!o){let k=i.toString();return f===V.Error&&(k+=`, ${f}`),r&&!o&&(k+=", visited"),k}},[i,o,r,f]);return h.createElement("li",{className:N(b.wizardNavItem,a&&b.modifiers.expandable,a&&v&&b.modifiers.expanded)},h.createElement(c,Object.assign({},c==="a"?{tabIndex:s?-1:void 0,href:u,target:g}:{disabled:s},z&&{id:z.toString()},{onClick:k=>{k.stopPropagation(),a?w(!v||o):l?.(k,n)},className:N(b.wizardNavLink,o&&b.modifiers.current,s&&b.modifiers.disabled),"aria-disabled":s?!0:null,"aria-current":o&&!e?"step":!1},a&&{"aria-expanded":v},E&&{"aria-label":E},S),a?h.createElement(h.Fragment,null,h.createElement("span",{className:N(b.wizardNavLinkText)},i),h.createElement("span",{className:N(b.wizardNavLinkToggle)},h.createElement("span",{className:N(b.wizardNavLinkToggleIcon)},h.createElement(ee,{"aria-label":`${o?"Collapse":"Expand"} step icon`})))):h.createElement(h.Fragment,null,i,f===V.Error&&h.createElement("span",{style:{marginLeft:Pe.var}},h.createElement(fe,{color:Ae.var})))),e)};A.displayName="WizardNavItem";const De=({nav:e,navAriaLabel:i,isVisitRequired:o,isProgressive:s,isNavExpanded:r})=>{const{activeStep:n,steps:l,goToStepByIndex:c}=M(),u=Object.assign({isExpanded:r,"aria-label":i||e?.["aria-label"]||"Wizard steps"},e?.["aria-labelledby"]&&{"aria-labelledby":e["aria-labelledby"]});return t.createElement(q,Object.assign({},u),l.map((a,z)=>{var f;const g=l.some(v=>v.index>z+1&&v.isVisited),d=a.isDisabled||o&&!a.isVisited&&!g,m=X(a.navItem)&&t.createElement(t.Fragment,{key:a.id},typeof a.navItem=="function"?a.navItem(a,n,l,c):a.navItem);if(R(a)&&!a.isHidden){let v,w=!1;const S=(f=a.subStepIds)===null||f===void 0?void 0:f.map((k,F)=>{const x=l.find(I=>I.id===k),y=l.some(I=>I.index>x.index&&I.isVisited),W=x.isDisabled||o&&!x.isVisited&&!y,O=X(x.navItem)&&t.createElement(t.Fragment,{key:x.id},typeof x.navItem=="function"?x.navItem(x,n,l,c):x.navItem);if(!x.isHidden&&(F===0&&(v=x.index),n?.id===x.id&&(w=!0),!s||s&&x.index<=n.index))return O||t.createElement(A,Object.assign({key:x.id,id:x.id,content:x.name,isCurrent:n?.id===x.id,isDisabled:W||d,isVisited:x.isVisited,stepIndex:x.index,onClick:()=>c(x.index),status:x.status},x.navItem))}),E=t.Children.toArray(S).some(k=>t.isValidElement(k)&&!k.props.isDisabled);if(!s||s&&a.index<=n.index)return m||t.createElement(A,Object.assign({key:a.id,id:a.id,content:a.name,isExpandable:a.isExpandable,isCurrent:w,isDisabled:!E||d,isVisited:a.isVisited,stepIndex:v,onClick:()=>c(v),status:a.status},a.navItem),t.createElement(q,Object.assign({},u,{isInnerList:!0}),S))}if(Fe(a)&&!a.isHidden&&(!s||s&&a.index<=n.index))return m||t.createElement(A,Object.assign({key:a.id,id:a.id,content:a.name,isCurrent:n?.id===a.id,isDisabled:d,isVisited:a.isVisited,stepIndex:a.index,onClick:()=>c(a.index),status:a.status},a.navItem))}))},se=e=>{var{children:i,footer:o,height:s,width:r,className:n,header:l,nav:c,navAriaLabel:u,startIndex:a=1,isVisitRequired:z=!1,isProgressive:f=!1,onStepChange:g,onSave:d,onClose:m}=e,v=H(e,["children","footer","height","width","className","header","nav","navAriaLabel","startIndex","isVisitRequired","isProgressive","onStepChange","onSave","onClose"]);const[w,S]=t.useState(a),E=Be(i),k=t.useRef(E[a-1]);t.useEffect(()=>{R(k.current)&&S(a+1)},[a]);const F=(I,_=E)=>{const p=_.find(C=>C.index>w&&Z(_,C));if(w>=_.length||!p?.index)return d?d(I):m?.(I);S(p?.index),g?.(I,p,_[w-1],P.Next)},x=(I,_=E)=>{const p=[..._].reverse().find(C=>C.index{const C=_.length+1;p<1?p=1:p>C&&(p=C);const L=_[p-1],B=_[w-1];S(p),g?.(I,L,B,P.Nav)},W=(I=E,_)=>{const p=I.find(B=>B.id===_),C=p?.index,L=I.length+1;C>0&&C{const p=I.find(B=>B.name===_),C=p?.index,L=I.length+1;C>0&&C{const{activeStep:r,steps:n,footer:l,goToStepByIndex:c}=M(),[u,a]=t.useState(!1),z=t.useMemo(()=>je(e)?typeof e=="function"?e(u,n,r,c):e:t.createElement(De,{nav:e,navAriaLabel:i,isNavExpanded:u,isVisitRequired:o,isProgressive:s}),[r,o,s,c,u,e,i,n]);return t.createElement(oe,{nav:z,footer:l,steps:n,activeStep:r,isNavExpanded:u,toggleNavExpanded:()=>a(f=>!f)})};se.displayName="Wizard";const Re=()=>{const{t:e}=Q(),i=pe();return G(te,{isHorizontal:!0,role:"manage-clients",children:[T(ge,{name:"protocol",label:e("clientType"),labelIcon:e("clientTypeHelp"),controller:{defaultValue:""},options:i.map(o=>({key:o,value:We(e,o)}))}),T(ke,{hasConfigureAccess:!0})]})},Me=e=>{const{t:i}=Q(),{trigger:o}=e,{activeStep:s,goToNextStep:r,goToPrevStep:n,close:l}=M(),c=async u=>{await o()&&u?.()};return T(U,{activeStep:s,onNext:()=>c(r),onBack:n,onClose:l,isBackDisabled:s.index===1,backButtonText:i("back"),nextButtonText:i("next"),cancelButtonText:i("cancel")})};function at(){const{adminClient:e}=be(),{t:i}=Q(),{realm:o}=ze(),s=we(),{addAlert:r,addError:n}=xe(),l=Se({defaultValues:{protocol:"openid-connect",clientId:"",name:"",description:"",publicClient:!0,authorizationServicesEnabled:!1,serviceAccountsEnabled:!1,implicitFlowEnabled:!1,directAccessGrantsEnabled:!0,standardFlowEnabled:!0,frontchannelLogout:!0,attributes:{saml_idp_initiated_sso_url_name:""}}}),{getValues:c,watch:u}=l,a=u("protocol"),z=async()=>{const g=Ie(c());try{const d=await e.clients.create({...g,clientId:g.clientId?.trim()});r(i("createClientSuccess"),he.success),s(_e({realm:o,clientId:d.id,tab:"settings"}))}catch(d){n("createClientError",d)}},f=i("createClient");return G(le,{children:[T(Ce,{titleKey:"createClient",subKey:"clientsExplain"}),T(ye,{variant:"light",children:T(Ee,{...l,children:G(se,{onClose:()=>s(Ne({realm:o})),navAriaLabel:`${f} steps`,onSave:z,footer:T(Me,{...l}),children:[T(j,{name:i("generalSettings"),id:"generalSettings",children:T(Re,{})},"generalSettings"),T(j,{name:i("capabilityConfig"),id:"capabilityConfig",isHidden:a==="saml",children:T(Te,{protocol:a})},"capabilityConfig"),T(j,{name:i("loginSettings"),id:"loginSettings",footer:{backButtonText:i("back"),nextButtonText:i("save"),cancelButtonText:i("cancel")},children:T(te,{isHorizontal:!0,role:"manage-clients",children:T(Oe,{protocol:a})})},"loginSettings")]})})})]})}export{at as default};
//# sourceMappingURL=NewClientForm-EtPhcHlS.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy