"use strict";(self.webpackChunkportal_ui=self.webpackChunkportal_ui||[]).push([[9134],{58400:function(e,n,t){var i=t(93433),l=t(29439),s=t(72791),c=t(40986),o=t(29945),r=t(21639),u=t(59114),a=t(87995),d=t(81551),f=t(74616),h=t(78687),v=t(31776),x=t(80184);n.Z=function(e){var n=e.noTitle,t=void 0!==n&&n,p=(0,d.TL)(),j=(0,s.useState)([]),m=(0,l.Z)(j,2),g=m[0],b=m[1],Z=(0,s.useState)(!1),y=(0,l.Z)(Z,2),S=y[0],P=y[1],k=(0,s.useState)(""),C=(0,l.Z)(k,2),w=C[0],z=C[1],A=(0,h.v9)((function(e){return e.createUser.selectedPolicies})),L=(0,s.useCallback)((function(){P(!0),v.h.policies.listPolicies().then((function(e){var n,t=null!==(n=e.data.policies)&&void 0!==n?n:[];P(!1),b(t.sort(r.g4))})).catch((function(e){P(!1),p((0,a.zb)(e))}))}),[p]);(0,s.useEffect)((function(){P(!0)}),[]),(0,s.useEffect)((function(){S&&L()}),[S,L]);var T=g.filter((function(e){return e.name.includes(w)}));return(0,x.jsxs)(o.rjZ,{item:!0,xs:12,className:"inputItem",children:[S&&(0,x.jsx)(c.Z,{}),g.length>0?(0,x.jsxs)(s.Fragment,{children:[(0,x.jsx)(o.rjZ,{item:!0,xs:12,className:"inputItem",children:(0,x.jsx)(u.Z,{placeholder:"Start typing to search for a Policy",onChange:function(e){z(e)},value:w,label:t?"":"Assign Policies"})}),(0,x.jsx)(o.wQF,{columns:[{label:"Policy",elementKey:"name"}],onSelect:function(e){var n=e.target,t=n.value,l=n.checked,s=(0,i.Z)(A);l?s.push(t):s=s.filter((function(e){return e!==t})),s=s.filter((function(e){return""!==e})),p((0,f.ue)(s))},selectedItems:A,isLoading:S,records:T,entityName:"Policies",idField:"name",customPaperHeight:"200px"})]}):(0,x.jsx)(o.xuv,{sx:{textAlign:"center",padding:"10px 0"},children:"No Policies Available"})]})}},39134:function(e,n,t){t.r(n);var i=t(29439),l=t(72791),s=t(26181),c=t.n(s),o=t(78687),r=t(29945),u=t(40986),a=t(45248),d=t(87995),f=t(81551),h=t(23814),v=t(74616),x=t(56028),p=t(58400),j=t(81207),m=t(80184);n.default=function(e){var n=e.closeModalAndRefresh,t=e.selectedUser,s=e.selectedGroups,g=e.open,b=(0,f.TL)(),Z=(0,l.useState)(!1),y=(0,i.Z)(Z,2),S=y[0],P=y[1],k=(0,l.useState)([]),C=(0,i.Z)(k,2),w=C[0],z=C[1],A=(0,l.useState)([]),L=(0,i.Z)(A,2),T=L[0],U=L[1],E=(0,o.v9)((function(e){return e.createUser.selectedPolicies}));(0,l.useEffect)((function(){if(g){if(1===(null===s||void 0===s?void 0:s.length))return void(1===(null===s||void 0===s?void 0:s.length)&&j.Z.invoke("GET","/api/v1/group/".concat((0,a.LL)(s[0]))).then((function(e){var n=c()(e,"policy","");z(n.split(",")),U(n.split(",")),b((0,v.ue)(n.split(",")))})).catch((function(e){b((0,d.zb)(e)),P(!1)})));var e=c()(t,"policy",[]);z(e),U(e),b((0,v.ue)(e))}}),[g,null===s||void 0===s?void 0:s.length,t]);var F=c()(t,"accessKey","");return(0,m.jsxs)(x.Z,{onClose:function(){n()},modalOpen:g,title:"Set Policies",children:[(0,m.jsxs)(r.ltY,{withBorders:!1,containerPadding:!1,children:[(1===(null===s||void 0===s?void 0:s.length)||null!=t)&&(0,m.jsxs)(l.Fragment,{children:[(0,m.jsx)(r.bSr,{label:"Selected ".concat(null!==s?"Group":"User"),sx:{width:"100%"},children:null!==s?s[0]:F}),(0,m.jsx)(r.bSr,{label:"Current Policy",sx:{width:"100%"},children:w.join(", ")})]}),s&&(null===s||void 0===s?void 0:s.length)>1&&(0,m.jsx)(r.bSr,{label:"Selected Groups",sx:{width:"100%"},children:s.join(", ")}),(0,m.jsx)(r.rjZ,{item:!0,xs:12,children:(0,m.jsx)(p.Z,{selectedPolicy:T})})]}),(0,m.jsxs)(r.rjZ,{item:!0,xs:12,sx:h.ID.modalButtonBar,children:[(0,m.jsx)(r.zxk,{id:"reset",type:"button",variant:"regular",onClick:function(){U(w),b((0,v.ue)(w))},label:"Reset"}),(0,m.jsx)(r.zxk,{id:"save",type:"button",variant:"callAction",color:"primary",disabled:S,onClick:function(){var e=null,i=null;null!==s?i=s:null!==t&&(e=[t.accessKey]||0),P(!0),j.Z.invoke("PUT","/api/v1/set-policy-multi",{name:E,groups:i,users:e}).then((function(){P(!1),n()})).catch((function(e){P(!1),b((0,d.zb)(e))}))},label:"Save"})]}),S&&(0,m.jsx)(r.rjZ,{item:!0,xs:12,children:(0,m.jsx)(u.Z,{})})]})}}}]);
//# sourceMappingURL=9134.a8ccdcdb.chunk.js.map