"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:()=>v});var s=t(65043),i=t(33097),n=t.n(i),c=t(22166),o=t(89923),a=t(64159),r=t(20554),d=t(77403),u=t(62560),h=t(94141),x=t(42967),p=t(20649),m=t(70579);const v=e=>{let{closeModalAndRefresh:l,selectedUser:t,selectedGroups:i,open:v}=e;const j=(0,r.jL)(),[y,g]=(0,s.useState)(!1),[b,f]=(0,s.useState)([]),[A,P]=(0,s.useState)([]),S=(0,c.d4)((e=>e.createUser.selectedPolicies));(0,s.useEffect)((()=>{if(v){if(1===(null===i||void 0===i?void 0:i.length))return void(1===(null===i||void 0===i?void 0:i.length)&&p.A.invoke("GET","/api/v1/group/".concat(encodeURIComponent(i[0]))).then((e=>{const l=n()(e,"policy","");f(l.split(",")),P(l.split(",")),j((0,u.Gy)(l.split(",")))})).catch((e=>{j((0,a.Dy)(e)),g(!1)})));const e=n()(t,"policy",[]);f(e),P(e),j((0,u.Gy)(e))}}),[v,null===i||void 0===i?void 0:i.length,t]);const k=n()(t,"accessKey","");return(0,m.jsxs)(h.A,{onClose:()=>{l()},modalOpen:v,title:"Set Policies",children:[(0,m.jsxs)(o.Hbc,{withBorders:!1,containerPadding:!1,children:[(1===(null===i||void 0===i?void 0:i.length)||null!=t)&&(0,m.jsxs)(s.Fragment,{children:[(0,m.jsx)(o.EmB,{label:"Selected ".concat(null!==i?"Group":"User"),sx:{width:"100%"},children:null!==i?i[0]:k}),(0,m.jsx)(o.EmB,{label:"Current Policy",sx:{width:"100%"},children:b.join(", ")})]}),i&&(null===i||void 0===i?void 0:i.length)>1&&(0,m.jsx)(o.EmB,{label:"Selected Groups",sx:{width:"100%"},children:i.join(", ")}),(0,m.jsx)(o.xA9,{item:!0,xs:12,children:(0,m.jsx)(x.A,{selectedPolicy:A})})]}),(0,m.jsxs)(o.xA9,{item:!0,xs:12,sx:d.Uz.modalButtonBar,children:[(0,m.jsx)(o.$nd,{id:"reset",type:"button",variant:"regular",onClick:()=>{P(b),j((0,u.Gy)(b))},label:"Reset"}),(0,m.jsx)(o.$nd,{id:"save",type:"button",variant:"callAction",color:"primary",disabled:y,onClick:()=>{let e=null,s=null;null!==i?s=i:null!==t&&(e=[t.accessKey]||0),g(!0),p.A.invoke("PUT","/api/v1/set-policy-multi",{name:S,groups:s,users:e}).then((()=>{g(!1),l()})).catch((e=>{g(!1),j((0,a.Dy)(e))}))},label:"Save"})]}),y&&(0,m.jsx)(o.xA9,{item:!0,xs:12,children:(0,m.jsx)(o.z21,{})})]})}}}]);
//# sourceMappingURL=4705.1a1c4cd3.chunk.js.map