theme.keycloak.v2.admin.resources.assets.ClientsSection-6w1IyCg1.js Maven / Gradle / Ivy
import{jsxs as c,Fragment as P,jsx as e}from"react/jsx-runtime";import{useState as I,useMemo as oe}from"react";import{bE as W,u as v,a as g,f as F,c as f,d as X,B as N,j as Y,h as K,L,bF as j,b as re,s as le,w as ce,M as de,q as me,e as Z,v as ue,aT as ee,a2 as M,aS as H,ad as _,b3 as te,au as pe,P as ye,aQ as q,bC as he,aR as ge,bG as fe,aC as ie,bH as Ce,bI as be}from"./index-C1LIsRX7.js";import{u as V}from"./ConfirmDialog-B5qjiAuo.js";import{V as Te,F as De}from"./ViewHeader-qjLr6U82.js";import{R as ne,u as ae}from"./RoutableTabs-j5CUH0-6.js";import{K as $}from"./KeycloakDataTable-jyvvxdb8.js";import{L as Ae}from"./PaginatingTableToolbar-CpMLQtqt.js";import{u as Re,F as z}from"./useFormatDate-Ypu7MAgr.js";import{a0 as ke,T as A,a1 as O}from"./Td-BwjBKSkH.js";import{u as Ie}from"./useToggle-K3Kx99tM.js";import{d as Le,D as G,a as Q,b as J,c as E}from"./DataListItemRow-COCiEHyF.js";import{a as R,b as k}from"./Tabs-CNBvRApH.js";import{i as Ke,g as Pe}from"./utils-DeGqqWSp.js";import"react-dom";import"./PageHandler-CFMh3rCu.js";import"./DynamicComponents-CIZcko9u.js";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./CodeEditor-CIeIZGz7.js";import"./copy-icon-DOS8MmN7.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./EmptyStateActions-DBSnfkAA.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./FlexItem-DCAd8FXq.js";import"./KeySelect-B2uWUd6C.js";import"./MultiLineInput-AcwuO_FT.js";import"./AddRoleMappingModal-Ds4yp8lg.js";import"./filter-icon-BVyMUArZ.js";import"./useParams-n_2fXkN1.js";import"./PageList-D9zZFEpa.js";import"./_baseFlatten-BHAcGTxk.js";import"./grip-vertical-icon-Bnn0MebT.js";const ve=()=>({className:ke.modifiers.wrap}),we=({rootUrl:t,baseUrl:i},n)=>i?.startsWith("http")?i:(t==="${authBaseUrl}"||t==="${authAdminUrl}")&&i?t.replace(/\$\{(authAdminUrl|authBaseUrl)\}/,W(n,i)):t?.startsWith("http")?i?W(t,i):t:i,xe=()=>{const{adminClient:t}=v(),{t:i}=g(),{addAlert:n,addError:r}=F(),{realm:s}=f(),l=Re(),p=X(),[d,a]=I(),y=async()=>{try{return await t.realms.getClientsInitialAccess({realm:s})}catch{return[]}},[h,C]=V({titleKey:"tokenDeleteConfirmTitle",messageKey:i("tokenDeleteConfirm",{id:d?.id}),continueButtonLabel:"delete",continueButtonVariant:N.danger,onConfirm:async()=>{try{await t.realms.delClientsInitialAccess({realm:s,id:d.id}),n(i("tokenDeleteSuccess"),Y.success),a(void 0)}catch(o){r("tokenDeleteError",o)}}});return c(P,{children:[e(C,{}),e($,{ariaLabelKey:"initialAccessToken",searchPlaceholderKey:"searchInitialAccessToken",loader:y,toolbarItem:e(K,{component:o=>e(L,{...o,to:j({realm:s})}),children:i("create")}),actions:[{title:i("delete"),onRowClick:o=>{a(o),h()}}],columns:[{name:"id",displayKey:"id"},{name:"timestamp",displayKey:"timestamp",cellRenderer:o=>l(new Date(o.timestamp*1e3),z)},{name:"expiration",displayKey:"expires",cellRenderer:o=>l(new Date(o.timestamp*1e3+o.expiration*1e3),z)},{name:"count",displayKey:"count"},{name:"remainingCount",displayKey:"remainingCount",transforms:[ve]}],emptyState:e(Ae,{message:i("noTokens"),instructions:i("noTokensInstructions"),primaryActionText:i("create"),onPrimaryAction:()=>p(j({realm:s}))})},d?.id)]})},Se=({onConfirm:t,toggleDialog:i})=>{const{t:n}=g(),r=re(),s=Object.keys(r.providers?.["client-registration-policy"].providers||[]),l=r.componentTypes?.["org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy"],p=le(),d=oe(()=>p(l?.filter(a=>s.includes(a.id))||[],ce("id")),[s,l]);return e(de,{variant:me.medium,title:n("chooseAPolicyProvider"),isOpen:!0,onClose:i,children:c(Le,{onSelectDataListItem:(a,y)=>{t(y),i()},"aria-label":n("addPredefinedMappers"),isCompact:!0,children:[e(G,{"aria-label":n("headerName"),id:"header",children:e(Q,{children:e(J,{dataListCells:[n("name"),n("description")].map(a=>e(E,{style:{fontWeight:700},children:a},a))})})}),d.map(a=>e(G,{"aria-label":a.id,"data-testid":a.id,id:a.id,children:e(Q,{children:e(J,{dataListCells:[e(E,{width:2,children:a.id},`name-${a.id}`),e(E,{width:4,children:a.helpText},`description-${a.id}`)]})})},a.id))]})})},Be=t=>{const{realm:i}=f(),{subTab:n}=Z();return e(L,{to:ee({realm:i,subTab:n||"anonymous",providerId:t.providerId,id:t.id}),children:t.name},t.id)},U=({subType:t})=>{const{adminClient:i}=v(),{t:n}=g(),{subTab:r}=Z(),s=X(),{addAlert:l,addError:p}=F(),{realm:d}=f(),[a,y]=I([]),[h,C]=I(),[o,b]=Ie();ue(()=>i.components.find({type:"org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy"}),m=>y(m.filter(S=>S.subType===t)),[h]);const[w,x]=V({titleKey:"clientRegisterPolicyDeleteConfirmTitle",messageKey:n("clientRegisterPolicyDeleteConfirm",{name:h?.name}),continueButtonLabel:"delete",continueButtonVariant:N.danger,onConfirm:async()=>{try{await i.components.del({realm:d,id:h?.id}),l(n("clientRegisterPolicyDeleteSuccess")),C(void 0)}catch(m){p("clientRegisterPolicyDeleteError",m)}}});return c(P,{children:[o&&e(Se,{onConfirm:m=>s(ee({realm:d,subTab:r||"anonymous",providerId:m})),toggleDialog:b}),e(x,{}),e($,{ariaLabelKey:"clientRegistration",searchPlaceholderKey:n("searchClientRegistration"),"data-testid":`clientRegistration-${t}`,loader:a,toolbarItem:e(M,{children:e(K,{"data-testid":`createPolicy-${t}`,onClick:b,children:n("createPolicy")})}),actions:[{title:n("delete"),onRowClick:m=>{C(m),w()}}],columns:[{name:"name",displayKey:"name",cellRenderer:Be},{name:"providerId",displayKey:"providerId"}]})]})},Ee=()=>{const{t}=g(),{realm:i}=f(),n=l=>ae(H({realm:i,subTab:l})),r=n("anonymous"),s=n("authenticated");return c(ne,{defaultLocation:H({realm:i,subTab:"anonymous"}),mountOnEnter:!0,children:[e(R,{"data-testid":"anonymous",title:c(k,{children:[t("anonymousAccessPolicies")," ",e(_,{fieldLabelId:"",helpText:t("anonymousAccessPoliciesHelp"),noVerticalAlign:!1,unWrap:!0})]}),...r,children:e(U,{subType:"anonymous"})}),e(R,{"data-testid":"authenticated",title:c(k,{children:[t("authenticatedAccessPolicies")," ",e(_,{fieldLabelId:"",helpText:t("authenticatedAccessPoliciesHelp"),noVerticalAlign:!1,unWrap:!0})]}),...s,children:e(U,{subType:"authenticated"})})]})},Me=t=>{const{t:i}=g(),{realm:n}=f();return e(O,{wrapModifier:"truncate",children:c(L,{to:ge({realm:n,clientId:t.id,tab:"settings"}),children:[t.clientId,!t.enabled&&e(fe,{isRead:!0,className:"pf-v5-u-ml-sm",children:i("disabled")},`${t.id}-disabled`)]},t.id)})},Fe=t=>e(O,{wrapModifier:"truncate",children:ie()(t.name)}),Ne=t=>e(O,{wrapModifier:"truncate",children:ie()(t.description)}),Ve=t=>{const{adminClient:i}=v(),n=we(t,i.baseUrl);return n?e(De,{href:n}):"—"},$e=()=>{const{t}=g(),{realm:i}=f(),{hasAccess:n}=te();return n("manage-clients")?c(P,{children:[e(M,{children:e(K,{component:s=>e(L,{...s,to:Ce({realm:i})}),children:t("createClient")})}),e(M,{children:e(K,{component:s=>e(L,{...s,to:be({realm:i})}),variant:"link","data-testid":"importClient",children:t("importClient")})})]}):e("span",{})};function bt(){const{adminClient:t}=v(),{t:i}=g(),{addAlert:n,addError:r}=F(),{realm:s}=f(),[l,p]=I(0),d=()=>p(new Date().getTime()),[a,y]=I(),{hasAccess:h}=te(),C=h("manage-clients"),o=async(u,T,D)=>{const B={first:u,max:T};return D&&(B.clientId=D,B.search=!0),await t.clients.find({...B})},b=u=>ae(q({realm:s,tab:u})),w=b("list"),x=b("initial-access-token"),m=b("client-registration"),[S,se]=V({titleKey:i("clientDelete",{clientId:a?.clientId}),messageKey:"clientDeleteConfirm",continueButtonLabel:"delete",continueButtonVariant:N.danger,onConfirm:async()=>{try{await t.clients.del({id:a.id}),n(i("clientDeletedSuccess"),Y.success),d()}catch(u){r("clientDeleteError",u)}}});return c(P,{children:[e(Te,{titleKey:"clientList",subKey:"clientsExplain",helpUrl:pe.clientsUrl,divider:!1}),e(ye,{variant:"light",className:"pf-v5-u-p-0",children:c(ne,{mountOnEnter:!0,isBox:!0,defaultLocation:q({realm:s,tab:"list"}),children:[c(R,{"data-testid":"list",title:e(k,{children:i("clientsList")}),...w,children:[e(se,{}),e($,{loader:o,isPaginated:!0,ariaLabelKey:"clientList",searchPlaceholderKey:"searchForClient",toolbarItem:e($e,{}),actionResolver:u=>{const T=u.data,D=[{title:i("export"),onClick(){he(T)}}];return!Ke(T)&&(C||T.access?.configure)&&D.push({title:i("delete"),onClick(){y(T),S()}}),D},columns:[{name:"clientId",displayKey:"clientId",transforms:[A(20)],cellRenderer:Me},{name:"clientName",displayKey:"clientName",transforms:[A(20)],cellRenderer:Fe},{name:"protocol",displayKey:"type",transforms:[A(10)],cellRenderer:u=>Pe(i,u.protocol??"openid-connect")},{name:"description",displayKey:"description",transforms:[A(30)],cellRenderer:Ne},{name:"baseUrl",displayKey:"homeURL",transforms:[A(20)],cellRenderer:Ve}]},l)]}),e(R,{"data-testid":"initialAccessToken",title:e(k,{children:i("initialAccessToken")}),...x,children:e(xe,{})}),e(R,{"data-testid":"registration",title:e(k,{children:i("clientRegistration")}),...m,children:e(Ee,{})})]})})]})}export{bt as default};
//# sourceMappingURL=ClientsSection-6w1IyCg1.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy