"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[4705],{42967:(e,l,t)=>{t.d(l,{A:()=>x});var s=t(65043),i=t(89923),n=t(8185),c=t(64681),o=t(64159),a=t(20554),r=t(62560),d=t(22166),u=t(56629),h=t(70579);const x=e=>{let{noTitle:l=!1}=e;const t=(0,a.jL)(),[x,p]=(0,s.useState)([]),[m,v]=(0,s.useState)(!1),[j,y]=(0,s.useState)(""),g=(0,d.d4)((e=>e.createUser.selectedPolicies)),b=(0,s.useCallback)((()=>{v(!0),u.F.policies.listPolicies().then((e=>{var l;const t=null!==(l=e.data.policies)&&void 0!==l?l:[];v(!1),p(t.sort(n.Hw))})).catch((e=>{v(!1),t((0,o.Dy)(e))}))}),[t]);(0,s.useEffect)((()=>{v(!0)}),[]),(0,s.useEffect)((()=>{m&&b()}),[m,b]);const f=x.filter((e=>e.name.includes(j)));return(0,h.jsxs)(i.xA9,{item:!0,xs:12,className:"inputItem",children:[m&&(0,h.jsx)(i.z21,{}),x.length>0?(0,h.jsxs)(s.Fragment,{children:[(0,h.jsx)(i.xA9,{item:!0,xs:12,className:"inputItem",children:(0,h.jsx)(c.A,{placeholder:"Start typing to search for a Policy",onChange:e=>{y(e)},value:j,label:l?"":"Assign Policies"})}),(0,h.jsx)(i.bQt,{columns:[{label:"Policy",elementKey:"name"}],onSelect:e=>{const l=e.target,s=l.value,i=l.checked;let n=[...g];i?n.push(s):n=n.filter((e=>e!==s)),n=n.filter((e=>""!==e)),t((0,r.Gy)(n))},selectedItems:g,isLoading:m,records:f,entityName:"Policies",idField:"name",customPaperHeight:"200px"})]}):(0,h.jsx)(i.azJ,{sx:{textAlign:"center",padding:"10px 0"},children:"No Policies Available"})]})}},74705:(e,l,t)=>{t.r(l),t.d(l,{default:()=>j});var s=t(65043),i=t(33097),n=t.n(i),c=t(22166),o=t(89923),a=t(56483),r=t(64159),d=t(20554),u=t(77403),h=t(62560),x=t(94141),p=t(42967),m=t(20649),v=t(70579);const j=e=>{let{closeModalAndRefresh:l,selectedUser:t,selectedGroups:i,open:j}=e;const y=(0,d.jL)(),[g,b]=(0,s.useState)(!1),[f,A]=(0,s.useState)([]),[P,S]=(0,s.useState)([]),k=(0,c.d4)((e=>e.createUser.selectedPolicies));(0,s.useEffect)((()=>{if(j){if(1===(null===i||void 0===i?void 0:i.length))return void(1===(null===i||void 0===i?void 0:i.length)&&m.A.invoke("GET","/api/v1/group/".concat((0,a.nf)(i[0]))).then((e=>{const l=n()(e,"policy","");A(l.split(",")),S(l.split(",")),y((0,h.Gy)(l.split(",")))})).catch((e=>{y((0,r.Dy)(e)),b(!1)})));const e=n()(t,"policy",[]);A(e),S(e),y((0,h.Gy)(e))}}),[j,null===i||void 0===i?void 0:i.length,t]);const w=n()(t,"accessKey","");return(0,v.jsxs)(x.A,{onClose:()=>{l()},modalOpen:j,title:"Set Policies",children:[(0,v.jsxs)(o.Hbc,{withBorders:!1,containerPadding:!1,children:[(1===(null===i||void 0===i?void 0:i.length)||null!=t)&&(0,v.jsxs)(s.Fragment,{children:[(0,v.jsx)(o.EmB,{label:"Selected ".concat(null!==i?"Group":"User"),sx:{width:"100%"},children:null!==i?i[0]:w}),(0,v.jsx)(o.EmB,{label:"Current Policy",sx:{width:"100%"},children:f.join(", ")})]}),i&&(null===i||void 0===i?void 0:i.length)>1&&(0,v.jsx)(o.EmB,{label:"Selected Groups",sx:{width:"100%"},children:i.join(", ")}),(0,v.jsx)(o.xA9,{item:!0,xs:12,children:(0,v.jsx)(p.A,{selectedPolicy:P})})]}),(0,v.jsxs)(o.xA9,{item:!0,xs:12,sx:u.Uz.modalButtonBar,children:[(0,v.jsx)(o.$nd,{id:"reset",type:"button",variant:"regular",onClick:()=>{S(f),y((0,h.Gy)(f))},label:"Reset"}),(0,v.jsx)(o.$nd,{id:"save",type:"button",variant:"callAction",color:"primary",disabled:g,onClick:()=>{let e=null,s=null;null!==i?s=i:null!==t&&(e=[t.accessKey]||0),b(!0),m.A.invoke("PUT","/api/v1/set-policy-multi",{name:k,groups:s,users:e}).then((()=>{b(!1),l()})).catch((e=>{b(!1),y((0,r.Dy)(e))}))},label:"Save"})]}),g&&(0,v.jsx)(o.xA9,{item:!0,xs:12,children:(0,v.jsx)(o.z21,{})})]})}}}]);
//# sourceMappingURL=4705.2270c966.chunk.js.map