theme.keycloak.v2.admin.resources.assets.ClientScopesSection-Bwk8N3YF.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,j,au as X,P as Y,a2 as b,h as Z,L as x,aA as _,J as $,K as ee,aB as te,N as oe,D as ne,aC as B,az as ae,w as re}from"./index-C1LIsRX7.js";import{g as le}from"./utils-DeGqqWSp.js";import{A as u,r as ce,a as se,c as ie,C as O}from"./ClientScopeTypes-B5zNo17b.js";import{u as pe}from"./ConfirmDialog-B5qjiAuo.js";import{K as de}from"./KeycloakDataTable-jyvvxdb8.js";import{V as me}from"./ViewHeader-qjLr6U82.js";import{S as Se,a as ue,C as he,n as ye,t as fe,p as ge}from"./SearchFilter-CnjdFvwH.js";import{T as v}from"./Td-BwjBKSkH.js";import"react-dom";import"./PaginatingTableToolbar-CpMLQtqt.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./EmptyStateActions-DBSnfkAA.js";import"./_baseFlatten-BHAcGTxk.js";import"./filter-icon-BVyMUArZ.js";import"./grip-vertical-icon-Bnn0MebT.js";const Ce=o=>{const{adminClient:i}=E(),{t:n}=R(),{addAlert:h,addError:p}=V();return t(se,{clientScope:o,type:o.type,all:!0,onSelect:async d=>{try{await ie(i,o,d),h(n("clientScopeSuccess"),j.success),o.refresh()}catch(m){p("clientScopeError",m)}}})},we=({id:o,name:i})=>{const{realm:n}=N();return t(x,{to:ae({realm:n,id:o,tab:"settings"}),children:i},o)};function Ie(){const{adminClient:o}=E(),{realm:i}=N(),{t:n}=R(),{addAlert:h,addError:p}=V(),[d,m]=s(!1),[a,y]=s([]),[r,T]=s("name"),[D,f]=s(u.none),[K,g]=s("all"),I=G(),[A,U]=s(0),l=()=>{y([]),U(A+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(w=>w.name===C.name)?O.default:H.find(w=>w.name===C.name)?O.optional:u.none})).filter(W);return I(q,re("name")).slice(e,Number(e)+Number(L))},[k,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"),j.success),l()}catch(c){p("deleteErrorClientScope",c)}else p(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(b,{children:t(Z,{component:e=>t(x,{...e,to:_({realm:i})}),children:n("createClientScope")})}),t(b,{children:t(he,{selectedRows:a,refresh:l})}),t(b,{children:t($,{shouldFocusToggleOnSelect:!0,toggle:e=>t(ee,{"data-testid":"kebab","aria-label":"Kebab toggle",ref:e,onClick:()=>m(!d),variant:"plain",children:t(te,{})}),isOpen:d,children:t(oe,{children:t(ne,{"data-testid":"delete",isDisabled:a.length===0,onClick:()=>{k(),m(!1)},children:n("delete")})})})})]}),actions:[{title:n("delete"),onRowClick:e=>{y([e]),k()}}],columns:[{name:"name",cellRenderer:we},{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:[B()],transforms:[v(15)]},{name:"description",cellFormatters:[B()]}]},A)})]})}export{Ie as default};
//# sourceMappingURL=ClientScopesSection-Bwk8N3YF.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy