theme.keycloak.v2.admin.resources.assets.MapperList-BvJ2XhLk.js Maven / Gradle / Ivy
import{jsxs as g,jsx as t,Fragment as $}from"react/jsx-runtime";import{useState as s,useMemo as k,useEffect as j}from"react";import{a as R,b as B,s as E,w as A,M as N,q,aa as J,Z as I,$ as W,h as x,B as Z,J as _,K as z,N as G,D as K,L as H}from"./index-C1LIsRX7.js";import{L as F}from"./PaginatingTableToolbar-CpMLQtqt.js";import{K as O}from"./KeycloakDataTable-jyvvxdb8.js";import{d as Q,D as P,a as w,b as v,c as T}from"./DataListItemRow-COCiEHyF.js";const U=a=>{const{t:o}=R(),c=B(),h=a.protocol,n=c.protocolMapperTypes[h],y=c.builtinProtocolMappers[h],[M,d]=s([]),[u,D]=s([]),L=E(),p=k(()=>L(y,A("name")).map(e=>{const r=n.filter(l=>l.id===e.protocolMapper)[0];return{item:e,id:e.name,description:r.helpText}}),[y,n]),[f,S]=s(p);if(a.filter&&a.filter.length!==M.length){d(a.filter);const e=a.filter.map(r=>r.name);S([...p.filter(r=>!e.includes(r.item.name))])}const C=k(()=>L(n,A("name")),[n]),i=!!a.filter,b=[o("name"),o("description")];return g(N,{"aria-label":o(i?"addPredefinedMappers":"emptySecondaryAction"),variant:q.medium,header:g(J,{role:"dialog","aria-label":o(i?"addPredefinedMappers":"emptySecondaryAction"),children:[t(I,{component:W.h1,children:o(i?"addPredefinedMappers":"emptySecondaryAction")}),t(I,{children:o(i?"predefinedMappingDescription":"configureMappingDescription")})]}),isOpen:a.open,onClose:a.toggleDialog,actions:i?[t(x,{id:"modal-confirm","data-testid":"confirm",isDisabled:f.length===0||u.length===0,onClick:()=>{a.onConfirm(u.map(({item:e})=>e)),a.toggleDialog()},children:o("add")},"confirm"),t(x,{id:"modal-cancel","data-testid":"cancel",variant:Z.link,onClick:()=>{a.toggleDialog()},children:o("cancel")},"cancel")]:[],children:[!i&&g(Q,{onSelectDataListItem:(e,r)=>{const l=n.find(m=>m.id===r);a.onConfirm(l),a.toggleDialog()},"aria-label":o("addPredefinedMappers"),isCompact:!0,children:[t(P,{"aria-label":o("headerName"),id:"header",children:t(w,{children:t(v,{dataListCells:b.map(e=>t(T,{style:{fontWeight:700},children:e},e))})})}),C.map(e=>t(P,{"aria-label":e.name,id:e.id,children:t(w,{children:t(v,{dataListCells:[t(T,{children:e.name},`name-${e.id}`),t(T,{children:e.helpText},`helpText-${e.id}`)]})})},e.id))]}),i&&t(O,{loader:f,onSelect:D,canSelectAll:!0,ariaLabelKey:"addPredefinedMappers",searchPlaceholderKey:"searchForMapper",columns:[{name:"id",displayKey:"name"},{name:"description",displayKey:"description"}],emptyState:t(F,{message:o("emptyMappers"),instructions:o("emptyBuiltInMappersInstructions")})})]})},X=({id:a,name:o,detailLink:c})=>t(H,{to:c(a),children:o}),ie=({model:a,onAdd:o,onDelete:c,detailLink:h})=>{const{t:n}=R(),[y,M]=s(!1),d=a.protocolMappers,u=B().protocolMapperTypes[a.protocol],[D,L]=s(0);j(()=>L(D+1),[d]);const[p,f]=s(!1),[S,C]=s(a.protocolMappers),i=e=>{C(e?d||[]:void 0),f(!p)},b=async()=>d?d.reduce((r,l)=>{const m=u.find(({id:V})=>V===l.protocolMapper);return m?r.concat({...l,category:m.category,type:m.name,priority:m.priority}):r},[]).sort((r,l)=>r.priority-l.priority):[];return g($,{children:[t(U,{protocol:a.protocol,filter:S,onConfirm:o,open:p,toggleDialog:()=>f(!p)}),t(O,{loader:b,ariaLabelKey:"clientScopeList",searchPlaceholderKey:"searchForMapper",toolbarItem:t(_,{onSelect:()=>M(!1),toggle:e=>t(z,{ref:e,variant:"primary",id:"mapperAction",onClick:()=>M(!y),children:n("addMapper")}),isOpen:y,children:g(G,{children:[t(K,{onClick:()=>i(!0),children:n("fromPredefinedMapper")}),t(K,{onClick:()=>i(!1),children:n("byConfiguration")})]})}),actions:[{title:n("delete"),onRowClick:c}],columns:[{name:"name",cellRenderer:e=>t(X,{...e,detailLink:h})},{name:"category"},{name:"type"},{name:"priority"}],emptyState:t(F,{message:n("emptyMappers"),instructions:n("emptyMappersInstructions"),secondaryActions:[{text:n("emptyPrimaryAction"),onClick:()=>i(!0)},{text:n("emptySecondaryAction"),onClick:()=>i(!1)}]})},D)]})};export{ie as M};
//# sourceMappingURL=MapperList-BvJ2XhLk.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy