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