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

theme.keycloak.v2.admin.resources.assets.GroupPickerDialog-C09EjRTA.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as s,jsxs as D}from"react/jsx-runtime";import*as g from"react";import{useState as h,Fragment as Y}from"react";import{_ as q,m as S,cd as Z,I as ee,u as ae,a as J,w as te,M as se,q as O,i as P,cl as ie,cm as T,n as ne}from"./main-C7ps2lmX.js";import{P as le,L as V}from"./PaginatingTableToolbar-Cjsz5Jh4.js";import{s as E,d as ce,D as oe,a as re,b as de,c as me}from"./DataListItemRow-BC0LurDd.js";const U=e=>{var{children:l,className:o,visibility:c,id:b,"aria-label":f,"aria-labelledby":u,isPlainButtonAction:r}=e,d=q(e,["children","className","visibility","id","aria-label","aria-labelledby","isPlainButtonAction"]);return g.createElement("div",Object.assign({className:S(E.dataListItemAction,Z(c,E),o)},d),r?g.createElement("div",{className:S(E.dataListAction)},l):l)};U.displayName="DataListAction";const z=e=>{var{className:l="",onChange:o=(k,n)=>{},isValid:c=!0,isDisabled:b=!1,isChecked:f=!1,checked:u=!1,defaultChecked:r,otherControls:d=!1}=e,i=q(e,["className","onChange","isValid","isDisabled","isChecked","checked","defaultChecked","otherControls"]);const m=g.createElement("div",{className:S(E.dataListCheck)},g.createElement("input",Object.assign({},i,{type:"checkbox",onChange:k=>o(k,k.currentTarget.checked),"aria-invalid":!c,disabled:b},[!0,!1].includes(r)&&{defaultChecked:r},![!0,!1].includes(r)&&{checked:f||u})));return g.createElement(g.Fragment,null,!d&&g.createElement("div",{className:S(E.dataListItemControl,l)},m),d&&m)};z.displayName="DataListCheck";const he=({group:{path:e},onMouseEnter:l,...o})=>{const[c,b]=h(""),u=s("span",{onMouseEnter:r=>{b(e),l?.(r)},...o,children:e});return c!==""?s(ee,{content:c,isVisible:!0,children:u}):u},Ce=({id:e,type:l,filterGroups:o,text:c,canBrowse:b=!0,isMove:f=!1,onClose:u,onConfirm:r})=>{const{adminClient:d}=ae(),{t:i}=J(),[m,k]=h([]),[n,v]=h([]),[x,H]=h([]),[A,K]=h(""),[Q,W]=h([]),[G,L]=h(),[p,R]=h(!1),[N,I]=h(10),[w,y]=h(0),[X,j]=h(0),B=()=>n[n.length-1];te(async()=>{let a,t,M;if(G){if(!n.map(({id:$})=>$).includes(G)&&(a=await d.groups.findOne({id:G}),!a))throw new Error(i("notFound"));const C={first:w,max:N,parentId:G};t=await d.groups.listSubGroups(C)}else{const C={first:w,max:N+1};p&&(C.search=A),t=await d.groups.find(C)}return e&&(M=await d.users.listGroups({id:e})),{group:a,groups:t,existingUserGroups:M}},async({group:a,groups:t,existingUserGroups:M})=>{W(M||[]),a&&(v([...n,a]),j(a.subGroupCount)),t.forEach(C=>{C.checked=!!m.find($=>$.id===C.id)}),H(t),(p||!G)&&j(t.length)},[G,A,w,N]);const F=a=>[...Q.map(t=>t.id),...(o||[]).map(t=>t.id)].some(t=>t===a?.id);return s(se,{variant:p?O.medium:O.small,title:i(c.title,{group1:o?.[0]?.name,group2:n.length?B().name:i("root")}),isOpen:!0,onClose:u,actions:[s(P,{"data-testid":`${c.ok}-button`,variant:"primary",form:"group-form",onClick:()=>{r(l==="selectMany"?m:n.length?[B()]:void 0)},isDisabled:l==="selectMany"&&m.length===0,children:i(c.ok)},"confirm")],children:D(le,{count:X,first:w,max:N,onNextClick:y,onPreviousClick:y,onPerPageSelect:(a,t)=>{y(a),I(t)},inputGroupName:"search",inputGroupOnEnter:a=>{K(a),R(a!==""),y(0),I(10),v([]),L(void 0)},inputGroupPlaceholder:i("searchForGroups"),children:[D(ie,{children:[n.length>0&&s(T,{children:s(P,{variant:"link",onClick:()=>{L(void 0),v([]),y(0),I(10)},children:i("groups")})},"home"),n.map((a,t)=>D(T,{children:[n.length-1!==t&&s(P,{variant:"link",onClick:()=>{L(a.id),v([...n].slice(0,t)),y(0),I(10)},children:a.name}),n.length-1===t&&a.name]},t))]}),s(ce,{"aria-label":i("groups"),isCompact:!0,children:x.slice(0,N).map(a=>D(Y,{children:[(!p||a.name?.includes(A))&&s(_,{group:a,isRowDisabled:F,onSelect:L,type:l,isSearching:p,setIsSearching:R,selectedRows:m,setSelectedRows:k,canBrowse:b},a.id),p&&a.subGroups?.map(t=>s(_,{group:t,isRowDisabled:F,onSelect:L,type:l,isSearching:p,setIsSearching:R,selectedRows:m,setSelectedRows:k,canBrowse:b},t.id))]},a.id))}),x.length===0&&!p&&s(V,{hasIcon:!1,message:i("moveGroupEmpty"),instructions:f?i("moveGroupEmptyInstructions"):void 0}),x.length===0&&p&&s(V,{message:i("noSearchResults"),instructions:i("noSearchResultsInstructions")})]})})},_=({group:e,type:l,isRowDisabled:o,isSearching:c,setIsSearching:b,onSelect:f,selectedRows:u,setSelectedRows:r,canBrowse:d})=>{const{t:i}=J();return s(oe,{"aria-labelledby":e.name,id:e.id,onClick:m=>{l==="selectOne"?f(e.id):m.target.type!=="checkbox"&&e.subGroupCount!==0&&(f(e.id),b(!1))},children:D(re,{className:`join-group-dialog-row${o(e)?"-m-disabled":""}`,"data-testid":e.name,children:[l==="selectMany"&&s(z,{className:"kc-join-group-modal-check","data-testid":`${e.name}-check`,"aria-label":e.name,checked:e.checked,isDisabled:o(e),onChange:(m,k)=>{e.checked=k;let n=[];e.checked?n=[...u,e]:n=u.filter(v=>v.id!==e.id),r(n)},"aria-labelledby":`select-${e.name}`}),s(de,{dataListCells:[s(me,{className:"keycloak-groups-group-path",children:c?s(he,{id:`select-${e.name}`,group:e}):s("span",{id:`select-${e.name}`,children:e.name})},`name-${e.id}`)]}),s(U,{id:"actions","aria-labelledby":`select-${e.name}`,"aria-label":i("groupName"),isPlainButtonAction:!0,children:(d||l==="selectOne")&&e.subGroupCount!==0&&s(P,{variant:"link","aria-label":i("select"),children:s(ne,{})})})]})},e.id)};export{Ce as G,he as a};
//# sourceMappingURL=GroupPickerDialog-C09EjRTA.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy