All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.MapperList-58acf988.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{u as w,W as K,r,j as e,N as v,B as L,l as E,D as O,E as V,ah as N,G as I,L as W}from"./index-0cda761d.js";import{L as R}from"./PaginatingTableToolbar-11bdf18a.js";import{K as B}from"./KeycloakDataTable-a1a2bfca.js";import{u as $,m as T}from"./useLocaleSort-ef2c79ac.js";import{M as G,a as q}from"./Modal-ea09312d.js";import{T as b,a as z}from"./Text-b9444fb8.js";import{e as H,D as A,a as k,c as P,d as C}from"./DataListItemRow-7ca17a45.js";const J=o=>{const{t:a}=w("client-scopes"),l=K(),f=o.protocol,n=l.protocolMapperTypes[f],m=l.builtinProtocolMappers[f],[g,p]=r.useState([]),[u,x]=r.useState([]),h=$(),d=r.useMemo(()=>h(m,T("name")).map(t=>{const i=n.filter(c=>c.id===t.protocolMapper)[0];return{item:t,id:t.name,description:i.helpText}}),[m,n]),[y,D]=r.useState(d);if(o.filter&&o.filter.length!==g.length){p(o.filter);const t=o.filter.map(i=>i.name);D([...d.filter(i=>!t.includes(i.item.name))])}const M=r.useMemo(()=>h(n,T("name")),[n]),s=!!o.filter,S=[a("common:name"),a("common:description")];return e.jsxs(G,{"aria-label":a(s?"addPredefinedMappers":"emptySecondaryAction"),variant:q.medium,header:e.jsxs(v,{role:"dialog","aria-label":a(s?"addPredefinedMappers":"emptySecondaryAction"),children:[e.jsx(b,{component:z.h1,children:a(s?"addPredefinedMappers":"emptySecondaryAction")}),e.jsx(b,{children:a(s?"predefinedMappingDescription":"configureMappingDescription")})]}),isOpen:o.open,onClose:o.toggleDialog,actions:s?[e.jsx(L,{id:"modal-confirm","data-testid":"confirm",isDisabled:y.length===0||u.length===0,onClick:()=>{o.onConfirm(u.map(({item:t})=>t)),o.toggleDialog()},children:a("common:add")},"confirm"),e.jsx(L,{id:"modal-cancel","data-testid":"cancel",variant:E.link,onClick:()=>{o.toggleDialog()},children:a("common:cancel")},"cancel")]:[],children:[!s&&e.jsxs(H,{onSelectDataListItem:t=>{const i=n.find(c=>c.id===t);o.onConfirm(i),o.toggleDialog()},"aria-label":a("addPredefinedMappers"),isCompact:!0,children:[e.jsx(A,{"aria-label":a("headerName"),id:"header",children:e.jsx(k,{children:e.jsx(P,{dataListCells:S.map(t=>e.jsx(C,{style:{fontWeight:700},children:t},t))})})}),M.map(t=>e.jsx(A,{"aria-label":t.name,id:t.id,children:e.jsx(k,{children:e.jsx(P,{dataListCells:[e.jsx(C,{children:t.name},`name-${t.id}`),e.jsx(C,{children:t.helpText},`helpText-${t.id}`)]})})},t.id))]}),s&&e.jsx(B,{loader:y,onSelect:x,canSelectAll:!0,ariaLabelKey:"client-scopes:addPredefinedMappers",searchPlaceholderKey:"common:searchForMapper",columns:[{name:"id",displayKey:"common:name"},{name:"description",displayKey:"common:description"}],emptyState:e.jsx(R,{message:a("common:emptyMappers"),instructions:a("client-scopes:emptyBuiltInMappersInstructions")})})]})},Q=({id:o,name:a,detailLink:l})=>e.jsx(W,{to:l(o),children:a}),oe=({model:o,onAdd:a,onDelete:l,detailLink:f})=>{const{t:n}=w("client-scopes"),[m,g]=r.useState(!1),p=o.protocolMappers,u=K().protocolMapperTypes[o.protocol],[x,h]=r.useState(0);r.useEffect(()=>h(x+1),[p]);const[d,y]=r.useState(!1),[D,M]=r.useState(o.protocolMappers),s=t=>{M(t?p||[]:void 0),y(!d)},S=async()=>p?p.reduce((i,c)=>{const j=u.find(({id:F})=>F===c.protocolMapper);return j?i.concat({...c,category:j.category,type:j.name,priority:j.priority}):i},[]).sort((i,c)=>i.priority-c.priority):[];return e.jsxs(e.Fragment,{children:[e.jsx(J,{protocol:o.protocol,filter:D,onConfirm:a,open:d,toggleDialog:()=>y(!d)}),e.jsx(B,{loader:S,ariaLabelKey:"client-scopes:clientScopeList",searchPlaceholderKey:"common:searchForMapper",toolbarItem:e.jsx(O,{onSelect:()=>g(!1),toggle:e.jsx(V,{isPrimary:!0,id:"mapperAction",onToggle:()=>g(!m),toggleIndicator:N,children:n("common:addMapper")}),isOpen:m,dropdownItems:[e.jsx(I,{onClick:()=>s(!0),children:n("fromPredefinedMapper")},"predefined"),e.jsx(I,{onClick:()=>s(!1),children:n("byConfiguration")},"byConfiguration")]}),actions:[{title:n("common:delete"),onRowClick:l}],columns:[{name:"name",cellRenderer:t=>e.jsx(Q,{...t,detailLink:f})},{name:"category"},{name:"type"},{name:"priority"}],emptyState:e.jsx(R,{message:n("common:emptyMappers"),instructions:n("common:emptyMappersInstructions"),secondaryActions:[{text:n("common:emptyPrimaryAction"),onClick:()=>s(!0)},{text:n("emptySecondaryAction"),onClick:()=>s(!1)}]})},x)]})};export{oe as M};
//# sourceMappingURL=MapperList-58acf988.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy