theme.keycloak.v2.admin.resources.assets.ClientScopesSection-C1acOUJ1.js Maven / Gradle / Ivy
import{jsxs as F,Fragment as P,jsx as t}from"react/jsx-runtime";import{useState as s}from"react";import{u as E,c as N,a as R,f as V,s as G,B as Q,k as x,au as X,P as Y,a2 as w,i as Z,L as I,aA as _,J as $,K as ee,aB as te,N as oe,D as ne,aC as O,az as ae,x as re}from"./main-C7ps2lmX.js";import{g as le}from"./utils-DeGqqWSp.js";import{A as u,r as ce,a as se,c as ie,C as B}from"./ClientScopeTypes-BnGjMgG5.js";import{u as pe}from"./ConfirmDialog-hx7XKLbN.js";import{K as de}from"./KeycloakDataTable-DbY4la1D.js";import{V as me}from"./ViewHeader-B7eeFzFA.js";import{S as Se,a as ue,C as he,n as ye,t as fe,p as ge}from"./SearchFilter-D7dkU26J.js";import{T as v}from"./Td-D2hVFK0Z.js";import"react-dom";import"./PaginatingTableToolbar-Cjsz5Jh4.js";import"./EmptyStateFooter-DqmBOP2I.js";import"./EmptyStateActions-DWNUFByn.js";import"./_baseFlatten-eIEJR-AJ.js";import"./filter-icon-DO0QNij3.js";import"./grip-vertical-icon-BxF7V59o.js";const Ce=o=>{const{adminClient:i}=E(),{t:n}=R(),{addAlert:h,addError:d}=V();return t(se,{clientScope:o,type:o.type,all:!0,onSelect:async m=>{try{await ie(i,o,m),h(n("clientScopeSuccess"),x.success),o.refresh()}catch(p){d("clientScopeError",p)}}})},be=({id:o,name:i})=>{const{realm:n}=N();return t(I,{to:ae({realm:n,id:o,tab:"settings"}),children:i},o)};function je(){const{adminClient:o}=E(),{realm:i}=N(),{t:n}=R(),{addAlert:h,addError:d}=V(),[m,p]=s(!1),[a,y]=s([]),[r,T]=s("name"),[D,f]=s(u.none),[K,g]=s("all"),j=G(),[k,U]=s(0),l=()=>{y([]),U(k+1)},M=async(e,L,c)=>{const S=await o.clientScopes.listDefaultClientScopes(),H=await o.clientScopes.listDefaultOptionalClientScopes(),J=await o.clientScopes.find(),W=r==="name"?ye(c):r==="type"?fe(D):ge(K),q=J.map(C=>({...C,type:S.find(b=>b.name===C.name)?B.default:H.find(b=>b.name===C.name)?B.optional:u.none})).filter(W);return j(q,re("name")).slice(e,Number(e)+Number(L))},[A,z]=pe({titleKey:n("deleteClientScope",{count:a.length,name:a[0]?.name}),messageKey:"deleteConfirmClientScopes",continueButtonLabel:"delete",continueButtonVariant:Q.danger,onConfirm:async()=>{const e=await o.clientScopes.find();if(Object.keys(e).length-a.length>0)try{for(const c of a){try{await ce(o,c)}catch(S){console.warn("could not remove scope",S.response?.data?.errorMessage||S)}await o.clientScopes.del({id:c.id})}h(n("deletedSuccessClientScope"),x.success),l()}catch(c){d("deleteErrorClientScope",c)}else d(n("notAllowedToDeleteAllClientScopes"),"error")}});return F(P,{children:[t(z,{}),t(me,{titleKey:"clientScopes",subKey:"clientScopeExplain",helpUrl:X.clientScopesUrl}),t(Y,{variant:"light",className:"pf-v5-u-p-0",children:t(de,{loader:M,ariaLabelKey:"clientScopeList",searchPlaceholderKey:r==="name"?"searchForClientScope":void 0,isSearching:r!=="name",searchTypeComponent:t(Se,{searchType:r,onSelect:e=>T(e),withProtocol:!0}),isPaginated:!0,onSelect:e=>y([...e]),canSelectAll:!0,toolbarItem:F(P,{children:[t(ue,{searchType:r,type:D,onSelect:e=>{T(e),g("all"),f(u.none),l()},onType:e=>{f(e),g("all"),l()},protocol:K,onProtocol:e=>{g(e),f(u.none),l()}}),t(w,{children:t(Z,{component:e=>t(I,{...e,to:_({realm:i})}),children:n("createClientScope")})}),t(w,{children:t(he,{selectedRows:a,refresh:l})}),t(w,{children:t($,{shouldFocusToggleOnSelect:!0,onOpenChange:e=>p(e),toggle:e=>t(ee,{"data-testid":"kebab","aria-label":"Kebab toggle",ref:e,onClick:()=>p(!m),variant:"plain",children:t(te,{})}),isOpen:m,children:t(oe,{children:t(ne,{"data-testid":"delete",isDisabled:a.length===0,onClick:()=>{A(),p(!1)},children:n("delete")})})})})]}),actions:[{title:n("delete"),onRowClick:e=>{y([e]),A()}}],columns:[{name:"name",cellRenderer:be},{name:"type",displayKey:"assignedType",cellRenderer:e=>t(Ce,{...e,refresh:l})},{name:"protocol",displayKey:"protocol",cellRenderer:e=>le(n,e.protocol??"openid-connect"),transforms:[v(15)]},{name:"attributes['gui.order']",displayKey:"displayOrder",cellFormatters:[O()],transforms:[v(15)]},{name:"description",cellFormatters:[O()]}]},k)})]})}export{je as default};
//# sourceMappingURL=ClientScopesSection-C1acOUJ1.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy